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: 1.6.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 [`retry_bpmn_incident`]
54#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum RetryBpmnIncidentError {
57    UnknownValue(serde_json::Value),
58}
59
60/// struct for typed errors of method [`start_bpmn_instance`]
61#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum StartBpmnInstanceError {
64    UnknownValue(serde_json::Value),
65}
66
67
68pub async fn cancel_bpmn_instance(configuration: &configuration::Configuration, workspace: &str, id: &str, cancel_bpmn_instance: models::CancelBpmnInstance) -> Result<String, Error<CancelBpmnInstanceError>> {
69    let local_var_configuration = configuration;
70
71    let local_var_client = &local_var_configuration.client;
72
73    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));
74    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
75
76    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
77        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
78    }
79    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
80        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
81    };
82    local_var_req_builder = local_var_req_builder.json(&cancel_bpmn_instance);
83
84    let local_var_req = local_var_req_builder.build()?;
85    let local_var_resp = local_var_client.execute(local_var_req).await?;
86
87    let local_var_status = local_var_resp.status();
88    let local_var_content = local_var_resp.text().await?;
89
90    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
91        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
92    } else {
93        let local_var_entity: Option<CancelBpmnInstanceError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
94        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
95        Err(Error::ResponseError(local_var_error))
96    }
97}
98
99pub async fn get_bpmn_instance(configuration: &configuration::Configuration, workspace: &str, id: &str) -> Result<models::BpmnInstanceDetail, Error<GetBpmnInstanceError>> {
100    let local_var_configuration = configuration;
101
102    let local_var_client = &local_var_configuration.client;
103
104    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));
105    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
106
107    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
108        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
109    }
110    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
111        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
112    };
113
114    let local_var_req = local_var_req_builder.build()?;
115    let local_var_resp = local_var_client.execute(local_var_req).await?;
116
117    let local_var_status = local_var_resp.status();
118    let local_var_content = local_var_resp.text().await?;
119
120    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
121        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
122    } else {
123        let local_var_entity: Option<GetBpmnInstanceError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
124        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
125        Err(Error::ResponseError(local_var_error))
126    }
127}
128
129/// Frontend-facing projection of the process instance's live runtime state (lifecycle, per-activity status, variables, history, incidents), consumed by the bpmn-js token overlay. 404 if the instance isn't in the workspace, or if the engine has not picked it up yet (no runtime state).
130pub async fn get_bpmn_instance_status(configuration: &configuration::Configuration, workspace: &str, id: &str) -> Result<models::ProcessInstanceStatus, Error<GetBpmnInstanceStatusError>> {
131    let local_var_configuration = configuration;
132
133    let local_var_client = &local_var_configuration.client;
134
135    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));
136    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
137
138    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
139        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
140    }
141    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
142        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
143    };
144
145    let local_var_req = local_var_req_builder.build()?;
146    let local_var_resp = local_var_client.execute(local_var_req).await?;
147
148    let local_var_status = local_var_resp.status();
149    let local_var_content = local_var_resp.text().await?;
150
151    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
152        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
153    } else {
154        let local_var_entity: Option<GetBpmnInstanceStatusError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
155        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
156        Err(Error::ResponseError(local_var_error))
157    }
158}
159
160pub async fn list_bpmn_incidents(configuration: &configuration::Configuration, workspace: &str, id: &str) -> Result<Vec<models::BpmnIncident>, Error<ListBpmnIncidentsError>> {
161    let local_var_configuration = configuration;
162
163    let local_var_client = &local_var_configuration.client;
164
165    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));
166    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
167
168    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
169        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
170    }
171    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
172        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
173    };
174
175    let local_var_req = local_var_req_builder.build()?;
176    let local_var_resp = local_var_client.execute(local_var_req).await?;
177
178    let local_var_status = local_var_resp.status();
179    let local_var_content = local_var_resp.text().await?;
180
181    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
182        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
183    } else {
184        let local_var_entity: Option<ListBpmnIncidentsError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
185        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
186        Err(Error::ResponseError(local_var_error))
187    }
188}
189
190pub async fn list_bpmn_instances(configuration: &configuration::Configuration, workspace: &str, page: Option<i32>, per_page: Option<i32>) -> Result<Vec<models::BpmnInstanceSummary>, Error<ListBpmnInstancesError>> {
191    let local_var_configuration = configuration;
192
193    let local_var_client = &local_var_configuration.client;
194
195    let local_var_uri_str = format!("{}/w/{workspace}/bpmn/instances/list", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
196    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
197
198    if let Some(ref local_var_str) = page {
199        local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
200    }
201    if let Some(ref local_var_str) = per_page {
202        local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
203    }
204    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
205        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
206    }
207    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
208        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
209    };
210
211    let local_var_req = local_var_req_builder.build()?;
212    let local_var_resp = local_var_client.execute(local_var_req).await?;
213
214    let local_var_status = local_var_resp.status();
215    let local_var_content = local_var_resp.text().await?;
216
217    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
218        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
219    } else {
220        let local_var_entity: Option<ListBpmnInstancesError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
221        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
222        Err(Error::ResponseError(local_var_error))
223    }
224}
225
226/// 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.
227pub async fn retry_bpmn_incident(configuration: &configuration::Configuration, workspace: &str, id: &str, job_id: &str) -> Result<String, Error<RetryBpmnIncidentError>> {
228    let local_var_configuration = configuration;
229
230    let local_var_client = &local_var_configuration.client;
231
232    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));
233    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
234
235    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
236        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
237    }
238    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
239        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
240    };
241
242    let local_var_req = local_var_req_builder.build()?;
243    let local_var_resp = local_var_client.execute(local_var_req).await?;
244
245    let local_var_status = local_var_resp.status();
246    let local_var_content = local_var_resp.text().await?;
247
248    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
249        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
250    } else {
251        let local_var_entity: Option<RetryBpmnIncidentError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
252        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
253        Err(Error::ResponseError(local_var_error))
254    }
255}
256
257pub async fn start_bpmn_instance(configuration: &configuration::Configuration, workspace: &str, path: &str, start_bpmn_instance: models::StartBpmnInstance) -> Result<String, Error<StartBpmnInstanceError>> {
258    let local_var_configuration = configuration;
259
260    let local_var_client = &local_var_configuration.client;
261
262    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));
263    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
264
265    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
266        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
267    }
268    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
269        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
270    };
271    local_var_req_builder = local_var_req_builder.json(&start_bpmn_instance);
272
273    let local_var_req = local_var_req_builder.build()?;
274    let local_var_resp = local_var_client.execute(local_var_req).await?;
275
276    let local_var_status = local_var_resp.status();
277    let local_var_content = local_var_resp.text().await?;
278
279    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
280        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
281    } else {
282        let local_var_entity: Option<StartBpmnInstanceError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
283        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
284        Err(Error::ResponseError(local_var_error))
285    }
286}
287