1use super::{configuration, ContentType, Error};
12use crate::{apis::ResponseContent, models};
13use reqwest;
14use serde::{de::Error as _, Deserialize, Serialize};
15
16#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum WorkflowControllerCreateError {
20 UnknownValue(serde_json::Value),
21}
22
23#[derive(Debug, Clone, Serialize, Deserialize)]
25#[serde(untagged)]
26pub enum WorkflowControllerDeleteError {
27 UnknownValue(serde_json::Value),
28}
29
30#[derive(Debug, Clone, Serialize, Deserialize)]
32#[serde(untagged)]
33pub enum WorkflowControllerFindAllError {
34 UnknownValue(serde_json::Value),
35}
36
37#[derive(Debug, Clone, Serialize, Deserialize)]
39#[serde(untagged)]
40pub enum WorkflowControllerFindOneError {
41 UnknownValue(serde_json::Value),
42}
43
44#[derive(Debug, Clone, Serialize, Deserialize)]
46#[serde(untagged)]
47pub enum WorkflowControllerUpdateError {
48 UnknownValue(serde_json::Value),
49}
50
51pub async fn workflow_controller_create(
52 configuration: &configuration::Configuration,
53 create_workflow_dto: models::CreateWorkflowDto,
54) -> Result<models::Workflow, Error<WorkflowControllerCreateError>> {
55 let p_create_workflow_dto = create_workflow_dto;
57
58 let uri_str = format!("{}/workflow", configuration.base_path);
59 let mut req_builder = configuration
60 .client
61 .request(reqwest::Method::POST, &uri_str);
62
63 if let Some(ref user_agent) = configuration.user_agent {
64 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
65 }
66 if let Some(ref token) = configuration.bearer_access_token {
67 req_builder = req_builder.bearer_auth(token.to_owned());
68 };
69 req_builder = req_builder.json(&p_create_workflow_dto);
70
71 let req = req_builder.build()?;
72 let resp = configuration.client.execute(req).await?;
73
74 let status = resp.status();
75 let content_type = resp
76 .headers()
77 .get("content-type")
78 .and_then(|v| v.to_str().ok())
79 .unwrap_or("application/octet-stream");
80 let content_type = super::ContentType::from(content_type);
81
82 if !status.is_client_error() && !status.is_server_error() {
83 let content = resp.text().await?;
84 match content_type {
85 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
86 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Workflow`"))),
87 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Workflow`")))),
88 }
89 } else {
90 let content = resp.text().await?;
91 let entity: Option<WorkflowControllerCreateError> = serde_json::from_str(&content).ok();
92 Err(Error::ResponseError(ResponseContent {
93 status,
94 content,
95 entity,
96 }))
97 }
98}
99
100pub async fn workflow_controller_delete(
101 configuration: &configuration::Configuration,
102 id: &str,
103) -> Result<models::Workflow, Error<WorkflowControllerDeleteError>> {
104 let p_id = id;
106
107 let uri_str = format!(
108 "{}/workflow/{id}",
109 configuration.base_path,
110 id = crate::apis::urlencode(p_id)
111 );
112 let mut req_builder = configuration
113 .client
114 .request(reqwest::Method::DELETE, &uri_str);
115
116 if let Some(ref user_agent) = configuration.user_agent {
117 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
118 }
119 if let Some(ref token) = configuration.bearer_access_token {
120 req_builder = req_builder.bearer_auth(token.to_owned());
121 };
122
123 let req = req_builder.build()?;
124 let resp = configuration.client.execute(req).await?;
125
126 let status = resp.status();
127 let content_type = resp
128 .headers()
129 .get("content-type")
130 .and_then(|v| v.to_str().ok())
131 .unwrap_or("application/octet-stream");
132 let content_type = super::ContentType::from(content_type);
133
134 if !status.is_client_error() && !status.is_server_error() {
135 let content = resp.text().await?;
136 match content_type {
137 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
138 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Workflow`"))),
139 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Workflow`")))),
140 }
141 } else {
142 let content = resp.text().await?;
143 let entity: Option<WorkflowControllerDeleteError> = serde_json::from_str(&content).ok();
144 Err(Error::ResponseError(ResponseContent {
145 status,
146 content,
147 entity,
148 }))
149 }
150}
151
152pub async fn workflow_controller_find_all(
153 configuration: &configuration::Configuration,
154) -> Result<Vec<models::Workflow>, Error<WorkflowControllerFindAllError>> {
155 let uri_str = format!("{}/workflow", configuration.base_path);
156 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
157
158 if let Some(ref user_agent) = configuration.user_agent {
159 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
160 }
161 if let Some(ref token) = configuration.bearer_access_token {
162 req_builder = req_builder.bearer_auth(token.to_owned());
163 };
164
165 let req = req_builder.build()?;
166 let resp = configuration.client.execute(req).await?;
167
168 let status = resp.status();
169 let content_type = resp
170 .headers()
171 .get("content-type")
172 .and_then(|v| v.to_str().ok())
173 .unwrap_or("application/octet-stream");
174 let content_type = super::ContentType::from(content_type);
175
176 if !status.is_client_error() && !status.is_server_error() {
177 let content = resp.text().await?;
178 match content_type {
179 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
180 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::Workflow>`"))),
181 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::Workflow>`")))),
182 }
183 } else {
184 let content = resp.text().await?;
185 let entity: Option<WorkflowControllerFindAllError> = serde_json::from_str(&content).ok();
186 Err(Error::ResponseError(ResponseContent {
187 status,
188 content,
189 entity,
190 }))
191 }
192}
193
194pub async fn workflow_controller_find_one(
195 configuration: &configuration::Configuration,
196 id: &str,
197) -> Result<models::Workflow, Error<WorkflowControllerFindOneError>> {
198 let p_id = id;
200
201 let uri_str = format!(
202 "{}/workflow/{id}",
203 configuration.base_path,
204 id = crate::apis::urlencode(p_id)
205 );
206 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
207
208 if let Some(ref user_agent) = configuration.user_agent {
209 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
210 }
211 if let Some(ref token) = configuration.bearer_access_token {
212 req_builder = req_builder.bearer_auth(token.to_owned());
213 };
214
215 let req = req_builder.build()?;
216 let resp = configuration.client.execute(req).await?;
217
218 let status = resp.status();
219 let content_type = resp
220 .headers()
221 .get("content-type")
222 .and_then(|v| v.to_str().ok())
223 .unwrap_or("application/octet-stream");
224 let content_type = super::ContentType::from(content_type);
225
226 if !status.is_client_error() && !status.is_server_error() {
227 let content = resp.text().await?;
228 match content_type {
229 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
230 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Workflow`"))),
231 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Workflow`")))),
232 }
233 } else {
234 let content = resp.text().await?;
235 let entity: Option<WorkflowControllerFindOneError> = serde_json::from_str(&content).ok();
236 Err(Error::ResponseError(ResponseContent {
237 status,
238 content,
239 entity,
240 }))
241 }
242}
243
244pub async fn workflow_controller_update(
245 configuration: &configuration::Configuration,
246 id: &str,
247 update_workflow_dto: models::UpdateWorkflowDto,
248) -> Result<models::Workflow, Error<WorkflowControllerUpdateError>> {
249 let p_id = id;
251 let p_update_workflow_dto = update_workflow_dto;
252
253 let uri_str = format!(
254 "{}/workflow/{id}",
255 configuration.base_path,
256 id = crate::apis::urlencode(p_id)
257 );
258 let mut req_builder = configuration
259 .client
260 .request(reqwest::Method::PATCH, &uri_str);
261
262 if let Some(ref user_agent) = configuration.user_agent {
263 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
264 }
265 if let Some(ref token) = configuration.bearer_access_token {
266 req_builder = req_builder.bearer_auth(token.to_owned());
267 };
268 req_builder = req_builder.json(&p_update_workflow_dto);
269
270 let req = req_builder.build()?;
271 let resp = configuration.client.execute(req).await?;
272
273 let status = resp.status();
274 let content_type = resp
275 .headers()
276 .get("content-type")
277 .and_then(|v| v.to_str().ok())
278 .unwrap_or("application/octet-stream");
279 let content_type = super::ContentType::from(content_type);
280
281 if !status.is_client_error() && !status.is_server_error() {
282 let content = resp.text().await?;
283 match content_type {
284 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
285 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Workflow`"))),
286 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Workflow`")))),
287 }
288 } else {
289 let content = resp.text().await?;
290 let entity: Option<WorkflowControllerUpdateError> = serde_json::from_str(&content).ok();
291 Err(Error::ResponseError(ResponseContent {
292 status,
293 content,
294 entity,
295 }))
296 }
297}