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: 4.1.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    UnknownValue(serde_json::Value),
42}
43
44/// struct for typed errors of method [`delete_cmmn_case_by_path`]
45#[derive(Debug, Clone, Serialize, Deserialize)]
46#[serde(untagged)]
47pub enum DeleteCmmnCaseByPathError {
48    Status400(String),
49    Status404(String),
50    UnknownValue(serde_json::Value),
51}
52
53/// struct for typed errors of method [`exists_cmmn_case_by_path`]
54#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum ExistsCmmnCaseByPathError {
57    Status404(String),
58    UnknownValue(serde_json::Value),
59}
60
61/// struct for typed errors of method [`get_cmmn_case`]
62#[derive(Debug, Clone, Serialize, Deserialize)]
63#[serde(untagged)]
64pub enum GetCmmnCaseError {
65    Status404(String),
66    UnknownValue(serde_json::Value),
67}
68
69/// struct for typed errors of method [`get_cmmn_case_by_path`]
70#[derive(Debug, Clone, Serialize, Deserialize)]
71#[serde(untagged)]
72pub enum GetCmmnCaseByPathError {
73    Status404(String),
74    UnknownValue(serde_json::Value),
75}
76
77/// struct for typed errors of method [`get_cmmn_case_by_path_with_draft`]
78#[derive(Debug, Clone, Serialize, Deserialize)]
79#[serde(untagged)]
80pub enum GetCmmnCaseByPathWithDraftError {
81    Status404(String),
82    UnknownValue(serde_json::Value),
83}
84
85/// struct for typed errors of method [`get_cmmn_case_history`]
86#[derive(Debug, Clone, Serialize, Deserialize)]
87#[serde(untagged)]
88pub enum GetCmmnCaseHistoryError {
89    Status404(String),
90    UnknownValue(serde_json::Value),
91}
92
93/// struct for typed errors of method [`get_cmmn_case_overview`]
94#[derive(Debug, Clone, Serialize, Deserialize)]
95#[serde(untagged)]
96pub enum GetCmmnCaseOverviewError {
97    Status400(String),
98    Status404(String),
99    UnknownValue(serde_json::Value),
100}
101
102/// struct for typed errors of method [`get_cmmn_case_status`]
103#[derive(Debug, Clone, Serialize, Deserialize)]
104#[serde(untagged)]
105pub enum GetCmmnCaseStatusError {
106    Status404(String),
107    UnknownValue(serde_json::Value),
108}
109
110/// struct for typed errors of method [`list_cmmn_case_instances`]
111#[derive(Debug, Clone, Serialize, Deserialize)]
112#[serde(untagged)]
113pub enum ListCmmnCaseInstancesError {
114    Status404(String),
115    UnknownValue(serde_json::Value),
116}
117
118/// struct for typed errors of method [`list_cmmn_cases`]
119#[derive(Debug, Clone, Serialize, Deserialize)]
120#[serde(untagged)]
121pub enum ListCmmnCasesError {
122    Status404(String),
123    UnknownValue(serde_json::Value),
124}
125
126/// struct for typed errors of method [`resume_cmmn_case_instance`]
127#[derive(Debug, Clone, Serialize, Deserialize)]
128#[serde(untagged)]
129pub enum ResumeCmmnCaseInstanceError {
130    Status400(String),
131    Status404(String),
132    UnknownValue(serde_json::Value),
133}
134
135/// struct for typed errors of method [`start_cmmn_case`]
136#[derive(Debug, Clone, Serialize, Deserialize)]
137#[serde(untagged)]
138pub enum StartCmmnCaseError {
139    Status404(String),
140    UnknownValue(serde_json::Value),
141}
142
143/// struct for typed errors of method [`suspend_cmmn_case_instance`]
144#[derive(Debug, Clone, Serialize, Deserialize)]
145#[serde(untagged)]
146pub enum SuspendCmmnCaseInstanceError {
147    Status400(String),
148    Status404(String),
149    UnknownValue(serde_json::Value),
150}
151
152/// struct for typed errors of method [`terminate_cmmn_case_instance`]
153#[derive(Debug, Clone, Serialize, Deserialize)]
154#[serde(untagged)]
155pub enum TerminateCmmnCaseInstanceError {
156    Status400(String),
157    Status404(String),
158    UnknownValue(serde_json::Value),
159}
160
161/// struct for typed errors of method [`trigger_cmmn_plan_item`]
162#[derive(Debug, Clone, Serialize, Deserialize)]
163#[serde(untagged)]
164pub enum TriggerCmmnPlanItemError {
165    Status400(String),
166    Status401(String),
167    Status404(String),
168    UnknownValue(serde_json::Value),
169}
170
171/// struct for typed errors of method [`update_cmmn_case`]
172#[derive(Debug, Clone, Serialize, Deserialize)]
173#[serde(untagged)]
174pub enum UpdateCmmnCaseError {
175    Status400(Vec<models::CmmnRefusal>),
176    Status404(String),
177    UnknownValue(serde_json::Value),
178}
179
180
181pub 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>> {
182    let local_var_configuration = configuration;
183
184    let local_var_client = &local_var_configuration.client;
185
186    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));
187    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
188
189    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
190        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
191    }
192    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
193        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
194    };
195    local_var_req_builder = local_var_req_builder.json(&archive_flow_by_path_request);
196
197    let local_var_req = local_var_req_builder.build()?;
198    let local_var_resp = local_var_client.execute(local_var_req).await?;
199
200    let local_var_status = local_var_resp.status();
201    let local_var_content = local_var_resp.text().await?;
202
203    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
204        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
205    } else {
206        let local_var_entity: Option<ArchiveCmmnCaseByPathError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
207        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
208        Err(Error::ResponseError(local_var_error))
209    }
210}
211
212/// 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. 
213pub async fn close_cmmn_case_instance(configuration: &configuration::Configuration, workspace: &str, id: &str) -> Result<String, Error<CloseCmmnCaseInstanceError>> {
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}/cmmn/instances/close/{id}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), id=crate::apis::urlencode(id));
219    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, 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/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
236    } else {
237        let local_var_entity: Option<CloseCmmnCaseInstanceError> = crate::from_str_patched/* Externally injected from /build.nu */(&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 create_cmmn_case(configuration: &configuration::Configuration, workspace: &str, new_cmmn_case_model: models::NewCmmnCaseModel) -> Result<models::CmmnDeployResult, Error<CreateCmmnCaseError>> {
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}/cmmn_cases/create", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
249    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, 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    local_var_req_builder = local_var_req_builder.json(&new_cmmn_case_model);
258
259    let local_var_req = local_var_req_builder.build()?;
260    let local_var_resp = local_var_client.execute(local_var_req).await?;
261
262    let local_var_status = local_var_resp.status();
263    let local_var_content = local_var_resp.text().await?;
264
265    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
266        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
267    } else {
268        let local_var_entity: Option<CreateCmmnCaseError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
269        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
270        Err(Error::ResponseError(local_var_error))
271    }
272}
273
274pub async fn delete_cmmn_case_by_path(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<String, Error<DeleteCmmnCaseByPathError>> {
275    let local_var_configuration = configuration;
276
277    let local_var_client = &local_var_configuration.client;
278
279    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));
280    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
281
282    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
283        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
284    }
285    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
286        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
287    };
288
289    let local_var_req = local_var_req_builder.build()?;
290    let local_var_resp = local_var_client.execute(local_var_req).await?;
291
292    let local_var_status = local_var_resp.status();
293    let local_var_content = local_var_resp.text().await?;
294
295    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
296        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
297    } else {
298        let local_var_entity: Option<DeleteCmmnCaseByPathError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
299        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
300        Err(Error::ResponseError(local_var_error))
301    }
302}
303
304pub async fn exists_cmmn_case_by_path(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<bool, Error<ExistsCmmnCaseByPathError>> {
305    let local_var_configuration = configuration;
306
307    let local_var_client = &local_var_configuration.client;
308
309    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));
310    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
311
312    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
313        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
314    }
315    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
316        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
317    };
318
319    let local_var_req = local_var_req_builder.build()?;
320    let local_var_resp = local_var_client.execute(local_var_req).await?;
321
322    let local_var_status = local_var_resp.status();
323    let local_var_content = local_var_resp.text().await?;
324
325    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
326        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
327    } else {
328        let local_var_entity: Option<ExistsCmmnCaseByPathError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
329        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
330        Err(Error::ResponseError(local_var_error))
331    }
332}
333
334/// 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. 
335pub async fn get_cmmn_case(configuration: &configuration::Configuration, workspace: &str, id: &str) -> Result<models::CmmnCaseDetail, Error<GetCmmnCaseError>> {
336    let local_var_configuration = configuration;
337
338    let local_var_client = &local_var_configuration.client;
339
340    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));
341    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
342
343    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
344        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
345    }
346    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
347        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
348    };
349
350    let local_var_req = local_var_req_builder.build()?;
351    let local_var_resp = local_var_client.execute(local_var_req).await?;
352
353    let local_var_status = local_var_resp.status();
354    let local_var_content = local_var_resp.text().await?;
355
356    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
357        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
358    } else {
359        let local_var_entity: Option<GetCmmnCaseError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
360        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
361        Err(Error::ResponseError(local_var_error))
362    }
363}
364
365pub async fn get_cmmn_case_by_path(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<models::CmmnCaseModel, Error<GetCmmnCaseByPathError>> {
366    let local_var_configuration = configuration;
367
368    let local_var_client = &local_var_configuration.client;
369
370    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));
371    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
372
373    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
374        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
375    }
376    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
377        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
378    };
379
380    let local_var_req = local_var_req_builder.build()?;
381    let local_var_resp = local_var_client.execute(local_var_req).await?;
382
383    let local_var_status = local_var_resp.status();
384    let local_var_content = local_var_resp.text().await?;
385
386    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
387        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
388    } else {
389        let local_var_entity: Option<GetCmmnCaseByPathError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
390        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
391        Err(Error::ResponseError(local_var_error))
392    }
393}
394
395pub async fn get_cmmn_case_by_path_with_draft(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<models::CmmnCaseModelWithDraft, Error<GetCmmnCaseByPathWithDraftError>> {
396    let local_var_configuration = configuration;
397
398    let local_var_client = &local_var_configuration.client;
399
400    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));
401    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
402
403    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
404        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
405    }
406    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
407        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
408    };
409
410    let local_var_req = local_var_req_builder.build()?;
411    let local_var_resp = local_var_client.execute(local_var_req).await?;
412
413    let local_var_status = local_var_resp.status();
414    let local_var_content = local_var_resp.text().await?;
415
416    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
417        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
418    } else {
419        let local_var_entity: Option<GetCmmnCaseByPathWithDraftError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
420        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
421        Err(Error::ResponseError(local_var_error))
422    }
423}
424
425pub async fn get_cmmn_case_history(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<Vec<models::CmmnCaseModelVersion>, Error<GetCmmnCaseHistoryError>> {
426    let local_var_configuration = configuration;
427
428    let local_var_client = &local_var_configuration.client;
429
430    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));
431    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
432
433    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
434        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
435    }
436    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
437        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
438    };
439
440    let local_var_req = local_var_req_builder.build()?;
441    let local_var_resp = local_var_client.execute(local_var_req).await?;
442
443    let local_var_status = local_var_resp.status();
444    let local_var_content = local_var_resp.text().await?;
445
446    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
447        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
448    } else {
449        let local_var_entity: Option<GetCmmnCaseHistoryError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
450        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
451        Err(Error::ResponseError(local_var_error))
452    }
453}
454
455/// 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. 
456pub async fn get_cmmn_case_overview(configuration: &configuration::Configuration, workspace: &str, version: i64) -> Result<models::CmmnCaseOverview, Error<GetCmmnCaseOverviewError>> {
457    let local_var_configuration = configuration;
458
459    let local_var_client = &local_var_configuration.client;
460
461    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);
462    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
463
464    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
465        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
466    }
467    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
468        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
469    };
470
471    let local_var_req = local_var_req_builder.build()?;
472    let local_var_resp = local_var_client.execute(local_var_req).await?;
473
474    let local_var_status = local_var_resp.status();
475    let local_var_content = local_var_resp.text().await?;
476
477    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
478        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
479    } else {
480        let local_var_entity: Option<GetCmmnCaseOverviewError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
481        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
482        Err(Error::ResponseError(local_var_error))
483    }
484}
485
486/// 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. 
487pub async fn get_cmmn_case_status(configuration: &configuration::Configuration, workspace: &str, id: &str) -> Result<models::CmmnCaseInstanceStatus, Error<GetCmmnCaseStatusError>> {
488    let local_var_configuration = configuration;
489
490    let local_var_client = &local_var_configuration.client;
491
492    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));
493    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
494
495    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
496        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
497    }
498    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
499        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
500    };
501
502    let local_var_req = local_var_req_builder.build()?;
503    let local_var_resp = local_var_client.execute(local_var_req).await?;
504
505    let local_var_status = local_var_resp.status();
506    let local_var_content = local_var_resp.text().await?;
507
508    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
509        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
510    } else {
511        let local_var_entity: Option<GetCmmnCaseStatusError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
512        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
513        Err(Error::ResponseError(local_var_error))
514    }
515}
516
517/// 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`. 
518pub 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>> {
519    let local_var_configuration = configuration;
520
521    let local_var_client = &local_var_configuration.client;
522
523    let local_var_uri_str = format!("{}/w/{workspace}/cmmn/instances/list", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
524    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
525
526    if let Some(ref local_var_str) = page {
527        local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
528    }
529    if let Some(ref local_var_str) = per_page {
530        local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
531    }
532    if let Some(ref local_var_str) = business_key {
533        local_var_req_builder = local_var_req_builder.query(&[("business_key", &local_var_str.to_string())]);
534    }
535    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
536        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
537    }
538    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
539        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
540    };
541
542    let local_var_req = local_var_req_builder.build()?;
543    let local_var_resp = local_var_client.execute(local_var_req).await?;
544
545    let local_var_status = local_var_resp.status();
546    let local_var_content = local_var_resp.text().await?;
547
548    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
549        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
550    } else {
551        let local_var_entity: Option<ListCmmnCaseInstancesError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
552        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
553        Err(Error::ResponseError(local_var_error))
554    }
555}
556
557pub 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>) -> Result<Vec<models::ListableCmmnCaseModel>, Error<ListCmmnCasesError>> {
558    let local_var_configuration = configuration;
559
560    let local_var_client = &local_var_configuration.client;
561
562    let local_var_uri_str = format!("{}/w/{workspace}/cmmn_cases/list", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
563    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
564
565    if let Some(ref local_var_str) = page {
566        local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
567    }
568    if let Some(ref local_var_str) = per_page {
569        local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
570    }
571    if let Some(ref local_var_str) = path_start {
572        local_var_req_builder = local_var_req_builder.query(&[("path_start", &local_var_str.to_string())]);
573    }
574    if let Some(ref local_var_str) = show_archived {
575        local_var_req_builder = local_var_req_builder.query(&[("show_archived", &local_var_str.to_string())]);
576    }
577    if let Some(ref local_var_str) = include_draft_only {
578        local_var_req_builder = local_var_req_builder.query(&[("include_draft_only", &local_var_str.to_string())]);
579    }
580    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
581        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
582    }
583    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
584        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
585    };
586
587    let local_var_req = local_var_req_builder.build()?;
588    let local_var_resp = local_var_client.execute(local_var_req).await?;
589
590    let local_var_status = local_var_resp.status();
591    let local_var_content = local_var_resp.text().await?;
592
593    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
594        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
595    } else {
596        let local_var_entity: Option<ListCmmnCasesError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
597        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
598        Err(Error::ResponseError(local_var_error))
599    }
600}
601
602/// 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. 
603pub async fn resume_cmmn_case_instance(configuration: &configuration::Configuration, workspace: &str, id: &str) -> Result<String, Error<ResumeCmmnCaseInstanceError>> {
604    let local_var_configuration = configuration;
605
606    let local_var_client = &local_var_configuration.client;
607
608    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));
609    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
610
611    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
612        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
613    }
614    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
615        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
616    };
617
618    let local_var_req = local_var_req_builder.build()?;
619    let local_var_resp = local_var_client.execute(local_var_req).await?;
620
621    let local_var_status = local_var_resp.status();
622    let local_var_content = local_var_resp.text().await?;
623
624    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
625        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
626    } else {
627        let local_var_entity: Option<ResumeCmmnCaseInstanceError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
628        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
629        Err(Error::ResponseError(local_var_error))
630    }
631}
632
633/// 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. 
634pub async fn start_cmmn_case(configuration: &configuration::Configuration, workspace: &str, path: &str, start_cmmn_case: models::StartCmmnCase) -> Result<String, Error<StartCmmnCaseError>> {
635    let local_var_configuration = configuration;
636
637    let local_var_client = &local_var_configuration.client;
638
639    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));
640    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
641
642    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
643        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
644    }
645    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
646        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
647    };
648    local_var_req_builder = local_var_req_builder.json(&start_cmmn_case);
649
650    let local_var_req = local_var_req_builder.build()?;
651    let local_var_resp = local_var_client.execute(local_var_req).await?;
652
653    let local_var_status = local_var_resp.status();
654    let local_var_content = local_var_resp.text().await?;
655
656    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
657        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
658    } else {
659        let local_var_entity: Option<StartCmmnCaseError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
660        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
661        Err(Error::ResponseError(local_var_error))
662    }
663}
664
665/// 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. 
666pub async fn suspend_cmmn_case_instance(configuration: &configuration::Configuration, workspace: &str, id: &str) -> Result<String, Error<SuspendCmmnCaseInstanceError>> {
667    let local_var_configuration = configuration;
668
669    let local_var_client = &local_var_configuration.client;
670
671    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));
672    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
673
674    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
675        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
676    }
677    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
678        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
679    };
680
681    let local_var_req = local_var_req_builder.build()?;
682    let local_var_resp = local_var_client.execute(local_var_req).await?;
683
684    let local_var_status = local_var_resp.status();
685    let local_var_content = local_var_resp.text().await?;
686
687    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
688        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
689    } else {
690        let local_var_entity: Option<SuspendCmmnCaseInstanceError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
691        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
692        Err(Error::ResponseError(local_var_error))
693    }
694}
695
696/// 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. 
697pub async fn terminate_cmmn_case_instance(configuration: &configuration::Configuration, workspace: &str, id: &str) -> Result<String, Error<TerminateCmmnCaseInstanceError>> {
698    let local_var_configuration = configuration;
699
700    let local_var_client = &local_var_configuration.client;
701
702    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));
703    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
704
705    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
706        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
707    }
708    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
709        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
710    };
711
712    let local_var_req = local_var_req_builder.build()?;
713    let local_var_resp = local_var_client.execute(local_var_req).await?;
714
715    let local_var_status = local_var_resp.status();
716    let local_var_content = local_var_resp.text().await?;
717
718    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
719        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
720    } else {
721        let local_var_entity: Option<TerminateCmmnCaseInstanceError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
722        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
723        Err(Error::ResponseError(local_var_error))
724    }
725}
726
727/// 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. 
728pub 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>> {
729    let local_var_configuration = configuration;
730
731    let local_var_client = &local_var_configuration.client;
732
733    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));
734    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
735
736    if let Some(ref local_var_str) = instance {
737        local_var_req_builder = local_var_req_builder.query(&[("instance", &local_var_str.to_string())]);
738    }
739    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
740        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
741    }
742    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
743        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
744    };
745
746    let local_var_req = local_var_req_builder.build()?;
747    let local_var_resp = local_var_client.execute(local_var_req).await?;
748
749    let local_var_status = local_var_resp.status();
750    let local_var_content = local_var_resp.text().await?;
751
752    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
753        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
754    } else {
755        let local_var_entity: Option<TriggerCmmnPlanItemError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
756        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
757        Err(Error::ResponseError(local_var_error))
758    }
759}
760
761pub async fn update_cmmn_case(configuration: &configuration::Configuration, workspace: &str, path: &str, new_cmmn_case_model: models::NewCmmnCaseModel) -> Result<models::CmmnDeployResult, Error<UpdateCmmnCaseError>> {
762    let local_var_configuration = configuration;
763
764    let local_var_client = &local_var_configuration.client;
765
766    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));
767    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
768
769    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
770        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
771    }
772    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
773        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
774    };
775    local_var_req_builder = local_var_req_builder.json(&new_cmmn_case_model);
776
777    let local_var_req = local_var_req_builder.build()?;
778    let local_var_resp = local_var_client.execute(local_var_req).await?;
779
780    let local_var_status = local_var_resp.status();
781    let local_var_content = local_var_resp.text().await?;
782
783    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
784        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
785    } else {
786        let local_var_entity: Option<UpdateCmmnCaseError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
787        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
788        Err(Error::ResponseError(local_var_error))
789    }
790}
791