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.0.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 [`get_bpmn_flow_version_rollup`]
52#[derive(Debug, Clone, Serialize, Deserialize)]
53#[serde(untagged)]
54pub enum GetBpmnFlowVersionRollupError {
55    Status402(String),
56    UnknownValue(serde_json::Value),
57}
58
59/// struct for typed errors of method [`get_bpmn_instance`]
60#[derive(Debug, Clone, Serialize, Deserialize)]
61#[serde(untagged)]
62pub enum GetBpmnInstanceError {
63    Status402(String),
64    UnknownValue(serde_json::Value),
65}
66
67/// struct for typed errors of method [`get_bpmn_instance_status`]
68#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum GetBpmnInstanceStatusError {
71    Status402(String),
72    UnknownValue(serde_json::Value),
73}
74
75/// struct for typed errors of method [`get_bpmn_version_rollup`]
76#[derive(Debug, Clone, Serialize, Deserialize)]
77#[serde(untagged)]
78pub enum GetBpmnVersionRollupError {
79    Status402(String),
80    UnknownValue(serde_json::Value),
81}
82
83/// struct for typed errors of method [`list_bpmn_incidents`]
84#[derive(Debug, Clone, Serialize, Deserialize)]
85#[serde(untagged)]
86pub enum ListBpmnIncidentsError {
87    Status402(String),
88    UnknownValue(serde_json::Value),
89}
90
91/// struct for typed errors of method [`list_bpmn_instances`]
92#[derive(Debug, Clone, Serialize, Deserialize)]
93#[serde(untagged)]
94pub enum ListBpmnInstancesError {
95    Status402(String),
96    UnknownValue(serde_json::Value),
97}
98
99/// struct for typed errors of method [`migrate_bpmn_instance`]
100#[derive(Debug, Clone, Serialize, Deserialize)]
101#[serde(untagged)]
102pub enum MigrateBpmnInstanceError {
103    Status400(models::BpmnMigrationRefusal),
104    Status402(String),
105    UnknownValue(serde_json::Value),
106}
107
108/// struct for typed errors of method [`preview_bpmn_instance`]
109#[derive(Debug, Clone, Serialize, Deserialize)]
110#[serde(untagged)]
111pub enum PreviewBpmnInstanceError {
112    Status400(models::BpmnValidationProblem),
113    Status402(String),
114    UnknownValue(serde_json::Value),
115}
116
117/// struct for typed errors of method [`retry_bpmn_incident`]
118#[derive(Debug, Clone, Serialize, Deserialize)]
119#[serde(untagged)]
120pub enum RetryBpmnIncidentError {
121    Status402(String),
122    UnknownValue(serde_json::Value),
123}
124
125/// struct for typed errors of method [`start_bpmn_instance`]
126#[derive(Debug, Clone, Serialize, Deserialize)]
127#[serde(untagged)]
128pub enum StartBpmnInstanceError {
129    Status402(String),
130    UnknownValue(serde_json::Value),
131}
132
133
134/// 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.
135pub async fn bulk_migrate_bpmn_instances(configuration: &configuration::Configuration, workspace: &str, bulk_migrate_bpmn_instances_request: models::BulkMigrateBpmnInstancesRequest) -> Result<models::BpmnMigrationResult, Error<BulkMigrateBpmnInstancesError>> {
136    let local_var_configuration = configuration;
137
138    let local_var_client = &local_var_configuration.client;
139
140    let local_var_uri_str = format!("{}/w/{workspace}/bpmn/instances/migrate", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
141    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
142
143    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
144        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
145    }
146    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
147        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
148    };
149    local_var_req_builder = local_var_req_builder.json(&bulk_migrate_bpmn_instances_request);
150
151    let local_var_req = local_var_req_builder.build()?;
152    let local_var_resp = local_var_client.execute(local_var_req).await?;
153
154    let local_var_status = local_var_resp.status();
155    let local_var_content = local_var_resp.text().await?;
156
157    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
158        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
159    } else {
160        let local_var_entity: Option<BulkMigrateBpmnInstancesError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
161        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
162        Err(Error::ResponseError(local_var_error))
163    }
164}
165
166pub async fn cancel_bpmn_instance(configuration: &configuration::Configuration, workspace: &str, id: &str, cancel_bpmn_instance: models::CancelBpmnInstance) -> Result<String, Error<CancelBpmnInstanceError>> {
167    let local_var_configuration = configuration;
168
169    let local_var_client = &local_var_configuration.client;
170
171    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));
172    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
173
174    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
175        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
176    }
177    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
178        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
179    };
180    local_var_req_builder = local_var_req_builder.json(&cancel_bpmn_instance);
181
182    let local_var_req = local_var_req_builder.build()?;
183    let local_var_resp = local_var_client.execute(local_var_req).await?;
184
185    let local_var_status = local_var_resp.status();
186    let local_var_content = local_var_resp.text().await?;
187
188    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
189        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
190    } else {
191        let local_var_entity: Option<CancelBpmnInstanceError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
192        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
193        Err(Error::ResponseError(local_var_error))
194    }
195}
196
197/// 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).
198pub async fn check_bpmn_instance_migration(configuration: &configuration::Configuration, workspace: &str, id: &str, target_version: i64) -> Result<models::BpmnMigrationCheck, Error<CheckBpmnInstanceMigrationError>> {
199    let local_var_configuration = configuration;
200
201    let local_var_client = &local_var_configuration.client;
202
203    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));
204    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
205
206    local_var_req_builder = local_var_req_builder.query(&[("target_version", &target_version.to_string())]);
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
214    let local_var_req = local_var_req_builder.build()?;
215    let local_var_resp = local_var_client.execute(local_var_req).await?;
216
217    let local_var_status = local_var_resp.status();
218    let local_var_content = local_var_resp.text().await?;
219
220    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
221        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
222    } else {
223        let local_var_entity: Option<CheckBpmnInstanceMigrationError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
224        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
225        Err(Error::ResponseError(local_var_error))
226    }
227}
228
229/// 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.
230pub async fn check_bpmn_version_pair(configuration: &configuration::Configuration, workspace: &str, path: &str, from_version: i64, to_version: i64) -> Result<models::BpmnMigrationCheck, Error<CheckBpmnVersionPairError>> {
231    let local_var_configuration = configuration;
232
233    let local_var_client = &local_var_configuration.client;
234
235    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));
236    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
237
238    local_var_req_builder = local_var_req_builder.query(&[("from_version", &from_version.to_string())]);
239    local_var_req_builder = local_var_req_builder.query(&[("to_version", &to_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<CheckBpmnVersionPairError> = 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/// #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.
263pub async fn get_bpmn_flow_version_rollup(configuration: &configuration::Configuration, workspace: &str, path: &str, check: Option<bool>) -> Result<models::BpmnVersionRollup, Error<GetBpmnFlowVersionRollupError>> {
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/instances/version_rollup/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    if let Some(ref local_var_str) = check {
272        local_var_req_builder = local_var_req_builder.query(&[("check", &local_var_str.to_string())]);
273    }
274    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
275        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
276    }
277    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
278        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
279    };
280
281    let local_var_req = local_var_req_builder.build()?;
282    let local_var_resp = local_var_client.execute(local_var_req).await?;
283
284    let local_var_status = local_var_resp.status();
285    let local_var_content = local_var_resp.text().await?;
286
287    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
288        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
289    } else {
290        let local_var_entity: Option<GetBpmnFlowVersionRollupError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
291        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
292        Err(Error::ResponseError(local_var_error))
293    }
294}
295
296pub async fn get_bpmn_instance(configuration: &configuration::Configuration, workspace: &str, id: &str) -> Result<models::BpmnInstanceDetail, Error<GetBpmnInstanceError>> {
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/get/{id}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), id=crate::apis::urlencode(id));
302    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, 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
311    let local_var_req = local_var_req_builder.build()?;
312    let local_var_resp = local_var_client.execute(local_var_req).await?;
313
314    let local_var_status = local_var_resp.status();
315    let local_var_content = local_var_resp.text().await?;
316
317    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
318        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
319    } else {
320        let local_var_entity: Option<GetBpmnInstanceError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
321        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
322        Err(Error::ResponseError(local_var_error))
323    }
324}
325
326/// 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).
327pub async fn get_bpmn_instance_status(configuration: &configuration::Configuration, workspace: &str, id: &str) -> Result<models::ProcessInstanceStatus, Error<GetBpmnInstanceStatusError>> {
328    let local_var_configuration = configuration;
329
330    let local_var_client = &local_var_configuration.client;
331
332    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));
333    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
334
335    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
336        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
337    }
338    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
339        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
340    };
341
342    let local_var_req = local_var_req_builder.build()?;
343    let local_var_resp = local_var_client.execute(local_var_req).await?;
344
345    let local_var_status = local_var_resp.status();
346    let local_var_content = local_var_resp.text().await?;
347
348    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
349        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
350    } else {
351        let local_var_entity: Option<GetBpmnInstanceStatusError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
352        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
353        Err(Error::ResponseError(local_var_error))
354    }
355}
356
357/// #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.
358pub async fn get_bpmn_version_rollup(configuration: &configuration::Configuration, workspace: &str, check: Option<bool>) -> Result<models::BpmnVersionRollup, Error<GetBpmnVersionRollupError>> {
359    let local_var_configuration = configuration;
360
361    let local_var_client = &local_var_configuration.client;
362
363    let local_var_uri_str = format!("{}/w/{workspace}/bpmn/instances/version_rollup", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
364    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
365
366    if let Some(ref local_var_str) = check {
367        local_var_req_builder = local_var_req_builder.query(&[("check", &local_var_str.to_string())]);
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<GetBpmnVersionRollupError> = 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
391pub async fn list_bpmn_incidents(configuration: &configuration::Configuration, workspace: &str, id: &str) -> Result<Vec<models::BpmnIncident>, Error<ListBpmnIncidentsError>> {
392    let local_var_configuration = configuration;
393
394    let local_var_client = &local_var_configuration.client;
395
396    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));
397    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
398
399    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
400        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
401    }
402    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
403        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
404    };
405
406    let local_var_req = local_var_req_builder.build()?;
407    let local_var_resp = local_var_client.execute(local_var_req).await?;
408
409    let local_var_status = local_var_resp.status();
410    let local_var_content = local_var_resp.text().await?;
411
412    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
413        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
414    } else {
415        let local_var_entity: Option<ListBpmnIncidentsError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
416        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
417        Err(Error::ResponseError(local_var_error))
418    }
419}
420
421pub async fn list_bpmn_instances(configuration: &configuration::Configuration, workspace: &str, page: Option<i32>, per_page: Option<i32>) -> Result<Vec<models::BpmnInstanceSummary>, Error<ListBpmnInstancesError>> {
422    let local_var_configuration = configuration;
423
424    let local_var_client = &local_var_configuration.client;
425
426    let local_var_uri_str = format!("{}/w/{workspace}/bpmn/instances/list", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
427    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
428
429    if let Some(ref local_var_str) = page {
430        local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
431    }
432    if let Some(ref local_var_str) = per_page {
433        local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
434    }
435    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
436        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
437    }
438    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
439        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
440    };
441
442    let local_var_req = local_var_req_builder.build()?;
443    let local_var_resp = local_var_client.execute(local_var_req).await?;
444
445    let local_var_status = local_var_resp.status();
446    let local_var_content = local_var_resp.text().await?;
447
448    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
449        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
450    } else {
451        let local_var_entity: Option<ListBpmnInstancesError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
452        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
453        Err(Error::ResponseError(local_var_error))
454    }
455}
456
457/// 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.
458pub async fn migrate_bpmn_instance(configuration: &configuration::Configuration, workspace: &str, id: &str, migrate_bpmn_instance_request: models::MigrateBpmnInstanceRequest) -> Result<models::BpmnMigrationResult, Error<MigrateBpmnInstanceError>> {
459    let local_var_configuration = configuration;
460
461    let local_var_client = &local_var_configuration.client;
462
463    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));
464    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
465
466    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
467        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
468    }
469    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
470        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
471    };
472    local_var_req_builder = local_var_req_builder.json(&migrate_bpmn_instance_request);
473
474    let local_var_req = local_var_req_builder.build()?;
475    let local_var_resp = local_var_client.execute(local_var_req).await?;
476
477    let local_var_status = local_var_resp.status();
478    let local_var_content = local_var_resp.text().await?;
479
480    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
481        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
482    } else {
483        let local_var_entity: Option<MigrateBpmnInstanceError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
484        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
485        Err(Error::ResponseError(local_var_error))
486    }
487}
488
489/// 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`.
490pub async fn preview_bpmn_instance(configuration: &configuration::Configuration, workspace: &str, preview_bpmn_instance: models::PreviewBpmnInstance) -> Result<String, Error<PreviewBpmnInstanceError>> {
491    let local_var_configuration = configuration;
492
493    let local_var_client = &local_var_configuration.client;
494
495    let local_var_uri_str = format!("{}/w/{workspace}/bpmn/run/preview", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
496    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
497
498    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
499        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
500    }
501    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
502        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
503    };
504    local_var_req_builder = local_var_req_builder.json(&preview_bpmn_instance);
505
506    let local_var_req = local_var_req_builder.build()?;
507    let local_var_resp = local_var_client.execute(local_var_req).await?;
508
509    let local_var_status = local_var_resp.status();
510    let local_var_content = local_var_resp.text().await?;
511
512    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
513        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
514    } else {
515        let local_var_entity: Option<PreviewBpmnInstanceError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
516        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
517        Err(Error::ResponseError(local_var_error))
518    }
519}
520
521/// 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.
522pub async fn retry_bpmn_incident(configuration: &configuration::Configuration, workspace: &str, id: &str, job_id: &str) -> Result<String, Error<RetryBpmnIncidentError>> {
523    let local_var_configuration = configuration;
524
525    let local_var_client = &local_var_configuration.client;
526
527    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));
528    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
529
530    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
531        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
532    }
533    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
534        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
535    };
536
537    let local_var_req = local_var_req_builder.build()?;
538    let local_var_resp = local_var_client.execute(local_var_req).await?;
539
540    let local_var_status = local_var_resp.status();
541    let local_var_content = local_var_resp.text().await?;
542
543    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
544        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
545    } else {
546        let local_var_entity: Option<RetryBpmnIncidentError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
547        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
548        Err(Error::ResponseError(local_var_error))
549    }
550}
551
552pub async fn start_bpmn_instance(configuration: &configuration::Configuration, workspace: &str, path: &str, start_bpmn_instance: models::StartBpmnInstance) -> Result<String, Error<StartBpmnInstanceError>> {
553    let local_var_configuration = configuration;
554
555    let local_var_client = &local_var_configuration.client;
556
557    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));
558    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
559
560    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
561        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
562    }
563    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
564        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
565    };
566    local_var_req_builder = local_var_req_builder.json(&start_bpmn_instance);
567
568    let local_var_req = local_var_req_builder.build()?;
569    let local_var_resp = local_var_client.execute(local_var_req).await?;
570
571    let local_var_status = local_var_resp.status();
572    let local_var_content = local_var_resp.text().await?;
573
574    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
575        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
576    } else {
577        let local_var_entity: Option<StartBpmnInstanceError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
578        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
579        Err(Error::ResponseError(local_var_error))
580    }
581}
582