1use 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 ConfigS3CreateS3Error {
22 Status400(models::PbsError),
23 Status401(models::PbsError),
24 Status403(models::PbsError),
25 Status404(models::PbsError),
26 Status500(models::PbsError),
27 Status501(models::PbsError),
28 Status503(models::PbsError),
29 UnknownValue(serde_json::Value),
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum ConfigS3DeleteS3Error {
36 Status400(models::PbsError),
37 Status401(models::PbsError),
38 Status403(models::PbsError),
39 Status404(models::PbsError),
40 Status500(models::PbsError),
41 Status501(models::PbsError),
42 Status503(models::PbsError),
43 UnknownValue(serde_json::Value),
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum ConfigS3GetConfigS3ByIdError {
50 Status400(models::PbsError),
51 Status401(models::PbsError),
52 Status403(models::PbsError),
53 Status404(models::PbsError),
54 Status500(models::PbsError),
55 Status501(models::PbsError),
56 Status503(models::PbsError),
57 UnknownValue(serde_json::Value),
58}
59
60#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum ConfigS3GetListBucketsError {
64 Status400(models::PbsError),
65 Status401(models::PbsError),
66 Status403(models::PbsError),
67 Status404(models::PbsError),
68 Status500(models::PbsError),
69 Status501(models::PbsError),
70 Status503(models::PbsError),
71 UnknownValue(serde_json::Value),
72}
73
74#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum ConfigS3GetS3Error {
78 Status400(models::PbsError),
79 Status401(models::PbsError),
80 Status403(models::PbsError),
81 Status404(models::PbsError),
82 Status500(models::PbsError),
83 Status501(models::PbsError),
84 Status503(models::PbsError),
85 UnknownValue(serde_json::Value),
86}
87
88#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum ConfigS3UpdateS3Error {
92 Status400(models::PbsError),
93 Status401(models::PbsError),
94 Status403(models::PbsError),
95 Status404(models::PbsError),
96 Status500(models::PbsError),
97 Status501(models::PbsError),
98 Status503(models::PbsError),
99 UnknownValue(serde_json::Value),
100}
101
102
103pub async fn config_s3_create_s3(configuration: &configuration::Configuration, config_s3_create_s3_request: models::ConfigS3CreateS3Request) -> Result<models::ConfigS3CreateS3Response, Error<ConfigS3CreateS3Error>> {
105 let p_body_config_s3_create_s3_request = config_s3_create_s3_request;
107
108 let uri_str = format!("{}/config/s3", configuration.base_path);
109 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
110
111 if let Some(ref user_agent) = configuration.user_agent {
112 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
113 }
114 if let Some(ref apikey) = configuration.api_key {
115 let key = apikey.key.clone();
116 let value = match apikey.prefix {
117 Some(ref prefix) => format!("{} {}", prefix, key),
118 None => key,
119 };
120 req_builder = req_builder.header("Authorization", value);
121 };
122 if let Some(ref apikey) = configuration.api_key {
123 let key = apikey.key.clone();
124 let value = match apikey.prefix {
125 Some(ref prefix) => format!("{} {}", prefix, key),
126 None => key,
127 };
128 req_builder = req_builder.header("CSRFPreventionToken", value);
129 };
130 req_builder = req_builder.json(&p_body_config_s3_create_s3_request);
131
132 let req = req_builder.build()?;
133 let resp = configuration.client.execute(req).await?;
134
135 let status = resp.status();
136 let content_type = resp
137 .headers()
138 .get("content-type")
139 .and_then(|v| v.to_str().ok())
140 .unwrap_or("application/octet-stream");
141 let content_type = super::ContentType::from(content_type);
142
143 if !status.is_client_error() && !status.is_server_error() {
144 let content = resp.text().await?;
145 match content_type {
146 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
147 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConfigS3CreateS3Response`"))),
148 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::ConfigS3CreateS3Response`")))),
149 }
150 } else {
151 let content = resp.text().await?;
152 let entity: Option<ConfigS3CreateS3Error> = serde_json::from_str(&content).ok();
153 Err(Error::ResponseError(ResponseContent { status, content, entity }))
154 }
155}
156
157pub async fn config_s3_delete_s3(configuration: &configuration::Configuration, id: &str, digest: Option<&str>) -> Result<models::ConfigS3DeleteS3Response, Error<ConfigS3DeleteS3Error>> {
159 let p_path_id = id;
161 let p_query_digest = digest;
162
163 let uri_str = format!("{}/config/s3/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
164 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
165
166 if let Some(ref param_value) = p_query_digest {
167 req_builder = req_builder.query(&[("digest", ¶m_value.to_string())]);
168 }
169 if let Some(ref user_agent) = configuration.user_agent {
170 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
171 }
172 if let Some(ref apikey) = configuration.api_key {
173 let key = apikey.key.clone();
174 let value = match apikey.prefix {
175 Some(ref prefix) => format!("{} {}", prefix, key),
176 None => key,
177 };
178 req_builder = req_builder.header("Authorization", value);
179 };
180 if let Some(ref apikey) = configuration.api_key {
181 let key = apikey.key.clone();
182 let value = match apikey.prefix {
183 Some(ref prefix) => format!("{} {}", prefix, key),
184 None => key,
185 };
186 req_builder = req_builder.header("CSRFPreventionToken", value);
187 };
188
189 let req = req_builder.build()?;
190 let resp = configuration.client.execute(req).await?;
191
192 let status = resp.status();
193 let content_type = resp
194 .headers()
195 .get("content-type")
196 .and_then(|v| v.to_str().ok())
197 .unwrap_or("application/octet-stream");
198 let content_type = super::ContentType::from(content_type);
199
200 if !status.is_client_error() && !status.is_server_error() {
201 let content = resp.text().await?;
202 match content_type {
203 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
204 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConfigS3DeleteS3Response`"))),
205 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::ConfigS3DeleteS3Response`")))),
206 }
207 } else {
208 let content = resp.text().await?;
209 let entity: Option<ConfigS3DeleteS3Error> = serde_json::from_str(&content).ok();
210 Err(Error::ResponseError(ResponseContent { status, content, entity }))
211 }
212}
213
214pub async fn config_s3_get_config_s3_by_id(configuration: &configuration::Configuration, id: &str) -> Result<models::ConfigS3GetConfigS3ByIdResponse, Error<ConfigS3GetConfigS3ByIdError>> {
216 let p_path_id = id;
218
219 let uri_str = format!("{}/config/s3/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
220 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
221
222 if let Some(ref user_agent) = configuration.user_agent {
223 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
224 }
225 if let Some(ref apikey) = configuration.api_key {
226 let key = apikey.key.clone();
227 let value = match apikey.prefix {
228 Some(ref prefix) => format!("{} {}", prefix, key),
229 None => key,
230 };
231 req_builder = req_builder.header("Authorization", value);
232 };
233 if let Some(ref apikey) = configuration.api_key {
234 let key = apikey.key.clone();
235 let value = match apikey.prefix {
236 Some(ref prefix) => format!("{} {}", prefix, key),
237 None => key,
238 };
239 req_builder = req_builder.header("CSRFPreventionToken", value);
240 };
241
242 let req = req_builder.build()?;
243 let resp = configuration.client.execute(req).await?;
244
245 let status = resp.status();
246 let content_type = resp
247 .headers()
248 .get("content-type")
249 .and_then(|v| v.to_str().ok())
250 .unwrap_or("application/octet-stream");
251 let content_type = super::ContentType::from(content_type);
252
253 if !status.is_client_error() && !status.is_server_error() {
254 let content = resp.text().await?;
255 match content_type {
256 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
257 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConfigS3GetConfigS3ByIdResponse`"))),
258 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::ConfigS3GetConfigS3ByIdResponse`")))),
259 }
260 } else {
261 let content = resp.text().await?;
262 let entity: Option<ConfigS3GetConfigS3ByIdError> = serde_json::from_str(&content).ok();
263 Err(Error::ResponseError(ResponseContent { status, content, entity }))
264 }
265}
266
267pub async fn config_s3_get_list_buckets(configuration: &configuration::Configuration, id: &str) -> Result<models::ConfigS3GetListBucketsResponse, Error<ConfigS3GetListBucketsError>> {
269 let p_path_id = id;
271
272 let uri_str = format!("{}/config/s3/{id}/list-buckets", configuration.base_path, id=crate::apis::urlencode(p_path_id));
273 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
274
275 if let Some(ref user_agent) = configuration.user_agent {
276 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
277 }
278 if let Some(ref apikey) = configuration.api_key {
279 let key = apikey.key.clone();
280 let value = match apikey.prefix {
281 Some(ref prefix) => format!("{} {}", prefix, key),
282 None => key,
283 };
284 req_builder = req_builder.header("Authorization", value);
285 };
286 if let Some(ref apikey) = configuration.api_key {
287 let key = apikey.key.clone();
288 let value = match apikey.prefix {
289 Some(ref prefix) => format!("{} {}", prefix, key),
290 None => key,
291 };
292 req_builder = req_builder.header("CSRFPreventionToken", value);
293 };
294
295 let req = req_builder.build()?;
296 let resp = configuration.client.execute(req).await?;
297
298 let status = resp.status();
299 let content_type = resp
300 .headers()
301 .get("content-type")
302 .and_then(|v| v.to_str().ok())
303 .unwrap_or("application/octet-stream");
304 let content_type = super::ContentType::from(content_type);
305
306 if !status.is_client_error() && !status.is_server_error() {
307 let content = resp.text().await?;
308 match content_type {
309 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
310 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConfigS3GetListBucketsResponse`"))),
311 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::ConfigS3GetListBucketsResponse`")))),
312 }
313 } else {
314 let content = resp.text().await?;
315 let entity: Option<ConfigS3GetListBucketsError> = serde_json::from_str(&content).ok();
316 Err(Error::ResponseError(ResponseContent { status, content, entity }))
317 }
318}
319
320pub async fn config_s3_get_s3(configuration: &configuration::Configuration, ) -> Result<models::ConfigS3GetS3Response, Error<ConfigS3GetS3Error>> {
322
323 let uri_str = format!("{}/config/s3", configuration.base_path);
324 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
325
326 if let Some(ref user_agent) = configuration.user_agent {
327 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
328 }
329 if let Some(ref apikey) = configuration.api_key {
330 let key = apikey.key.clone();
331 let value = match apikey.prefix {
332 Some(ref prefix) => format!("{} {}", prefix, key),
333 None => key,
334 };
335 req_builder = req_builder.header("Authorization", value);
336 };
337 if let Some(ref apikey) = configuration.api_key {
338 let key = apikey.key.clone();
339 let value = match apikey.prefix {
340 Some(ref prefix) => format!("{} {}", prefix, key),
341 None => key,
342 };
343 req_builder = req_builder.header("CSRFPreventionToken", value);
344 };
345
346 let req = req_builder.build()?;
347 let resp = configuration.client.execute(req).await?;
348
349 let status = resp.status();
350 let content_type = resp
351 .headers()
352 .get("content-type")
353 .and_then(|v| v.to_str().ok())
354 .unwrap_or("application/octet-stream");
355 let content_type = super::ContentType::from(content_type);
356
357 if !status.is_client_error() && !status.is_server_error() {
358 let content = resp.text().await?;
359 match content_type {
360 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
361 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConfigS3GetS3Response`"))),
362 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::ConfigS3GetS3Response`")))),
363 }
364 } else {
365 let content = resp.text().await?;
366 let entity: Option<ConfigS3GetS3Error> = serde_json::from_str(&content).ok();
367 Err(Error::ResponseError(ResponseContent { status, content, entity }))
368 }
369}
370
371pub async fn config_s3_update_s3(configuration: &configuration::Configuration, id: &str, config_s3_update_s3_request: Option<models::ConfigS3UpdateS3Request>) -> Result<models::ConfigS3UpdateS3Response, Error<ConfigS3UpdateS3Error>> {
373 let p_path_id = id;
375 let p_body_config_s3_update_s3_request = config_s3_update_s3_request;
376
377 let uri_str = format!("{}/config/s3/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
378 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
379
380 if let Some(ref user_agent) = configuration.user_agent {
381 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
382 }
383 if let Some(ref apikey) = configuration.api_key {
384 let key = apikey.key.clone();
385 let value = match apikey.prefix {
386 Some(ref prefix) => format!("{} {}", prefix, key),
387 None => key,
388 };
389 req_builder = req_builder.header("Authorization", value);
390 };
391 if let Some(ref apikey) = configuration.api_key {
392 let key = apikey.key.clone();
393 let value = match apikey.prefix {
394 Some(ref prefix) => format!("{} {}", prefix, key),
395 None => key,
396 };
397 req_builder = req_builder.header("CSRFPreventionToken", value);
398 };
399 req_builder = req_builder.json(&p_body_config_s3_update_s3_request);
400
401 let req = req_builder.build()?;
402 let resp = configuration.client.execute(req).await?;
403
404 let status = resp.status();
405 let content_type = resp
406 .headers()
407 .get("content-type")
408 .and_then(|v| v.to_str().ok())
409 .unwrap_or("application/octet-stream");
410 let content_type = super::ContentType::from(content_type);
411
412 if !status.is_client_error() && !status.is_server_error() {
413 let content = resp.text().await?;
414 match content_type {
415 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
416 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ConfigS3UpdateS3Response`"))),
417 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::ConfigS3UpdateS3Response`")))),
418 }
419 } else {
420 let content = resp.text().await?;
421 let entity: Option<ConfigS3UpdateS3Error> = serde_json::from_str(&content).ok();
422 Err(Error::ResponseError(ResponseContent { status, content, entity }))
423 }
424}
425