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: 2.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 [`cancel_bpmn_instance`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum CancelBpmnInstanceError {
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`get_bpmn_instance`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum GetBpmnInstanceError {
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`get_bpmn_instance_status`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum GetBpmnInstanceStatusError {
36    UnknownValue(serde_json::Value),
37}
38
39/// struct for typed errors of method [`list_bpmn_incidents`]
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum ListBpmnIncidentsError {
43    UnknownValue(serde_json::Value),
44}
45
46/// struct for typed errors of method [`list_bpmn_instances`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum ListBpmnInstancesError {
50    UnknownValue(serde_json::Value),
51}
52
53/// struct for typed errors of method [`preview_bpmn_instance`]
54#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum PreviewBpmnInstanceError {
57    Status400(models::BpmnValidationProblem),
58    UnknownValue(serde_json::Value),
59}
60
61/// struct for typed errors of method [`retry_bpmn_incident`]
62#[derive(Debug, Clone, Serialize, Deserialize)]
63#[serde(untagged)]
64pub enum RetryBpmnIncidentError {
65    UnknownValue(serde_json::Value),
66}
67
68/// struct for typed errors of method [`start_bpmn_instance`]
69#[derive(Debug, Clone, Serialize, Deserialize)]
70#[serde(untagged)]
71pub enum StartBpmnInstanceError {
72    UnknownValue(serde_json::Value),
73}
74
75
76pub async fn cancel_bpmn_instance(configuration: &configuration::Configuration, workspace: &str, id: &str, cancel_bpmn_instance: models::CancelBpmnInstance) -> Result<String, Error<CancelBpmnInstanceError>> {
77    let local_var_configuration = configuration;
78
79    let local_var_client = &local_var_configuration.client;
80
81    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));
82    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
83
84    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
85        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
86    }
87    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
88        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
89    };
90    local_var_req_builder = local_var_req_builder.json(&cancel_bpmn_instance);
91
92    let local_var_req = local_var_req_builder.build()?;
93    let local_var_resp = local_var_client.execute(local_var_req).await?;
94
95    let local_var_status = local_var_resp.status();
96    let local_var_content = local_var_resp.text().await?;
97
98    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
99        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
100    } else {
101        let local_var_entity: Option<CancelBpmnInstanceError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
102        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
103        Err(Error::ResponseError(local_var_error))
104    }
105}
106
107pub async fn get_bpmn_instance(configuration: &configuration::Configuration, workspace: &str, id: &str) -> Result<models::BpmnInstanceDetail, Error<GetBpmnInstanceError>> {
108    let local_var_configuration = configuration;
109
110    let local_var_client = &local_var_configuration.client;
111
112    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));
113    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
114
115    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
116        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
117    }
118    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
119        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
120    };
121
122    let local_var_req = local_var_req_builder.build()?;
123    let local_var_resp = local_var_client.execute(local_var_req).await?;
124
125    let local_var_status = local_var_resp.status();
126    let local_var_content = local_var_resp.text().await?;
127
128    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
129        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
130    } else {
131        let local_var_entity: Option<GetBpmnInstanceError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
132        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
133        Err(Error::ResponseError(local_var_error))
134    }
135}
136
137/// 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).
138pub async fn get_bpmn_instance_status(configuration: &configuration::Configuration, workspace: &str, id: &str) -> Result<models::ProcessInstanceStatus, Error<GetBpmnInstanceStatusError>> {
139    let local_var_configuration = configuration;
140
141    let local_var_client = &local_var_configuration.client;
142
143    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));
144    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
145
146    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
147        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
148    }
149    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
150        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
151    };
152
153    let local_var_req = local_var_req_builder.build()?;
154    let local_var_resp = local_var_client.execute(local_var_req).await?;
155
156    let local_var_status = local_var_resp.status();
157    let local_var_content = local_var_resp.text().await?;
158
159    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
160        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
161    } else {
162        let local_var_entity: Option<GetBpmnInstanceStatusError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
163        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
164        Err(Error::ResponseError(local_var_error))
165    }
166}
167
168pub async fn list_bpmn_incidents(configuration: &configuration::Configuration, workspace: &str, id: &str) -> Result<Vec<models::BpmnIncident>, Error<ListBpmnIncidentsError>> {
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/{id}/incidents", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), id=crate::apis::urlencode(id));
174    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, 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
183    let local_var_req = local_var_req_builder.build()?;
184    let local_var_resp = local_var_client.execute(local_var_req).await?;
185
186    let local_var_status = local_var_resp.status();
187    let local_var_content = local_var_resp.text().await?;
188
189    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
190        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
191    } else {
192        let local_var_entity: Option<ListBpmnIncidentsError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
193        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
194        Err(Error::ResponseError(local_var_error))
195    }
196}
197
198pub async fn list_bpmn_instances(configuration: &configuration::Configuration, workspace: &str, page: Option<i32>, per_page: Option<i32>) -> Result<Vec<models::BpmnInstanceSummary>, Error<ListBpmnInstancesError>> {
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/list", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
204    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
205
206    if let Some(ref local_var_str) = page {
207        local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
208    }
209    if let Some(ref local_var_str) = per_page {
210        local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
211    }
212    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
213        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
214    }
215    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
216        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
217    };
218
219    let local_var_req = local_var_req_builder.build()?;
220    let local_var_resp = local_var_client.execute(local_var_req).await?;
221
222    let local_var_status = local_var_resp.status();
223    let local_var_content = local_var_resp.text().await?;
224
225    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
226        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
227    } else {
228        let local_var_entity: Option<ListBpmnInstancesError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
229        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
230        Err(Error::ResponseError(local_var_error))
231    }
232}
233
234/// 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`.
235pub async fn preview_bpmn_instance(configuration: &configuration::Configuration, workspace: &str, preview_bpmn_instance: models::PreviewBpmnInstance) -> Result<String, Error<PreviewBpmnInstanceError>> {
236    let local_var_configuration = configuration;
237
238    let local_var_client = &local_var_configuration.client;
239
240    let local_var_uri_str = format!("{}/w/{workspace}/bpmn/run/preview", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
241    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
242
243    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
244        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
245    }
246    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
247        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
248    };
249    local_var_req_builder = local_var_req_builder.json(&preview_bpmn_instance);
250
251    let local_var_req = local_var_req_builder.build()?;
252    let local_var_resp = local_var_client.execute(local_var_req).await?;
253
254    let local_var_status = local_var_resp.status();
255    let local_var_content = local_var_resp.text().await?;
256
257    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
258        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
259    } else {
260        let local_var_entity: Option<PreviewBpmnInstanceError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
261        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
262        Err(Error::ResponseError(local_var_error))
263    }
264}
265
266/// 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.
267pub async fn retry_bpmn_incident(configuration: &configuration::Configuration, workspace: &str, id: &str, job_id: &str) -> Result<String, Error<RetryBpmnIncidentError>> {
268    let local_var_configuration = configuration;
269
270    let local_var_client = &local_var_configuration.client;
271
272    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));
273    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
274
275    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
276        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
277    }
278    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
279        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
280    };
281
282    let local_var_req = local_var_req_builder.build()?;
283    let local_var_resp = local_var_client.execute(local_var_req).await?;
284
285    let local_var_status = local_var_resp.status();
286    let local_var_content = local_var_resp.text().await?;
287
288    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
289        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
290    } else {
291        let local_var_entity: Option<RetryBpmnIncidentError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
292        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
293        Err(Error::ResponseError(local_var_error))
294    }
295}
296
297pub async fn start_bpmn_instance(configuration: &configuration::Configuration, workspace: &str, path: &str, start_bpmn_instance: models::StartBpmnInstance) -> Result<String, Error<StartBpmnInstanceError>> {
298    let local_var_configuration = configuration;
299
300    let local_var_client = &local_var_configuration.client;
301
302    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));
303    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
304
305    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
306        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
307    }
308    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
309        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
310    };
311    local_var_req_builder = local_var_req_builder.json(&start_bpmn_instance);
312
313    let local_var_req = local_var_req_builder.build()?;
314    let local_var_resp = local_var_client.execute(local_var_req).await?;
315
316    let local_var_status = local_var_resp.status();
317    let local_var_content = local_var_resp.text().await?;
318
319    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
320        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
321    } else {
322        let local_var_entity: Option<StartBpmnInstanceError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
323        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
324        Err(Error::ResponseError(local_var_error))
325    }
326}
327