/*
* Orvanta API
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 4.1.0
* Contact: contact@orvanta.cloud
* Generated by: https://openapi-generator.tech
*/
use reqwest;
use serde::{Deserialize, Serialize};
use crate::{apis::ResponseContent, models};
use super::{Error, configuration};
/// struct for typed errors of method [`archive_cmmn_case_by_path`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ArchiveCmmnCaseByPathError {
Status404(String),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`close_cmmn_case_instance`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CloseCmmnCaseInstanceError {
Status400(String),
Status404(String),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_cmmn_case`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateCmmnCaseError {
Status400(Vec<models::CmmnRefusal>),
Status404(String),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_cmmn_case_by_path`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteCmmnCaseByPathError {
Status400(String),
Status404(String),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`exists_cmmn_case_by_path`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ExistsCmmnCaseByPathError {
Status404(String),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_cmmn_case`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCmmnCaseError {
Status404(String),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_cmmn_case_by_path`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCmmnCaseByPathError {
Status404(String),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_cmmn_case_by_path_with_draft`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCmmnCaseByPathWithDraftError {
Status404(String),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_cmmn_case_history`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCmmnCaseHistoryError {
Status404(String),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_cmmn_case_overview`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCmmnCaseOverviewError {
Status400(String),
Status404(String),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_cmmn_case_status`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCmmnCaseStatusError {
Status404(String),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_cmmn_case_instances`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListCmmnCaseInstancesError {
Status404(String),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_cmmn_cases`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListCmmnCasesError {
Status404(String),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`resume_cmmn_case_instance`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ResumeCmmnCaseInstanceError {
Status400(String),
Status404(String),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`start_cmmn_case`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum StartCmmnCaseError {
Status404(String),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`suspend_cmmn_case_instance`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SuspendCmmnCaseInstanceError {
Status400(String),
Status404(String),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`terminate_cmmn_case_instance`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum TerminateCmmnCaseInstanceError {
Status400(String),
Status404(String),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`trigger_cmmn_plan_item`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum TriggerCmmnPlanItemError {
Status400(String),
Status401(String),
Status404(String),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_cmmn_case`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateCmmnCaseError {
Status400(Vec<models::CmmnRefusal>),
Status404(String),
UnknownValue(serde_json::Value),
}
pub 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>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
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));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&archive_flow_by_path_request);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<ArchiveCmmnCaseByPathError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// 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.
pub async fn close_cmmn_case_instance(configuration: &configuration::Configuration, workspace: &str, id: &str) -> Result<String, Error<CloseCmmnCaseInstanceError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
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));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<CloseCmmnCaseInstanceError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
pub async fn create_cmmn_case(configuration: &configuration::Configuration, workspace: &str, new_cmmn_case_model: models::NewCmmnCaseModel) -> Result<models::CmmnDeployResult, Error<CreateCmmnCaseError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/w/{workspace}/cmmn_cases/create", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&new_cmmn_case_model);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<CreateCmmnCaseError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
pub async fn delete_cmmn_case_by_path(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<String, Error<DeleteCmmnCaseByPathError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
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));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<DeleteCmmnCaseByPathError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
pub async fn exists_cmmn_case_by_path(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<bool, Error<ExistsCmmnCaseByPathError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
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));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<ExistsCmmnCaseByPathError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// 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.
pub async fn get_cmmn_case(configuration: &configuration::Configuration, workspace: &str, id: &str) -> Result<models::CmmnCaseDetail, Error<GetCmmnCaseError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
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));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<GetCmmnCaseError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
pub async fn get_cmmn_case_by_path(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<models::CmmnCaseModel, Error<GetCmmnCaseByPathError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
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));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<GetCmmnCaseByPathError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
pub async fn get_cmmn_case_by_path_with_draft(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<models::CmmnCaseModelWithDraft, Error<GetCmmnCaseByPathWithDraftError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
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));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<GetCmmnCaseByPathWithDraftError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
pub async fn get_cmmn_case_history(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<Vec<models::CmmnCaseModelVersion>, Error<GetCmmnCaseHistoryError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
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));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<GetCmmnCaseHistoryError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// 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.
pub async fn get_cmmn_case_overview(configuration: &configuration::Configuration, workspace: &str, version: i64) -> Result<models::CmmnCaseOverview, Error<GetCmmnCaseOverviewError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
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);
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<GetCmmnCaseOverviewError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// 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.
pub async fn get_cmmn_case_status(configuration: &configuration::Configuration, workspace: &str, id: &str) -> Result<models::CmmnCaseInstanceStatus, Error<GetCmmnCaseStatusError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
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));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<GetCmmnCaseStatusError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// 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`.
pub 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>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/w/{workspace}/cmmn/instances/list", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_str) = page {
local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = per_page {
local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = business_key {
local_var_req_builder = local_var_req_builder.query(&[("business_key", &local_var_str.to_string())]);
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<ListCmmnCaseInstancesError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
pub 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>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/w/{workspace}/cmmn_cases/list", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_str) = page {
local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = per_page {
local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = path_start {
local_var_req_builder = local_var_req_builder.query(&[("path_start", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = show_archived {
local_var_req_builder = local_var_req_builder.query(&[("show_archived", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = include_draft_only {
local_var_req_builder = local_var_req_builder.query(&[("include_draft_only", &local_var_str.to_string())]);
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<ListCmmnCasesError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// 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.
pub async fn resume_cmmn_case_instance(configuration: &configuration::Configuration, workspace: &str, id: &str) -> Result<String, Error<ResumeCmmnCaseInstanceError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
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));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<ResumeCmmnCaseInstanceError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// 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.
pub async fn start_cmmn_case(configuration: &configuration::Configuration, workspace: &str, path: &str, start_cmmn_case: models::StartCmmnCase) -> Result<String, Error<StartCmmnCaseError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
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));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&start_cmmn_case);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<StartCmmnCaseError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// 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.
pub async fn suspend_cmmn_case_instance(configuration: &configuration::Configuration, workspace: &str, id: &str) -> Result<String, Error<SuspendCmmnCaseInstanceError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
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));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<SuspendCmmnCaseInstanceError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// 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.
pub async fn terminate_cmmn_case_instance(configuration: &configuration::Configuration, workspace: &str, id: &str) -> Result<String, Error<TerminateCmmnCaseInstanceError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
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));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<TerminateCmmnCaseInstanceError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// 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.
pub 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>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
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));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_str) = instance {
local_var_req_builder = local_var_req_builder.query(&[("instance", &local_var_str.to_string())]);
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<TriggerCmmnPlanItemError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
pub async fn update_cmmn_case(configuration: &configuration::Configuration, workspace: &str, path: &str, new_cmmn_case_model: models::NewCmmnCaseModel) -> Result<models::CmmnDeployResult, Error<UpdateCmmnCaseError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
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));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&new_cmmn_case_model);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<UpdateCmmnCaseError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}