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 Delete5Error {
20 UnknownValue(serde_json::Value),
21}
22
23#[derive(Debug, Clone, Serialize, Deserialize)]
25#[serde(untagged)]
26pub enum DeleteAllError {
27 UnknownValue(serde_json::Value),
28}
29
30#[derive(Debug, Clone, Serialize, Deserialize)]
32#[serde(untagged)]
33pub enum Download2Error {
34 UnknownValue(serde_json::Value),
35}
36
37#[derive(Debug, Clone, Serialize, Deserialize)]
39#[serde(untagged)]
40pub enum FindAll1Error {
41 UnknownValue(serde_json::Value),
42}
43
44#[derive(Debug, Clone, Serialize, Deserialize)]
46#[serde(untagged)]
47pub enum FindByCorrelationIdError {
48 UnknownValue(serde_json::Value),
49}
50
51#[derive(Debug, Clone, Serialize, Deserialize)]
53#[serde(untagged)]
54pub enum FindByCorrelationIdPublicError {
55 UnknownValue(serde_json::Value),
56}
57
58#[derive(Debug, Clone, Serialize, Deserialize)]
60#[serde(untagged)]
61pub enum FindById6Error {
62 UnknownValue(serde_json::Value),
63}
64
65#[derive(Debug, Clone, Serialize, Deserialize)]
67#[serde(untagged)]
68pub enum FindByIdPublicError {
69 UnknownValue(serde_json::Value),
70}
71
72#[derive(Debug, Clone, Serialize, Deserialize)]
74#[serde(untagged)]
75pub enum FindByIds4Error {
76 UnknownValue(serde_json::Value),
77}
78
79#[derive(Debug, Clone, Serialize, Deserialize)]
81#[serde(untagged)]
82pub enum GetCorrelationLinksError {
83 UnknownValue(serde_json::Value),
84}
85
86#[derive(Debug, Clone, Serialize, Deserialize)]
88#[serde(untagged)]
89pub enum PublicDownloadError {
90 UnknownValue(serde_json::Value),
91}
92
93#[derive(Debug, Clone, Serialize, Deserialize)]
95#[serde(untagged)]
96pub enum ToggleBookmarkedError {
97 UnknownValue(serde_json::Value),
98}
99
100#[derive(Debug, Clone, Serialize, Deserialize)]
102#[serde(untagged)]
103pub enum UploadError {
104 UnknownValue(serde_json::Value),
105}
106
107pub async fn delete5(
108 configuration: &configuration::Configuration,
109 id: &str,
110) -> Result<models::Restore200Response, Error<Delete5Error>> {
111 let p_query_id = id;
113
114 let uri_str = format!("{}/api/resource/delete-by-id", configuration.base_path);
115 let mut req_builder = configuration
116 .client
117 .request(reqwest::Method::DELETE, &uri_str);
118
119 req_builder = req_builder.query(&[("id", &p_query_id.to_string())]);
120 if let Some(ref user_agent) = configuration.user_agent {
121 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
122 }
123 if let Some(ref token) = configuration.bearer_access_token {
124 req_builder = req_builder.bearer_auth(token.to_owned());
125 };
126
127 let req = req_builder.build()?;
128 let resp = configuration.client.execute(req).await?;
129
130 let status = resp.status();
131 let content_type = resp
132 .headers()
133 .get("content-type")
134 .and_then(|v| v.to_str().ok())
135 .unwrap_or("application/octet-stream");
136 let content_type = super::ContentType::from(content_type);
137
138 if !status.is_client_error() && !status.is_server_error() {
139 let content = resp.text().await?;
140 match content_type {
141 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
142 ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Restore200Response`"))),
143 ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Restore200Response`")))),
144 }
145 } else {
146 let content = resp.text().await?;
147 let entity: Option<Delete5Error> = serde_json::from_str(&content).ok();
148 Err(Error::ResponseError(ResponseContent {
149 status,
150 content,
151 entity,
152 }))
153 }
154}
155
156pub async fn delete_all(
157 configuration: &configuration::Configuration,
158) -> Result<models::Restore200Response, Error<DeleteAllError>> {
159 let uri_str = format!("{}/api/resource/delete-all", configuration.base_path);
160 let mut req_builder = configuration
161 .client
162 .request(reqwest::Method::DELETE, &uri_str);
163
164 if let Some(ref user_agent) = configuration.user_agent {
165 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
166 }
167 if let Some(ref token) = configuration.bearer_access_token {
168 req_builder = req_builder.bearer_auth(token.to_owned());
169 };
170
171 let req = req_builder.build()?;
172 let resp = configuration.client.execute(req).await?;
173
174 let status = resp.status();
175 let content_type = resp
176 .headers()
177 .get("content-type")
178 .and_then(|v| v.to_str().ok())
179 .unwrap_or("application/octet-stream");
180 let content_type = super::ContentType::from(content_type);
181
182 if !status.is_client_error() && !status.is_server_error() {
183 let content = resp.text().await?;
184 match content_type {
185 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
186 ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Restore200Response`"))),
187 ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Restore200Response`")))),
188 }
189 } else {
190 let content = resp.text().await?;
191 let entity: Option<DeleteAllError> = serde_json::from_str(&content).ok();
192 Err(Error::ResponseError(ResponseContent {
193 status,
194 content,
195 entity,
196 }))
197 }
198}
199
200pub async fn download2(
201 configuration: &configuration::Configuration,
202 id: &str,
203) -> Result<reqwest::Response, Error<Download2Error>> {
204 let p_query_id = id;
206
207 let uri_str = format!("{}/api/resource/download", configuration.base_path);
208 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
209
210 req_builder = req_builder.query(&[("id", &p_query_id.to_string())]);
211 if let Some(ref user_agent) = configuration.user_agent {
212 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
213 }
214 if let Some(ref token) = configuration.bearer_access_token {
215 req_builder = req_builder.bearer_auth(token.to_owned());
216 };
217
218 let req = req_builder.build()?;
219 let resp = configuration.client.execute(req).await?;
220
221 let status = resp.status();
222
223 if !status.is_client_error() && !status.is_server_error() {
224 Ok(resp)
225 } else {
226 let content = resp.text().await?;
227 let entity: Option<Download2Error> = serde_json::from_str(&content).ok();
228 Err(Error::ResponseError(ResponseContent {
229 status,
230 content,
231 entity,
232 }))
233 }
234}
235
236pub async fn find_all1(
237 configuration: &configuration::Configuration,
238 arg1: models::Pageable,
239 file_upload_search_criteria: models::FileUploadSearchCriteria,
240) -> Result<models::PagedModelFileUpload, Error<FindAll1Error>> {
241 let p_query_arg1 = arg1;
243 let p_body_file_upload_search_criteria = file_upload_search_criteria;
244
245 let uri_str = format!("{}/api/resource/find-all", configuration.base_path);
246 let mut req_builder = configuration
247 .client
248 .request(reqwest::Method::POST, &uri_str);
249
250 req_builder = req_builder.query(&[("arg1", &p_query_arg1.to_string())]);
251 if let Some(ref user_agent) = configuration.user_agent {
252 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
253 }
254 if let Some(ref token) = configuration.bearer_access_token {
255 req_builder = req_builder.bearer_auth(token.to_owned());
256 };
257 req_builder = req_builder.json(&p_body_file_upload_search_criteria);
258
259 let req = req_builder.build()?;
260 let resp = configuration.client.execute(req).await?;
261
262 let status = resp.status();
263 let content_type = resp
264 .headers()
265 .get("content-type")
266 .and_then(|v| v.to_str().ok())
267 .unwrap_or("application/octet-stream");
268 let content_type = super::ContentType::from(content_type);
269
270 if !status.is_client_error() && !status.is_server_error() {
271 let content = resp.text().await?;
272 match content_type {
273 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
274 ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PagedModelFileUpload`"))),
275 ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PagedModelFileUpload`")))),
276 }
277 } else {
278 let content = resp.text().await?;
279 let entity: Option<FindAll1Error> = serde_json::from_str(&content).ok();
280 Err(Error::ResponseError(ResponseContent {
281 status,
282 content,
283 entity,
284 }))
285 }
286}
287
288pub async fn find_by_correlation_id(
289 configuration: &configuration::Configuration,
290 correlation_id: &str,
291) -> Result<Vec<models::FileUpload>, Error<FindByCorrelationIdError>> {
292 let p_query_correlation_id = correlation_id;
294
295 let uri_str = format!(
296 "{}/api/resource/find-by-correlation-id",
297 configuration.base_path
298 );
299 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
300
301 req_builder = req_builder.query(&[("correlationId", &p_query_correlation_id.to_string())]);
302 if let Some(ref user_agent) = configuration.user_agent {
303 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
304 }
305 if let Some(ref token) = configuration.bearer_access_token {
306 req_builder = req_builder.bearer_auth(token.to_owned());
307 };
308
309 let req = req_builder.build()?;
310 let resp = configuration.client.execute(req).await?;
311
312 let status = resp.status();
313 let content_type = resp
314 .headers()
315 .get("content-type")
316 .and_then(|v| v.to_str().ok())
317 .unwrap_or("application/octet-stream");
318 let content_type = super::ContentType::from(content_type);
319
320 if !status.is_client_error() && !status.is_server_error() {
321 let content = resp.text().await?;
322 match content_type {
323 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
324 ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::FileUpload>`"))),
325 ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::FileUpload>`")))),
326 }
327 } else {
328 let content = resp.text().await?;
329 let entity: Option<FindByCorrelationIdError> = serde_json::from_str(&content).ok();
330 Err(Error::ResponseError(ResponseContent {
331 status,
332 content,
333 entity,
334 }))
335 }
336}
337
338pub async fn find_by_correlation_id_public(
339 configuration: &configuration::Configuration,
340 correlation_id: &str,
341) -> Result<Vec<models::FileUpload>, Error<FindByCorrelationIdPublicError>> {
342 let p_query_correlation_id = correlation_id;
344
345 let uri_str = format!(
346 "{}/api/resource/public/find-by-correlation-id",
347 configuration.base_path
348 );
349 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
350
351 req_builder = req_builder.query(&[("correlationId", &p_query_correlation_id.to_string())]);
352 if let Some(ref user_agent) = configuration.user_agent {
353 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
354 }
355 if let Some(ref token) = configuration.bearer_access_token {
356 req_builder = req_builder.bearer_auth(token.to_owned());
357 };
358
359 let req = req_builder.build()?;
360 let resp = configuration.client.execute(req).await?;
361
362 let status = resp.status();
363 let content_type = resp
364 .headers()
365 .get("content-type")
366 .and_then(|v| v.to_str().ok())
367 .unwrap_or("application/octet-stream");
368 let content_type = super::ContentType::from(content_type);
369
370 if !status.is_client_error() && !status.is_server_error() {
371 let content = resp.text().await?;
372 match content_type {
373 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
374 ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::FileUpload>`"))),
375 ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::FileUpload>`")))),
376 }
377 } else {
378 let content = resp.text().await?;
379 let entity: Option<FindByCorrelationIdPublicError> = serde_json::from_str(&content).ok();
380 Err(Error::ResponseError(ResponseContent {
381 status,
382 content,
383 entity,
384 }))
385 }
386}
387
388pub async fn find_by_id6(
389 configuration: &configuration::Configuration,
390 id: &str,
391) -> Result<models::FileUpload, Error<FindById6Error>> {
392 let p_query_id = id;
394
395 let uri_str = format!("{}/api/resource/find-by-id", configuration.base_path);
396 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
397
398 req_builder = req_builder.query(&[("id", &p_query_id.to_string())]);
399 if let Some(ref user_agent) = configuration.user_agent {
400 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
401 }
402 if let Some(ref token) = configuration.bearer_access_token {
403 req_builder = req_builder.bearer_auth(token.to_owned());
404 };
405
406 let req = req_builder.build()?;
407 let resp = configuration.client.execute(req).await?;
408
409 let status = resp.status();
410 let content_type = resp
411 .headers()
412 .get("content-type")
413 .and_then(|v| v.to_str().ok())
414 .unwrap_or("application/octet-stream");
415 let content_type = super::ContentType::from(content_type);
416
417 if !status.is_client_error() && !status.is_server_error() {
418 let content = resp.text().await?;
419 match content_type {
420 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
421 ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FileUpload`"))),
422 ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::FileUpload`")))),
423 }
424 } else {
425 let content = resp.text().await?;
426 let entity: Option<FindById6Error> = serde_json::from_str(&content).ok();
427 Err(Error::ResponseError(ResponseContent {
428 status,
429 content,
430 entity,
431 }))
432 }
433}
434
435pub async fn find_by_id_public(
436 configuration: &configuration::Configuration,
437 id: &str,
438) -> Result<models::FileUpload, Error<FindByIdPublicError>> {
439 let p_query_id = id;
441
442 let uri_str = format!("{}/api/resource/public/find-by-id", configuration.base_path);
443 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
444
445 req_builder = req_builder.query(&[("id", &p_query_id.to_string())]);
446 if let Some(ref user_agent) = configuration.user_agent {
447 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
448 }
449 if let Some(ref token) = configuration.bearer_access_token {
450 req_builder = req_builder.bearer_auth(token.to_owned());
451 };
452
453 let req = req_builder.build()?;
454 let resp = configuration.client.execute(req).await?;
455
456 let status = resp.status();
457 let content_type = resp
458 .headers()
459 .get("content-type")
460 .and_then(|v| v.to_str().ok())
461 .unwrap_or("application/octet-stream");
462 let content_type = super::ContentType::from(content_type);
463
464 if !status.is_client_error() && !status.is_server_error() {
465 let content = resp.text().await?;
466 match content_type {
467 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
468 ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FileUpload`"))),
469 ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::FileUpload`")))),
470 }
471 } else {
472 let content = resp.text().await?;
473 let entity: Option<FindByIdPublicError> = serde_json::from_str(&content).ok();
474 Err(Error::ResponseError(ResponseContent {
475 status,
476 content,
477 entity,
478 }))
479 }
480}
481
482pub async fn find_by_ids4(
483 configuration: &configuration::Configuration,
484 id: Vec<String>,
485) -> Result<Vec<models::FileUpload>, Error<FindByIds4Error>> {
486 let p_query_id = id;
488
489 let uri_str = format!("{}/api/resource/find-by-ids", configuration.base_path);
490 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
491
492 req_builder = match "multi" {
493 "multi" => req_builder.query(
494 &p_query_id
495 .into_iter()
496 .map(|p| ("id".to_owned(), p.to_string()))
497 .collect::<Vec<(std::string::String, std::string::String)>>(),
498 ),
499 _ => req_builder.query(&[(
500 "id",
501 &p_query_id
502 .into_iter()
503 .map(|p| p.to_string())
504 .collect::<Vec<String>>()
505 .join(",")
506 .to_string(),
507 )]),
508 };
509 if let Some(ref user_agent) = configuration.user_agent {
510 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
511 }
512 if let Some(ref token) = configuration.bearer_access_token {
513 req_builder = req_builder.bearer_auth(token.to_owned());
514 };
515
516 let req = req_builder.build()?;
517 let resp = configuration.client.execute(req).await?;
518
519 let status = resp.status();
520 let content_type = resp
521 .headers()
522 .get("content-type")
523 .and_then(|v| v.to_str().ok())
524 .unwrap_or("application/octet-stream");
525 let content_type = super::ContentType::from(content_type);
526
527 if !status.is_client_error() && !status.is_server_error() {
528 let content = resp.text().await?;
529 match content_type {
530 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
531 ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::FileUpload>`"))),
532 ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::FileUpload>`")))),
533 }
534 } else {
535 let content = resp.text().await?;
536 let entity: Option<FindByIds4Error> = serde_json::from_str(&content).ok();
537 Err(Error::ResponseError(ResponseContent {
538 status,
539 content,
540 entity,
541 }))
542 }
543}
544
545pub async fn get_correlation_links(
546 configuration: &configuration::Configuration,
547) -> Result<std::collections::HashMap<String, String>, Error<GetCorrelationLinksError>> {
548 let uri_str = format!("{}/api/resource/correlation-links", configuration.base_path);
549 let mut req_builder = configuration
550 .client
551 .request(reqwest::Method::POST, &uri_str);
552
553 if let Some(ref user_agent) = configuration.user_agent {
554 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
555 }
556 if let Some(ref token) = configuration.bearer_access_token {
557 req_builder = req_builder.bearer_auth(token.to_owned());
558 };
559
560 let req = req_builder.build()?;
561 let resp = configuration.client.execute(req).await?;
562
563 let status = resp.status();
564 let content_type = resp
565 .headers()
566 .get("content-type")
567 .and_then(|v| v.to_str().ok())
568 .unwrap_or("application/octet-stream");
569 let content_type = super::ContentType::from(content_type);
570
571 if !status.is_client_error() && !status.is_server_error() {
572 let content = resp.text().await?;
573 match content_type {
574 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
575 ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, String>`"))),
576 ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, String>`")))),
577 }
578 } else {
579 let content = resp.text().await?;
580 let entity: Option<GetCorrelationLinksError> = serde_json::from_str(&content).ok();
581 Err(Error::ResponseError(ResponseContent {
582 status,
583 content,
584 entity,
585 }))
586 }
587}
588
589pub async fn public_download(
590 configuration: &configuration::Configuration,
591 id: &str,
592) -> Result<reqwest::Response, Error<PublicDownloadError>> {
593 let p_path_id = id;
595
596 let uri_str = format!(
597 "{}/api/resource/public/download/{id}",
598 configuration.base_path,
599 id = crate::apis::urlencode(p_path_id)
600 );
601 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
602
603 if let Some(ref user_agent) = configuration.user_agent {
604 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
605 }
606 if let Some(ref token) = configuration.bearer_access_token {
607 req_builder = req_builder.bearer_auth(token.to_owned());
608 };
609
610 let req = req_builder.build()?;
611 let resp = configuration.client.execute(req).await?;
612
613 let status = resp.status();
614
615 if !status.is_client_error() && !status.is_server_error() {
616 Ok(resp)
617 } else {
618 let content = resp.text().await?;
619 let entity: Option<PublicDownloadError> = serde_json::from_str(&content).ok();
620 Err(Error::ResponseError(ResponseContent {
621 status,
622 content,
623 entity,
624 }))
625 }
626}
627
628pub async fn toggle_bookmarked(
629 configuration: &configuration::Configuration,
630 id: &str,
631) -> Result<models::FileUpload, Error<ToggleBookmarkedError>> {
632 let p_query_id = id;
634
635 let uri_str = format!("{}/api/resource/toggle-bookmarked", configuration.base_path);
636 let mut req_builder = configuration
637 .client
638 .request(reqwest::Method::POST, &uri_str);
639
640 req_builder = req_builder.query(&[("id", &p_query_id.to_string())]);
641 if let Some(ref user_agent) = configuration.user_agent {
642 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
643 }
644 if let Some(ref token) = configuration.bearer_access_token {
645 req_builder = req_builder.bearer_auth(token.to_owned());
646 };
647
648 let req = req_builder.build()?;
649 let resp = configuration.client.execute(req).await?;
650
651 let status = resp.status();
652 let content_type = resp
653 .headers()
654 .get("content-type")
655 .and_then(|v| v.to_str().ok())
656 .unwrap_or("application/octet-stream");
657 let content_type = super::ContentType::from(content_type);
658
659 if !status.is_client_error() && !status.is_server_error() {
660 let content = resp.text().await?;
661 match content_type {
662 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
663 ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FileUpload`"))),
664 ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::FileUpload`")))),
665 }
666 } else {
667 let content = resp.text().await?;
668 let entity: Option<ToggleBookmarkedError> = serde_json::from_str(&content).ok();
669 Err(Error::ResponseError(ResponseContent {
670 status,
671 content,
672 entity,
673 }))
674 }
675}
676
677pub async fn upload(
678 configuration: &configuration::Configuration,
679 file: std::path::PathBuf,
680 correlation_id: Option<&str>,
681 public_resource: Option<bool>,
682) -> Result<models::FileUpload, Error<UploadError>> {
683 let p_form_file = file;
685 let p_query_correlation_id = correlation_id;
686 let p_query_public_resource = public_resource;
687
688 let uri_str = format!("{}/api/resource/upload", configuration.base_path);
689 let mut req_builder = configuration
690 .client
691 .request(reqwest::Method::POST, &uri_str);
692
693 if let Some(ref param_value) = p_query_correlation_id {
694 req_builder = req_builder.query(&[("correlationId", ¶m_value.to_string())]);
695 }
696 if let Some(ref param_value) = p_query_public_resource {
697 req_builder = req_builder.query(&[("publicResource", ¶m_value.to_string())]);
698 }
699 if let Some(ref user_agent) = configuration.user_agent {
700 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
701 }
702 if let Some(ref token) = configuration.bearer_access_token {
703 req_builder = req_builder.bearer_auth(token.to_owned());
704 };
705 let multipart_form = reqwest::multipart::Form::new();
706 req_builder = req_builder.multipart(multipart_form);
708
709 let req = req_builder.build()?;
710 let resp = configuration.client.execute(req).await?;
711
712 let status = resp.status();
713 let content_type = resp
714 .headers()
715 .get("content-type")
716 .and_then(|v| v.to_str().ok())
717 .unwrap_or("application/octet-stream");
718 let content_type = super::ContentType::from(content_type);
719
720 if !status.is_client_error() && !status.is_server_error() {
721 let content = resp.text().await?;
722 match content_type {
723 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
724 ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FileUpload`"))),
725 ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::FileUpload`")))),
726 }
727 } else {
728 let content = resp.text().await?;
729 let entity: Option<UploadError> = serde_json::from_str(&content).ok();
730 Err(Error::ResponseError(ResponseContent {
731 status,
732 content,
733 entity,
734 }))
735 }
736}