Skip to main content

orvanta_api/apis/
bpmn_instance_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: 3.2.0
7 * Contact: contact@orvanta.cloud
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration};
16
17
18/// struct for typed errors of method [`bulk_migrate_bpmn_instances`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum BulkMigrateBpmnInstancesError {
22    Status400(models::BpmnMigrationRefusal),
23    Status402(String),
24    UnknownValue(serde_json::Value),
25}
26
27/// struct for typed errors of method [`cancel_bpmn_instance`]
28#[derive(Debug, Clone, Serialize, Deserialize)]
29#[serde(untagged)]
30pub enum CancelBpmnInstanceError {
31    Status402(String),
32    UnknownValue(serde_json::Value),
33}
34
35/// struct for typed errors of method [`check_bpmn_instance_migration`]
36#[derive(Debug, Clone, Serialize, Deserialize)]
37#[serde(untagged)]
38pub enum CheckBpmnInstanceMigrationError {
39    Status402(String),
40    UnknownValue(serde_json::Value),
41}
42
43/// struct for typed errors of method [`check_bpmn_version_pair`]
44#[derive(Debug, Clone, Serialize, Deserialize)]
45#[serde(untagged)]
46pub enum CheckBpmnVersionPairError {
47    Status402(String),
48    UnknownValue(serde_json::Value),
49}
50
51/// struct for typed errors of method [`complete_bpmn_user_task`]
52#[derive(Debug, Clone, Serialize, Deserialize)]
53#[serde(untagged)]
54pub enum CompleteBpmnUserTaskError {
55    Status401(String),
56    Status402(String),
57    UnknownValue(serde_json::Value),
58}
59
60/// struct for typed errors of method [`get_bpmn_flow_version_rollup`]
61#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum GetBpmnFlowVersionRollupError {
64    Status402(String),
65    UnknownValue(serde_json::Value),
66}
67
68/// struct for typed errors of method [`get_bpmn_instance`]
69#[derive(Debug, Clone, Serialize, Deserialize)]
70#[serde(untagged)]
71pub enum GetBpmnInstanceError {
72    Status402(String),
73    UnknownValue(serde_json::Value),
74}
75
76/// struct for typed errors of method [`get_bpmn_instance_status`]
77#[derive(Debug, Clone, Serialize, Deserialize)]
78#[serde(untagged)]
79pub enum GetBpmnInstanceStatusError {
80    Status402(String),
81    UnknownValue(serde_json::Value),
82}
83
84/// struct for typed errors of method [`get_bpmn_version_rollup`]
85#[derive(Debug, Clone, Serialize, Deserialize)]
86#[serde(untagged)]
87pub enum GetBpmnVersionRollupError {
88    Status402(String),
89    UnknownValue(serde_json::Value),
90}
91
92/// struct for typed errors of method [`list_bpmn_incidents`]
93#[derive(Debug, Clone, Serialize, Deserialize)]
94#[serde(untagged)]
95pub enum ListBpmnIncidentsError {
96    Status402(String),
97    UnknownValue(serde_json::Value),
98}
99
100/// struct for typed errors of method [`list_bpmn_instances`]
101#[derive(Debug, Clone, Serialize, Deserialize)]
102#[serde(untagged)]
103pub enum ListBpmnInstancesError {
104    Status402(String),
105    UnknownValue(serde_json::Value),
106}
107
108/// struct for typed errors of method [`list_pending_bpmn_user_tasks`]
109#[derive(Debug, Clone, Serialize, Deserialize)]
110#[serde(untagged)]
111pub enum ListPendingBpmnUserTasksError {
112    Status402(String),
113    UnknownValue(serde_json::Value),
114}
115
116/// struct for typed errors of method [`migrate_bpmn_instance`]
117#[derive(Debug, Clone, Serialize, Deserialize)]
118#[serde(untagged)]
119pub enum MigrateBpmnInstanceError {
120    Status400(models::BpmnMigrationRefusal),
121    Status402(String),
122    UnknownValue(serde_json::Value),
123}
124
125/// struct for typed errors of method [`plan_bpmn_instance_migration`]
126#[derive(Debug, Clone, Serialize, Deserialize)]
127#[serde(untagged)]
128pub enum PlanBpmnInstanceMigrationError {
129    Status402(String),
130    UnknownValue(serde_json::Value),
131}
132
133/// struct for typed errors of method [`plan_bpmn_version_pair_migration`]
134#[derive(Debug, Clone, Serialize, Deserialize)]
135#[serde(untagged)]
136pub enum PlanBpmnVersionPairMigrationError {
137    Status402(String),
138    UnknownValue(serde_json::Value),
139}
140
141/// struct for typed errors of method [`preview_bpmn_instance`]
142#[derive(Debug, Clone, Serialize, Deserialize)]
143#[serde(untagged)]
144pub enum PreviewBpmnInstanceError {
145    Status400(models::BpmnValidationProblem),
146    Status402(String),
147    UnknownValue(serde_json::Value),
148}
149
150/// struct for typed errors of method [`retry_bpmn_incident`]
151#[derive(Debug, Clone, Serialize, Deserialize)]
152#[serde(untagged)]
153pub enum RetryBpmnIncidentError {
154    Status402(String),
155    UnknownValue(serde_json::Value),
156}
157
158/// struct for typed errors of method [`start_bpmn_instance`]
159#[derive(Debug, Clone, Serialize, Deserialize)]
160#[serde(untagged)]
161pub enum StartBpmnInstanceError {
162    Status402(String),
163    UnknownValue(serde_json::Value),
164}
165
166
167/// Bulk identity migration (#922). One validation for the whole batch, because eligibility is a property of the version pair, not of an instance. `from_version` is the whole bulk key -- a `bpmn_flow_version` row belongs to exactly one flow -- and both versions are checked to belong to the same flow before anything moves. Matching no running instance is a 200 with an empty `migrated`, not an error.
168pub async fn bulk_migrate_bpmn_instances(configuration: &configuration::Configuration, workspace: &str, bulk_migrate_bpmn_instances_request: models::BulkMigrateBpmnInstancesRequest) -> Result<models::BpmnMigrationResult, Error<BulkMigrateBpmnInstancesError>> {
169    let local_var_configuration = configuration;
170
171    let local_var_client = &local_var_configuration.client;
172
173    let local_var_uri_str = format!("{}/w/{workspace}/bpmn/instances/migrate", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
174    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
175
176    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
177        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
178    }
179    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
180        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
181    };
182    local_var_req_builder = local_var_req_builder.json(&bulk_migrate_bpmn_instances_request);
183
184    let local_var_req = local_var_req_builder.build()?;
185    let local_var_resp = local_var_client.execute(local_var_req).await?;
186
187    let local_var_status = local_var_resp.status();
188    let local_var_content = local_var_resp.text().await?;
189
190    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
191        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
192    } else {
193        let local_var_entity: Option<BulkMigrateBpmnInstancesError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
194        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
195        Err(Error::ResponseError(local_var_error))
196    }
197}
198
199pub async fn cancel_bpmn_instance(configuration: &configuration::Configuration, workspace: &str, id: &str, cancel_bpmn_instance: models::CancelBpmnInstance) -> Result<String, Error<CancelBpmnInstanceError>> {
200    let local_var_configuration = configuration;
201
202    let local_var_client = &local_var_configuration.client;
203
204    let local_var_uri_str = format!("{}/w/{workspace}/bpmn/instances/cancel/{id}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), id=crate::apis::urlencode(id));
205    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
206
207    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
208        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
209    }
210    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
211        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
212    };
213    local_var_req_builder = local_var_req_builder.json(&cancel_bpmn_instance);
214
215    let local_var_req = local_var_req_builder.build()?;
216    let local_var_resp = local_var_client.execute(local_var_req).await?;
217
218    let local_var_status = local_var_resp.status();
219    let local_var_content = local_var_resp.text().await?;
220
221    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
222        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
223    } else {
224        let local_var_entity: Option<CancelBpmnInstanceError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
225        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
226        Err(Error::ResponseError(local_var_error))
227    }
228}
229
230/// The same per-pair verdict as checkBpmnVersionPair, but resolving this instance's own current pin and its runtime preconditions (it must not be an inline preview run, and it must still be running).
231pub async fn check_bpmn_instance_migration(configuration: &configuration::Configuration, workspace: &str, id: &str, target_version: i64) -> Result<models::BpmnMigrationCheck, Error<CheckBpmnInstanceMigrationError>> {
232    let local_var_configuration = configuration;
233
234    let local_var_client = &local_var_configuration.client;
235
236    let local_var_uri_str = format!("{}/w/{workspace}/bpmn/instances/{id}/migration/check", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), id=crate::apis::urlencode(id));
237    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
238
239    local_var_req_builder = local_var_req_builder.query(&[("target_version", &target_version.to_string())]);
240    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
241        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
242    }
243    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
244        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
245    };
246
247    let local_var_req = local_var_req_builder.build()?;
248    let local_var_resp = local_var_client.execute(local_var_req).await?;
249
250    let local_var_status = local_var_resp.status();
251    let local_var_content = local_var_resp.text().await?;
252
253    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
254        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
255    } else {
256        let local_var_entity: Option<CheckBpmnInstanceMigrationError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
257        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
258        Err(Error::ResponseError(local_var_error))
259    }
260}
261
262/// Runs the identity-migration contract (#922) over two compiled definitions of the same flow and reports every blocker, grouped by rule. Reads no runtime state at all, so the verdict is a property of the (from_version, to_version) *pair* and applies to every instance pinned to from_version -- which is what makes it answerable with no instance and cacheable per version.
263pub async fn check_bpmn_version_pair(configuration: &configuration::Configuration, workspace: &str, path: &str, from_version: i64, to_version: i64) -> Result<models::BpmnMigrationCheck, Error<CheckBpmnVersionPairError>> {
264    let local_var_configuration = configuration;
265
266    let local_var_client = &local_var_configuration.client;
267
268    let local_var_uri_str = format!("{}/w/{workspace}/bpmn/migration/check/p/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
269    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
270
271    local_var_req_builder = local_var_req_builder.query(&[("from_version", &from_version.to_string())]);
272    local_var_req_builder = local_var_req_builder.query(&[("to_version", &to_version.to_string())]);
273    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
274        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
275    }
276    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
277        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
278    };
279
280    let local_var_req = local_var_req_builder.build()?;
281    let local_var_resp = local_var_client.execute(local_var_req).await?;
282
283    let local_var_status = local_var_resp.status();
284    let local_var_content = local_var_resp.text().await?;
285
286    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
287        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
288    } else {
289        let local_var_entity: Option<CheckBpmnVersionPairError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
290        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
291        Err(Error::ResponseError(local_var_error))
292    }
293}
294
295/// Deliver a user task's form data and unpark the instance. The body is the completion payload; when the task declares form fields it is validated against them server-side (required fields, declared defaults, enum values -- see #833), unless the model sets `flowable:formFieldValidation=\"false\"`.  Since #1104 the caller must be in the task's declared audience. This was previously unenforced: anyone who could see an instance could complete any of its user tasks, including one assigned to somebody else. 
296pub async fn complete_bpmn_user_task(configuration: &configuration::Configuration, workspace: &str, id: &str, user_task_id: &str, request_body: std::collections::HashMap<String, serde_json::Value>) -> Result<String, Error<CompleteBpmnUserTaskError>> {
297    let local_var_configuration = configuration;
298
299    let local_var_client = &local_var_configuration.client;
300
301    let local_var_uri_str = format!("{}/w/{workspace}/bpmn/instances/{id}/user-tasks/{user_task_id}/complete", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), id=crate::apis::urlencode(id), user_task_id=crate::apis::urlencode(user_task_id));
302    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
303
304    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
305        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
306    }
307    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
308        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
309    };
310    local_var_req_builder = local_var_req_builder.json(&request_body);
311
312    let local_var_req = local_var_req_builder.build()?;
313    let local_var_resp = local_var_client.execute(local_var_req).await?;
314
315    let local_var_status = local_var_resp.status();
316    let local_var_content = local_var_resp.text().await?;
317
318    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
319        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
320    } else {
321        let local_var_entity: Option<CompleteBpmnUserTaskError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
322        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
323        Err(Error::ResponseError(local_var_error))
324    }
325}
326
327/// #919, narrowed to a single flow. Identical shape to the workspace rollup. A flow that exists but has nothing running answers with an empty `flows` list, not a 404.
328pub async fn get_bpmn_flow_version_rollup(configuration: &configuration::Configuration, workspace: &str, path: &str, check: Option<bool>) -> Result<models::BpmnVersionRollup, Error<GetBpmnFlowVersionRollupError>> {
329    let local_var_configuration = configuration;
330
331    let local_var_client = &local_var_configuration.client;
332
333    let local_var_uri_str = format!("{}/w/{workspace}/bpmn/instances/version_rollup/p/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
334    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
335
336    if let Some(ref local_var_str) = check {
337        local_var_req_builder = local_var_req_builder.query(&[("check", &local_var_str.to_string())]);
338    }
339    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
340        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
341    }
342    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
343        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
344    };
345
346    let local_var_req = local_var_req_builder.build()?;
347    let local_var_resp = local_var_client.execute(local_var_req).await?;
348
349    let local_var_status = local_var_resp.status();
350    let local_var_content = local_var_resp.text().await?;
351
352    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
353        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
354    } else {
355        let local_var_entity: Option<GetBpmnFlowVersionRollupError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
356        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
357        Err(Error::ResponseError(local_var_error))
358    }
359}
360
361pub async fn get_bpmn_instance(configuration: &configuration::Configuration, workspace: &str, id: &str) -> Result<models::BpmnInstanceDetail, Error<GetBpmnInstanceError>> {
362    let local_var_configuration = configuration;
363
364    let local_var_client = &local_var_configuration.client;
365
366    let local_var_uri_str = format!("{}/w/{workspace}/bpmn/instances/get/{id}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), id=crate::apis::urlencode(id));
367    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
368
369    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
370        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
371    }
372    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
373        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
374    };
375
376    let local_var_req = local_var_req_builder.build()?;
377    let local_var_resp = local_var_client.execute(local_var_req).await?;
378
379    let local_var_status = local_var_resp.status();
380    let local_var_content = local_var_resp.text().await?;
381
382    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
383        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
384    } else {
385        let local_var_entity: Option<GetBpmnInstanceError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
386        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
387        Err(Error::ResponseError(local_var_error))
388    }
389}
390
391/// Frontend-facing projection of the process instance's live runtime state (lifecycle, per-activity status, variables, history, incidents), consumed by the live process token overlay. 404 if the instance isn't in the workspace, or if the engine has not picked it up yet (no runtime state).
392pub async fn get_bpmn_instance_status(configuration: &configuration::Configuration, workspace: &str, id: &str) -> Result<models::ProcessInstanceStatus, Error<GetBpmnInstanceStatusError>> {
393    let local_var_configuration = configuration;
394
395    let local_var_client = &local_var_configuration.client;
396
397    let local_var_uri_str = format!("{}/w/{workspace}/bpmn/instances/get/{id}/status", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), id=crate::apis::urlencode(id));
398    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
399
400    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
401        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
402    }
403    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
404        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
405    };
406
407    let local_var_req = local_var_req_builder.build()?;
408    let local_var_resp = local_var_client.execute(local_var_req).await?;
409
410    let local_var_status = local_var_resp.status();
411    let local_var_content = local_var_resp.text().await?;
412
413    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
414        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
415    } else {
416        let local_var_entity: Option<GetBpmnInstanceStatusError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
417        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
418        Err(Error::ResponseError(local_var_error))
419    }
420}
421
422/// #919. Answers \"which of my running instances are on an old definition?\" for the whole workspace, and per pinned version whether it is migratable to that flow's latest and if not why (#922's validator, computed once per version because eligibility is a property of the (version, latest) pair rather than of an instance). Read-only.  An instance is pinned at start to one `bpmn_flow_version` (`v2_job.runnable_id`) and resolves its model from that row on every step, so instances complete on the version they started on while new starts use the latest. `runnable_id` is the source here, never the denormalised `bpmn_process_status.bpmn_version`, which the engine writes on insert and never refreshes.  \"Running\" means a root instance still queued and uncancelled -- the same set a bulk migrate would move. Inline preview runs are excluded: they carry their model on the job row and are on no version.
423pub async fn get_bpmn_version_rollup(configuration: &configuration::Configuration, workspace: &str, check: Option<bool>) -> Result<models::BpmnVersionRollup, Error<GetBpmnVersionRollupError>> {
424    let local_var_configuration = configuration;
425
426    let local_var_client = &local_var_configuration.client;
427
428    let local_var_uri_str = format!("{}/w/{workspace}/bpmn/instances/version_rollup", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
429    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
430
431    if let Some(ref local_var_str) = check {
432        local_var_req_builder = local_var_req_builder.query(&[("check", &local_var_str.to_string())]);
433    }
434    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
435        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
436    }
437    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
438        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
439    };
440
441    let local_var_req = local_var_req_builder.build()?;
442    let local_var_resp = local_var_client.execute(local_var_req).await?;
443
444    let local_var_status = local_var_resp.status();
445    let local_var_content = local_var_resp.text().await?;
446
447    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
448        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
449    } else {
450        let local_var_entity: Option<GetBpmnVersionRollupError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
451        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
452        Err(Error::ResponseError(local_var_error))
453    }
454}
455
456pub async fn list_bpmn_incidents(configuration: &configuration::Configuration, workspace: &str, id: &str) -> Result<Vec<models::BpmnIncident>, Error<ListBpmnIncidentsError>> {
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}/bpmn/instances/{id}/incidents", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), id=crate::apis::urlencode(id));
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<ListBpmnIncidentsError> = 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
486pub async fn list_bpmn_instances(configuration: &configuration::Configuration, workspace: &str, page: Option<i32>, per_page: Option<i32>) -> Result<Vec<models::BpmnInstanceSummary>, Error<ListBpmnInstancesError>> {
487    let local_var_configuration = configuration;
488
489    let local_var_client = &local_var_configuration.client;
490
491    let local_var_uri_str = format!("{}/w/{workspace}/bpmn/instances/list", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
492    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
493
494    if let Some(ref local_var_str) = page {
495        local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
496    }
497    if let Some(ref local_var_str) = per_page {
498        local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
499    }
500    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
501        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
502    }
503    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
504        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
505    };
506
507    let local_var_req = local_var_req_builder.build()?;
508    let local_var_resp = local_var_client.execute(local_var_req).await?;
509
510    let local_var_status = local_var_resp.status();
511    let local_var_content = local_var_resp.text().await?;
512
513    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
514        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
515    } else {
516        let local_var_entity: Option<ListBpmnInstancesError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
517        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
518        Err(Error::ResponseError(local_var_error))
519    }
520}
521
522/// Every `<userTask>` in the workspace that is parked awaiting a human and that the caller may act on (#1104). This is the read side the completion operation below always presumed: that operation is addressed by `(instance id, element id)`, which a human has no way to discover otherwise.  Filtering is **server-side and is the same rule the completion operation enforces**. A task is returned when the caller is an admin, when the task declares no assignment it can resolve, or when the caller matches a declared literal `assignee`/`owner`/`candidateUsers` entry or one of the `candidateGroups`. Assignment written as an expression (`${approver}`) cannot be resolved on this path -- there is no runtime identity resolution in the engine -- and is reported via `assignment_unresolved` rather than guessed at.  Pagination applies to process *instances*, not to tasks: one instance can hold several parked tasks on parallel branches. 
523pub async fn list_pending_bpmn_user_tasks(configuration: &configuration::Configuration, workspace: &str, page: Option<i32>, per_page: Option<i32>) -> Result<Vec<models::PendingUserTask>, Error<ListPendingBpmnUserTasksError>> {
524    let local_var_configuration = configuration;
525
526    let local_var_client = &local_var_configuration.client;
527
528    let local_var_uri_str = format!("{}/w/{workspace}/bpmn/user-tasks/list", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
529    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
530
531    if let Some(ref local_var_str) = page {
532        local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
533    }
534    if let Some(ref local_var_str) = per_page {
535        local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
536    }
537    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
538        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
539    }
540    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
541        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
542    };
543
544    let local_var_req = local_var_req_builder.build()?;
545    let local_var_resp = local_var_client.execute(local_var_req).await?;
546
547    let local_var_status = local_var_resp.status();
548    let local_var_content = local_var_resp.text().await?;
549
550    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
551        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
552    } else {
553        let local_var_entity: Option<ListPendingBpmnUserTasksError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
554        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
555        Err(Error::ResponseError(local_var_error))
556    }
557}
558
559/// Validated pointer swap (#922). Validates the (current, target) pair against the identity-migration contract and, only if it passes, moves `v2_job.runnable_id` to the target version, refreshes the denormalised `bpmn_process_status.bpmn_version` (which no engine writer ever refreshes) and appends a `bpmn_instance_migration` ledger row -- all in one transaction. `process_status` is never written and `suspend_until` is never nudged; the instance runs on the target version from its next step, because the engine re-resolves the pinned definition on every step. A pair that fails the contract is refused with a 400 naming every offending identifier -- it is never migrated and flagged.
560pub async fn migrate_bpmn_instance(configuration: &configuration::Configuration, workspace: &str, id: &str, migrate_bpmn_instance_request: models::MigrateBpmnInstanceRequest) -> Result<models::BpmnMigrationResult, Error<MigrateBpmnInstanceError>> {
561    let local_var_configuration = configuration;
562
563    let local_var_client = &local_var_configuration.client;
564
565    let local_var_uri_str = format!("{}/w/{workspace}/bpmn/instances/{id}/migrate", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), id=crate::apis::urlencode(id));
566    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
567
568    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
569        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
570    }
571    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
572        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
573    };
574    local_var_req_builder = local_var_req_builder.json(&migrate_bpmn_instance_request);
575
576    let local_var_req = local_var_req_builder.build()?;
577    let local_var_resp = local_var_client.execute(local_var_req).await?;
578
579    let local_var_status = local_var_resp.status();
580    let local_var_content = local_var_resp.text().await?;
581
582    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
583        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
584    } else {
585        let local_var_entity: Option<MigrateBpmnInstanceError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
586        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
587        Err(Error::ResponseError(local_var_error))
588    }
589}
590
591/// The same resolution as planBpmnVersionPairMigration, but resolving this instance's own current pin and its runtime preconditions (it must not be an inline preview run, and it must still be running). Writes nothing.
592pub async fn plan_bpmn_instance_migration(configuration: &configuration::Configuration, workspace: &str, id: &str, plan_bpmn_instance_migration_request: models::PlanBpmnInstanceMigrationRequest) -> Result<models::BpmnMigrationPlanCheck, Error<PlanBpmnInstanceMigrationError>> {
593    let local_var_configuration = configuration;
594
595    let local_var_client = &local_var_configuration.client;
596
597    let local_var_uri_str = format!("{}/w/{workspace}/bpmn/instances/{id}/migration/plan", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), id=crate::apis::urlencode(id));
598    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
599
600    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
601        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
602    }
603    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
604        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
605    };
606    local_var_req_builder = local_var_req_builder.json(&plan_bpmn_instance_migration_request);
607
608    let local_var_req = local_var_req_builder.build()?;
609    let local_var_resp = local_var_client.execute(local_var_req).await?;
610
611    let local_var_status = local_var_resp.status();
612    let local_var_content = local_var_resp.text().await?;
613
614    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
615        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
616    } else {
617        let local_var_entity: Option<PlanBpmnInstanceMigrationError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
618        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
619        Err(Error::ResponseError(local_var_error))
620    }
621}
622
623/// Runs the *mapped* migration contract (#925, stage 4) over two compiled definitions of the same flow and, if the document holds, returns the resolved substitution as a plan. `POST` because the mapping is a document rather than a query parameter -- the call reads two definitions and **writes nothing**. Where the identity contract (checkBpmnVersionPair) asks \"may this instance run on the target unchanged\", this asks the strictly larger \"may it run on the target after renaming the identifiers this document names\". It admits renames -- of elements, of sequence flows (derived from their endpoints, never declared) and of the process id -- and refuses every topological change: a deleted activity with no replacement, an N:1 merge, a cross-scope move, a changed set of incoming flows, a re-attached boundary event. An element the document does not name is implicitly mapped to its own id, and is then subject to every rule an explicit mapping is. An element that is neither named nor present in the target is a hard refusal (`activity_deleted`), never a silently dropped token. Note `executable_today`: the engine-side rewrite that applies a plan is not built, so only an identity plan can currently be performed (by migrateBpmnInstance). A non-identity plan is a validated statement of what would be rewritten, not a promise that it can be.
624pub async fn plan_bpmn_version_pair_migration(configuration: &configuration::Configuration, workspace: &str, path: &str, plan_bpmn_version_pair_migration_request: models::PlanBpmnVersionPairMigrationRequest) -> Result<models::BpmnMigrationPlanCheck, Error<PlanBpmnVersionPairMigrationError>> {
625    let local_var_configuration = configuration;
626
627    let local_var_client = &local_var_configuration.client;
628
629    let local_var_uri_str = format!("{}/w/{workspace}/bpmn/migration/plan/p/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
630    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
631
632    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
633        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
634    }
635    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
636        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
637    };
638    local_var_req_builder = local_var_req_builder.json(&plan_bpmn_version_pair_migration_request);
639
640    let local_var_req = local_var_req_builder.build()?;
641    let local_var_resp = local_var_client.execute(local_var_req).await?;
642
643    let local_var_status = local_var_resp.status();
644    let local_var_content = local_var_resp.text().await?;
645
646    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
647        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
648    } else {
649        let local_var_entity: Option<PlanBpmnVersionPairMigrationError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
650        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
651        Err(Error::ResponseError(local_var_error))
652    }
653}
654
655/// Start a process instance from an undeployed diagram (#710 stage 3), the \"run without deploying\" counterpart to `POST /bpmn/run/p/{path}`. The submitted XML is parsed and validated exactly as a real deploy would -- nothing is written to `bpmn_flow`/`bpmn_flow_version`.
656pub async fn preview_bpmn_instance(configuration: &configuration::Configuration, workspace: &str, preview_bpmn_instance: models::PreviewBpmnInstance) -> Result<String, Error<PreviewBpmnInstanceError>> {
657    let local_var_configuration = configuration;
658
659    let local_var_client = &local_var_configuration.client;
660
661    let local_var_uri_str = format!("{}/w/{workspace}/bpmn/run/preview", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
662    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
663
664    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
665        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
666    }
667    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
668        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
669    };
670    local_var_req_builder = local_var_req_builder.json(&preview_bpmn_instance);
671
672    let local_var_req = local_var_req_builder.build()?;
673    let local_var_resp = local_var_client.execute(local_var_req).await?;
674
675    let local_var_status = local_var_resp.status();
676    let local_var_content = local_var_resp.text().await?;
677
678    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
679        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
680    } else {
681        let local_var_entity: Option<PreviewBpmnInstanceError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
682        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
683        Err(Error::ResponseError(local_var_error))
684    }
685}
686
687/// Validates the ActivityFailed incident, identified by the original failed child job's id, and records a retry intent on the process instance. The execution engine does not yet act on this intent: retrying an incident is not yet functional end-to-end. This endpoint only validates ownership of the incident and records the intent for a future engine version to consume.
688pub async fn retry_bpmn_incident(configuration: &configuration::Configuration, workspace: &str, id: &str, job_id: &str) -> Result<String, Error<RetryBpmnIncidentError>> {
689    let local_var_configuration = configuration;
690
691    let local_var_client = &local_var_configuration.client;
692
693    let local_var_uri_str = format!("{}/w/{workspace}/bpmn/instances/{id}/incidents/{job_id}/retry", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), id=crate::apis::urlencode(id), job_id=crate::apis::urlencode(job_id));
694    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
695
696    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
697        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
698    }
699    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
700        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
701    };
702
703    let local_var_req = local_var_req_builder.build()?;
704    let local_var_resp = local_var_client.execute(local_var_req).await?;
705
706    let local_var_status = local_var_resp.status();
707    let local_var_content = local_var_resp.text().await?;
708
709    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
710        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
711    } else {
712        let local_var_entity: Option<RetryBpmnIncidentError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
713        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
714        Err(Error::ResponseError(local_var_error))
715    }
716}
717
718pub async fn start_bpmn_instance(configuration: &configuration::Configuration, workspace: &str, path: &str, start_bpmn_instance: models::StartBpmnInstance) -> Result<String, Error<StartBpmnInstanceError>> {
719    let local_var_configuration = configuration;
720
721    let local_var_client = &local_var_configuration.client;
722
723    let local_var_uri_str = format!("{}/w/{workspace}/bpmn/run/p/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
724    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
725
726    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
727        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
728    }
729    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
730        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
731    };
732    local_var_req_builder = local_var_req_builder.json(&start_bpmn_instance);
733
734    let local_var_req = local_var_req_builder.build()?;
735    let local_var_resp = local_var_client.execute(local_var_req).await?;
736
737    let local_var_status = local_var_resp.status();
738    let local_var_content = local_var_resp.text().await?;
739
740    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
741        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
742    } else {
743        let local_var_entity: Option<StartBpmnInstanceError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
744        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
745        Err(Error::ResponseError(local_var_error))
746    }
747}
748