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