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