zsgf_client/apis/
system_file_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 SystemFileCreateFolderError {
22 UnknownValue(serde_json::Value),
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum SystemFileDeleteError {
29 UnknownValue(serde_json::Value),
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum SystemFileRenameError {
36 UnknownValue(serde_json::Value),
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum SystemFileUploadError {
43 UnknownValue(serde_json::Value),
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum SystemFilesError {
50 UnknownValue(serde_json::Value),
51}
52
53
54pub async fn system_file_create_folder(configuration: &configuration::Configuration, path: Option<&str>) -> Result<models::BooleanApiResponse, Error<SystemFileCreateFolderError>> {
56 let p_path = path;
58
59 let uri_str = format!("{}/SystemFile/CreateFolder", configuration.base_path);
60 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
61
62 if let Some(ref param_value) = p_path {
63 req_builder = req_builder.query(&[("path", ¶m_value.to_string())]);
64 }
65 if let Some(ref user_agent) = configuration.user_agent {
66 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
67 }
68 if let Some(ref token) = configuration.bearer_access_token {
69 req_builder = req_builder.bearer_auth(token.to_owned());
70 };
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::BooleanApiResponse`"))),
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::BooleanApiResponse`")))),
89 }
90 } else {
91 let content = resp.text().await?;
92 let entity: Option<SystemFileCreateFolderError> = serde_json::from_str(&content).ok();
93 Err(Error::ResponseError(ResponseContent { status, content, entity }))
94 }
95}
96
97pub async fn system_file_delete(configuration: &configuration::Configuration, path: Option<&str>) -> Result<models::BooleanApiResponse, Error<SystemFileDeleteError>> {
99 let p_path = path;
101
102 let uri_str = format!("{}/SystemFile", configuration.base_path);
103 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
104
105 if let Some(ref param_value) = p_path {
106 req_builder = req_builder.query(&[("path", ¶m_value.to_string())]);
107 }
108 if let Some(ref user_agent) = configuration.user_agent {
109 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
110 }
111 if let Some(ref token) = configuration.bearer_access_token {
112 req_builder = req_builder.bearer_auth(token.to_owned());
113 };
114
115 let req = req_builder.build()?;
116 let resp = configuration.client.execute(req).await?;
117
118 let status = resp.status();
119 let content_type = resp
120 .headers()
121 .get("content-type")
122 .and_then(|v| v.to_str().ok())
123 .unwrap_or("application/octet-stream");
124 let content_type = super::ContentType::from(content_type);
125
126 if !status.is_client_error() && !status.is_server_error() {
127 let content = resp.text().await?;
128 match content_type {
129 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
130 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BooleanApiResponse`"))),
131 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::BooleanApiResponse`")))),
132 }
133 } else {
134 let content = resp.text().await?;
135 let entity: Option<SystemFileDeleteError> = serde_json::from_str(&content).ok();
136 Err(Error::ResponseError(ResponseContent { status, content, entity }))
137 }
138}
139
140pub async fn system_file_rename(configuration: &configuration::Configuration, source_name: Option<&str>, dest_name: Option<&str>) -> Result<models::BooleanApiResponse, Error<SystemFileRenameError>> {
142 let p_source_name = source_name;
144 let p_dest_name = dest_name;
145
146 let uri_str = format!("{}/SystemFile/Rename", configuration.base_path);
147 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
148
149 if let Some(ref param_value) = p_source_name {
150 req_builder = req_builder.query(&[("sourceName", ¶m_value.to_string())]);
151 }
152 if let Some(ref param_value) = p_dest_name {
153 req_builder = req_builder.query(&[("destName", ¶m_value.to_string())]);
154 }
155 if let Some(ref user_agent) = configuration.user_agent {
156 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
157 }
158 if let Some(ref token) = configuration.bearer_access_token {
159 req_builder = req_builder.bearer_auth(token.to_owned());
160 };
161
162 let req = req_builder.build()?;
163 let resp = configuration.client.execute(req).await?;
164
165 let status = resp.status();
166 let content_type = resp
167 .headers()
168 .get("content-type")
169 .and_then(|v| v.to_str().ok())
170 .unwrap_or("application/octet-stream");
171 let content_type = super::ContentType::from(content_type);
172
173 if !status.is_client_error() && !status.is_server_error() {
174 let content = resp.text().await?;
175 match content_type {
176 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
177 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BooleanApiResponse`"))),
178 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::BooleanApiResponse`")))),
179 }
180 } else {
181 let content = resp.text().await?;
182 let entity: Option<SystemFileRenameError> = serde_json::from_str(&content).ok();
183 Err(Error::ResponseError(ResponseContent { status, content, entity }))
184 }
185}
186
187pub async fn system_file_upload(configuration: &configuration::Configuration, path: Option<&str>, file: Option<std::path::PathBuf>) -> Result<models::StringApiResponse, Error<SystemFileUploadError>> {
189 let p_path = path;
191 let p_file = file;
192
193 let uri_str = format!("{}/SystemFile", configuration.base_path);
194 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
195
196 if let Some(ref param_value) = p_path {
197 req_builder = req_builder.query(&[("path", ¶m_value.to_string())]);
198 }
199 if let Some(ref user_agent) = configuration.user_agent {
200 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
201 }
202 if let Some(ref token) = configuration.bearer_access_token {
203 req_builder = req_builder.bearer_auth(token.to_owned());
204 };
205 let mut multipart_form = reqwest::multipart::Form::new();
206 req_builder = req_builder.multipart(multipart_form);
208
209 let req = req_builder.build()?;
210 let resp = configuration.client.execute(req).await?;
211
212 let status = resp.status();
213 let content_type = resp
214 .headers()
215 .get("content-type")
216 .and_then(|v| v.to_str().ok())
217 .unwrap_or("application/octet-stream");
218 let content_type = super::ContentType::from(content_type);
219
220 if !status.is_client_error() && !status.is_server_error() {
221 let content = resp.text().await?;
222 match content_type {
223 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
224 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::StringApiResponse`"))),
225 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::StringApiResponse`")))),
226 }
227 } else {
228 let content = resp.text().await?;
229 let entity: Option<SystemFileUploadError> = serde_json::from_str(&content).ok();
230 Err(Error::ResponseError(ResponseContent { status, content, entity }))
231 }
232}
233
234pub async fn system_files(configuration: &configuration::Configuration, path: Option<&str>) -> Result<models::SystemFileListResultApiResponse, Error<SystemFilesError>> {
236 let p_path = path;
238
239 let uri_str = format!("{}/SystemFile", configuration.base_path);
240 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
241
242 if let Some(ref param_value) = p_path {
243 req_builder = req_builder.query(&[("path", ¶m_value.to_string())]);
244 }
245 if let Some(ref user_agent) = configuration.user_agent {
246 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
247 }
248 if let Some(ref token) = configuration.bearer_access_token {
249 req_builder = req_builder.bearer_auth(token.to_owned());
250 };
251
252 let req = req_builder.build()?;
253 let resp = configuration.client.execute(req).await?;
254
255 let status = resp.status();
256 let content_type = resp
257 .headers()
258 .get("content-type")
259 .and_then(|v| v.to_str().ok())
260 .unwrap_or("application/octet-stream");
261 let content_type = super::ContentType::from(content_type);
262
263 if !status.is_client_error() && !status.is_server_error() {
264 let content = resp.text().await?;
265 match content_type {
266 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
267 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SystemFileListResultApiResponse`"))),
268 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::SystemFileListResultApiResponse`")))),
269 }
270 } else {
271 let content = resp.text().await?;
272 let entity: Option<SystemFilesError> = serde_json::from_str(&content).ok();
273 Err(Error::ResponseError(ResponseContent { status, content, entity }))
274 }
275}
276