1use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16use tokio::fs::File as TokioFile;
17use tokio_util::codec::{BytesCodec, FramedRead};
18
19
20#[derive(Debug, Clone, Serialize, Deserialize)]
22#[serde(untagged)]
23pub enum BulkDeleteFilesError {
24 Status400(models::ApiError),
25 Status401(models::ApiError),
26 UnknownValue(serde_json::Value),
27}
28
29#[derive(Debug, Clone, Serialize, Deserialize)]
31#[serde(untagged)]
32pub enum BulkMoveFilesError {
33 Status400(models::ApiError),
34 Status401(models::ApiError),
35 UnknownValue(serde_json::Value),
36}
37
38#[derive(Debug, Clone, Serialize, Deserialize)]
40#[serde(untagged)]
41pub enum CommitChunkedUploadError {
42 Status400(models::ApiError),
43 Status401(models::ApiError),
44 UnknownValue(serde_json::Value),
45}
46
47#[derive(Debug, Clone, Serialize, Deserialize)]
49#[serde(untagged)]
50pub enum CreateFileFolderError {
51 Status400(models::CreateNote400Response),
52 Status401(models::ApiError),
53 UnknownValue(serde_json::Value),
54}
55
56#[derive(Debug, Clone, Serialize, Deserialize)]
58#[serde(untagged)]
59pub enum DeleteFileError {
60 Status401(models::ApiError),
61 Status404(models::ApiError),
62 UnknownValue(serde_json::Value),
63}
64
65#[derive(Debug, Clone, Serialize, Deserialize)]
67#[serde(untagged)]
68pub enum ExtractFileTextError {
69 Status401(models::ApiError),
70 Status404(models::ApiError),
71 Status422(models::ApiError),
72 UnknownValue(serde_json::Value),
73}
74
75#[derive(Debug, Clone, Serialize, Deserialize)]
77#[serde(untagged)]
78pub enum GetChunkedFileManifestError {
79 Status401(models::ApiError),
80 Status404(models::ApiError),
81 UnknownValue(serde_json::Value),
82}
83
84#[derive(Debug, Clone, Serialize, Deserialize)]
86#[serde(untagged)]
87pub enum GetFileError {
88 Status401(models::ApiError),
89 Status404(models::ApiError),
90 UnknownValue(serde_json::Value),
91}
92
93#[derive(Debug, Clone, Serialize, Deserialize)]
95#[serde(untagged)]
96pub enum GetFileDownloadUrlError {
97 Status401(models::ApiError),
98 Status404(models::ApiError),
99 UnknownValue(serde_json::Value),
100}
101
102#[derive(Debug, Clone, Serialize, Deserialize)]
104#[serde(untagged)]
105pub enum InitChunkedUploadError {
106 Status400(models::ApiError),
107 Status401(models::ApiError),
108 UnknownValue(serde_json::Value),
109}
110
111#[derive(Debug, Clone, Serialize, Deserialize)]
113#[serde(untagged)]
114pub enum ListFileFoldersError {
115 Status401(models::ApiError),
116 UnknownValue(serde_json::Value),
117}
118
119#[derive(Debug, Clone, Serialize, Deserialize)]
121#[serde(untagged)]
122pub enum ListFilesError {
123 Status401(models::ApiError),
124 Status500(models::ApiError),
125 UnknownValue(serde_json::Value),
126}
127
128#[derive(Debug, Clone, Serialize, Deserialize)]
130#[serde(untagged)]
131pub enum ListFilesAndFoldersError {
132 Status401(models::ApiError),
133 UnknownValue(serde_json::Value),
134}
135
136#[derive(Debug, Clone, Serialize, Deserialize)]
138#[serde(untagged)]
139pub enum MoveFileError {
140 Status400(models::ApiError),
141 Status401(models::ApiError),
142 Status404(models::ApiError),
143 UnknownValue(serde_json::Value),
144}
145
146#[derive(Debug, Clone, Serialize, Deserialize)]
148#[serde(untagged)]
149pub enum SearchFilesError {
150 Status401(models::ApiError),
151 UnknownValue(serde_json::Value),
152}
153
154#[derive(Debug, Clone, Serialize, Deserialize)]
156#[serde(untagged)]
157pub enum UpdateFileError {
158 Status400(models::ApiError),
159 Status401(models::ApiError),
160 Status404(models::ApiError),
161 UnknownValue(serde_json::Value),
162}
163
164#[derive(Debug, Clone, Serialize, Deserialize)]
166#[serde(untagged)]
167pub enum UploadChunkedBlockError {
168 Status400(models::ApiError),
169 Status401(models::ApiError),
170 UnknownValue(serde_json::Value),
171}
172
173#[derive(Debug, Clone, Serialize, Deserialize)]
175#[serde(untagged)]
176pub enum UploadFileError {
177 Status400(models::CreateNote400Response),
178 Status401(models::ApiError),
179 Status402(models::QuotaExceededError),
180 Status500(models::ApiError),
181 UnknownValue(serde_json::Value),
182}
183
184#[derive(Debug, Clone, Serialize, Deserialize)]
186#[serde(untagged)]
187pub enum UploadFileBase64Error {
188 Status400(models::CreateNote400Response),
189 Status401(models::ApiError),
190 Status402(models::QuotaExceededError),
191 Status500(models::ApiError),
192 UnknownValue(serde_json::Value),
193}
194
195#[derive(Debug, Clone, Serialize, Deserialize)]
197#[serde(untagged)]
198pub enum WorkspaceCommitChunkedUploadError {
199 Status401(models::ApiError),
200 Status403(models::ApiError),
201 UnknownValue(serde_json::Value),
202}
203
204#[derive(Debug, Clone, Serialize, Deserialize)]
206#[serde(untagged)]
207pub enum WorkspaceCreateFileFolderError {
208 Status401(models::ApiError),
209 Status403(models::ApiError),
210 UnknownValue(serde_json::Value),
211}
212
213#[derive(Debug, Clone, Serialize, Deserialize)]
215#[serde(untagged)]
216pub enum WorkspaceDeleteFileError {
217 Status401(models::ApiError),
218 Status403(models::ApiError),
219 UnknownValue(serde_json::Value),
220}
221
222#[derive(Debug, Clone, Serialize, Deserialize)]
224#[serde(untagged)]
225pub enum WorkspaceGetFileError {
226 Status401(models::ApiError),
227 Status403(models::ApiError),
228 Status404(models::ApiError),
229 UnknownValue(serde_json::Value),
230}
231
232#[derive(Debug, Clone, Serialize, Deserialize)]
234#[serde(untagged)]
235pub enum WorkspaceGetFileDownloadError {
236 Status401(models::ApiError),
237 Status403(models::ApiError),
238 Status404(models::ApiError),
239 UnknownValue(serde_json::Value),
240}
241
242#[derive(Debug, Clone, Serialize, Deserialize)]
244#[serde(untagged)]
245pub enum WorkspaceGetFileManifestError {
246 Status401(models::ApiError),
247 Status403(models::ApiError),
248 Status404(models::ApiError),
249 UnknownValue(serde_json::Value),
250}
251
252#[derive(Debug, Clone, Serialize, Deserialize)]
254#[serde(untagged)]
255pub enum WorkspaceInitChunkedUploadError {
256 Status401(models::ApiError),
257 Status403(models::ApiError),
258 UnknownValue(serde_json::Value),
259}
260
261#[derive(Debug, Clone, Serialize, Deserialize)]
263#[serde(untagged)]
264pub enum WorkspaceListFileFoldersError {
265 Status401(models::ApiError),
266 Status403(models::ApiError),
267 UnknownValue(serde_json::Value),
268}
269
270#[derive(Debug, Clone, Serialize, Deserialize)]
272#[serde(untagged)]
273pub enum WorkspaceListFilesError {
274 Status401(models::ApiError),
275 Status403(models::ApiError),
276 UnknownValue(serde_json::Value),
277}
278
279#[derive(Debug, Clone, Serialize, Deserialize)]
281#[serde(untagged)]
282pub enum WorkspaceMoveFileError {
283 Status401(models::ApiError),
284 Status403(models::ApiError),
285 UnknownValue(serde_json::Value),
286}
287
288#[derive(Debug, Clone, Serialize, Deserialize)]
290#[serde(untagged)]
291pub enum WorkspaceUpdateFileError {
292 Status401(models::ApiError),
293 Status403(models::ApiError),
294 UnknownValue(serde_json::Value),
295}
296
297#[derive(Debug, Clone, Serialize, Deserialize)]
299#[serde(untagged)]
300pub enum WorkspaceUploadChunkedBlockError {
301 Status401(models::ApiError),
302 Status403(models::ApiError),
303 UnknownValue(serde_json::Value),
304}
305
306#[derive(Debug, Clone, Serialize, Deserialize)]
308#[serde(untagged)]
309pub enum WorkspaceUploadFileError {
310 Status401(models::ApiError),
311 Status403(models::ApiError),
312 UnknownValue(serde_json::Value),
313}
314
315#[derive(Debug, Clone, Serialize, Deserialize)]
317#[serde(untagged)]
318pub enum WorkspaceUploadFileBase64Error {
319 Status401(models::ApiError),
320 Status403(models::ApiError),
321 UnknownValue(serde_json::Value),
322}
323
324
325pub async fn bulk_delete_files(configuration: &configuration::Configuration, bulk_delete_files_request: models::BulkDeleteFilesRequest) -> Result<models::BulkFilesResponse, Error<BulkDeleteFilesError>> {
326 let p_body_bulk_delete_files_request = bulk_delete_files_request;
328
329 let uri_str = format!("{}/v1/files/delete", configuration.base_path);
330 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
331
332 if let Some(ref user_agent) = configuration.user_agent {
333 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
334 }
335 if let Some(ref token) = configuration.bearer_access_token {
336 req_builder = req_builder.bearer_auth(token.to_owned());
337 };
338 req_builder = req_builder.json(&p_body_bulk_delete_files_request);
339
340 let req = req_builder.build()?;
341 let resp = configuration.client.execute(req).await?;
342
343 let status = resp.status();
344 let content_type = resp
345 .headers()
346 .get("content-type")
347 .and_then(|v| v.to_str().ok())
348 .unwrap_or("application/octet-stream");
349 let content_type = super::ContentType::from(content_type);
350
351 if !status.is_client_error() && !status.is_server_error() {
352 let content = resp.text().await?;
353 match content_type {
354 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
355 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BulkFilesResponse`"))),
356 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::BulkFilesResponse`")))),
357 }
358 } else {
359 let content = resp.text().await?;
360 let entity: Option<BulkDeleteFilesError> = serde_json::from_str(&content).ok();
361 Err(Error::ResponseError(ResponseContent { status, content, entity }))
362 }
363}
364
365pub async fn bulk_move_files(configuration: &configuration::Configuration, bulk_move_files_request: models::BulkMoveFilesRequest) -> Result<models::BulkFilesResponse, Error<BulkMoveFilesError>> {
366 let p_body_bulk_move_files_request = bulk_move_files_request;
368
369 let uri_str = format!("{}/v1/files/move", configuration.base_path);
370 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
371
372 if let Some(ref user_agent) = configuration.user_agent {
373 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
374 }
375 if let Some(ref token) = configuration.bearer_access_token {
376 req_builder = req_builder.bearer_auth(token.to_owned());
377 };
378 req_builder = req_builder.json(&p_body_bulk_move_files_request);
379
380 let req = req_builder.build()?;
381 let resp = configuration.client.execute(req).await?;
382
383 let status = resp.status();
384 let content_type = resp
385 .headers()
386 .get("content-type")
387 .and_then(|v| v.to_str().ok())
388 .unwrap_or("application/octet-stream");
389 let content_type = super::ContentType::from(content_type);
390
391 if !status.is_client_error() && !status.is_server_error() {
392 let content = resp.text().await?;
393 match content_type {
394 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
395 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BulkFilesResponse`"))),
396 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::BulkFilesResponse`")))),
397 }
398 } else {
399 let content = resp.text().await?;
400 let entity: Option<BulkMoveFilesError> = serde_json::from_str(&content).ok();
401 Err(Error::ResponseError(ResponseContent { status, content, entity }))
402 }
403}
404
405pub async fn commit_chunked_upload(configuration: &configuration::Configuration, commit_chunked_upload_request: models::CommitChunkedUploadRequest) -> Result<models::CommitChunkedUploadResponse, Error<CommitChunkedUploadError>> {
406 let p_body_commit_chunked_upload_request = commit_chunked_upload_request;
408
409 let uri_str = format!("{}/v1/files/upload/chunked/commit", configuration.base_path);
410 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
411
412 if let Some(ref user_agent) = configuration.user_agent {
413 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
414 }
415 if let Some(ref token) = configuration.bearer_access_token {
416 req_builder = req_builder.bearer_auth(token.to_owned());
417 };
418 req_builder = req_builder.json(&p_body_commit_chunked_upload_request);
419
420 let req = req_builder.build()?;
421 let resp = configuration.client.execute(req).await?;
422
423 let status = resp.status();
424 let content_type = resp
425 .headers()
426 .get("content-type")
427 .and_then(|v| v.to_str().ok())
428 .unwrap_or("application/octet-stream");
429 let content_type = super::ContentType::from(content_type);
430
431 if !status.is_client_error() && !status.is_server_error() {
432 let content = resp.text().await?;
433 match content_type {
434 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
435 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CommitChunkedUploadResponse`"))),
436 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::CommitChunkedUploadResponse`")))),
437 }
438 } else {
439 let content = resp.text().await?;
440 let entity: Option<CommitChunkedUploadError> = serde_json::from_str(&content).ok();
441 Err(Error::ResponseError(ResponseContent { status, content, entity }))
442 }
443}
444
445pub async fn create_file_folder(configuration: &configuration::Configuration, create_folder_request: models::CreateFolderRequest, account_id: Option<&str>, provider: Option<&str>, x_workspace_id: Option<&str>) -> Result<models::Folder, Error<CreateFileFolderError>> {
446 let p_body_create_folder_request = create_folder_request;
448 let p_query_account_id = account_id;
449 let p_query_provider = provider;
450 let p_header_x_workspace_id = x_workspace_id;
451
452 let uri_str = format!("{}/v1/files/folders", configuration.base_path);
453 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
454
455 if let Some(ref param_value) = p_query_account_id {
456 req_builder = req_builder.query(&[("accountId", ¶m_value.to_string())]);
457 }
458 if let Some(ref param_value) = p_query_provider {
459 req_builder = req_builder.query(&[("provider", ¶m_value.to_string())]);
460 }
461 if let Some(ref user_agent) = configuration.user_agent {
462 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
463 }
464 if let Some(param_value) = p_header_x_workspace_id {
465 req_builder = req_builder.header("X-Workspace-ID", param_value.to_string());
466 }
467 if let Some(ref token) = configuration.bearer_access_token {
468 req_builder = req_builder.bearer_auth(token.to_owned());
469 };
470 req_builder = req_builder.json(&p_body_create_folder_request);
471
472 let req = req_builder.build()?;
473 let resp = configuration.client.execute(req).await?;
474
475 let status = resp.status();
476 let content_type = resp
477 .headers()
478 .get("content-type")
479 .and_then(|v| v.to_str().ok())
480 .unwrap_or("application/octet-stream");
481 let content_type = super::ContentType::from(content_type);
482
483 if !status.is_client_error() && !status.is_server_error() {
484 let content = resp.text().await?;
485 match content_type {
486 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
487 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Folder`"))),
488 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::Folder`")))),
489 }
490 } else {
491 let content = resp.text().await?;
492 let entity: Option<CreateFileFolderError> = serde_json::from_str(&content).ok();
493 Err(Error::ResponseError(ResponseContent { status, content, entity }))
494 }
495}
496
497pub async fn delete_file(configuration: &configuration::Configuration, id: &str, account_id: Option<&str>, x_workspace_id: Option<&str>) -> Result<(), Error<DeleteFileError>> {
498 let p_path_id = id;
500 let p_query_account_id = account_id;
501 let p_header_x_workspace_id = x_workspace_id;
502
503 let uri_str = format!("{}/v1/files/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
504 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
505
506 if let Some(ref param_value) = p_query_account_id {
507 req_builder = req_builder.query(&[("accountId", ¶m_value.to_string())]);
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(param_value) = p_header_x_workspace_id {
513 req_builder = req_builder.header("X-Workspace-ID", param_value.to_string());
514 }
515 if let Some(ref token) = configuration.bearer_access_token {
516 req_builder = req_builder.bearer_auth(token.to_owned());
517 };
518
519 let req = req_builder.build()?;
520 let resp = configuration.client.execute(req).await?;
521
522 let status = resp.status();
523
524 if !status.is_client_error() && !status.is_server_error() {
525 Ok(())
526 } else {
527 let content = resp.text().await?;
528 let entity: Option<DeleteFileError> = serde_json::from_str(&content).ok();
529 Err(Error::ResponseError(ResponseContent { status, content, entity }))
530 }
531}
532
533pub async fn extract_file_text(configuration: &configuration::Configuration, id: &str, account_id: Option<&str>, x_workspace_id: Option<&str>, page_start: Option<i32>, page_end: Option<i32>, max_chars: Option<i32>) -> Result<models::ExtractTextResult, Error<ExtractFileTextError>> {
534 let p_path_id = id;
536 let p_query_account_id = account_id;
537 let p_header_x_workspace_id = x_workspace_id;
538 let p_query_page_start = page_start;
539 let p_query_page_end = page_end;
540 let p_query_max_chars = max_chars;
541
542 let uri_str = format!("{}/v1/files/{id}/extract-text", configuration.base_path, id=crate::apis::urlencode(p_path_id));
543 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
544
545 if let Some(ref param_value) = p_query_account_id {
546 req_builder = req_builder.query(&[("accountId", ¶m_value.to_string())]);
547 }
548 if let Some(ref param_value) = p_query_page_start {
549 req_builder = req_builder.query(&[("pageStart", ¶m_value.to_string())]);
550 }
551 if let Some(ref param_value) = p_query_page_end {
552 req_builder = req_builder.query(&[("pageEnd", ¶m_value.to_string())]);
553 }
554 if let Some(ref param_value) = p_query_max_chars {
555 req_builder = req_builder.query(&[("maxChars", ¶m_value.to_string())]);
556 }
557 if let Some(ref user_agent) = configuration.user_agent {
558 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
559 }
560 if let Some(param_value) = p_header_x_workspace_id {
561 req_builder = req_builder.header("X-Workspace-ID", param_value.to_string());
562 }
563 if let Some(ref token) = configuration.bearer_access_token {
564 req_builder = req_builder.bearer_auth(token.to_owned());
565 };
566
567 let req = req_builder.build()?;
568 let resp = configuration.client.execute(req).await?;
569
570 let status = resp.status();
571 let content_type = resp
572 .headers()
573 .get("content-type")
574 .and_then(|v| v.to_str().ok())
575 .unwrap_or("application/octet-stream");
576 let content_type = super::ContentType::from(content_type);
577
578 if !status.is_client_error() && !status.is_server_error() {
579 let content = resp.text().await?;
580 match content_type {
581 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
582 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ExtractTextResult`"))),
583 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::ExtractTextResult`")))),
584 }
585 } else {
586 let content = resp.text().await?;
587 let entity: Option<ExtractFileTextError> = serde_json::from_str(&content).ok();
588 Err(Error::ResponseError(ResponseContent { status, content, entity }))
589 }
590}
591
592pub async fn get_chunked_file_manifest(configuration: &configuration::Configuration, id: &str, account_id: Option<&str>, x_workspace_id: Option<&str>) -> Result<models::ChunkedFileManifest, Error<GetChunkedFileManifestError>> {
594 let p_path_id = id;
596 let p_query_account_id = account_id;
597 let p_header_x_workspace_id = x_workspace_id;
598
599 let uri_str = format!("{}/v1/files/{id}/manifest", configuration.base_path, id=crate::apis::urlencode(p_path_id));
600 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
601
602 if let Some(ref param_value) = p_query_account_id {
603 req_builder = req_builder.query(&[("accountId", ¶m_value.to_string())]);
604 }
605 if let Some(ref user_agent) = configuration.user_agent {
606 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
607 }
608 if let Some(param_value) = p_header_x_workspace_id {
609 req_builder = req_builder.header("X-Workspace-ID", param_value.to_string());
610 }
611 if let Some(ref token) = configuration.bearer_access_token {
612 req_builder = req_builder.bearer_auth(token.to_owned());
613 };
614
615 let req = req_builder.build()?;
616 let resp = configuration.client.execute(req).await?;
617
618 let status = resp.status();
619 let content_type = resp
620 .headers()
621 .get("content-type")
622 .and_then(|v| v.to_str().ok())
623 .unwrap_or("application/octet-stream");
624 let content_type = super::ContentType::from(content_type);
625
626 if !status.is_client_error() && !status.is_server_error() {
627 let content = resp.text().await?;
628 match content_type {
629 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
630 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ChunkedFileManifest`"))),
631 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::ChunkedFileManifest`")))),
632 }
633 } else {
634 let content = resp.text().await?;
635 let entity: Option<GetChunkedFileManifestError> = serde_json::from_str(&content).ok();
636 Err(Error::ResponseError(ResponseContent { status, content, entity }))
637 }
638}
639
640pub async fn get_file(configuration: &configuration::Configuration, id: &str, account_id: Option<&str>, x_workspace_id: Option<&str>) -> Result<models::SpatioFile, Error<GetFileError>> {
641 let p_path_id = id;
643 let p_query_account_id = account_id;
644 let p_header_x_workspace_id = x_workspace_id;
645
646 let uri_str = format!("{}/v1/files/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
647 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
648
649 if let Some(ref param_value) = p_query_account_id {
650 req_builder = req_builder.query(&[("accountId", ¶m_value.to_string())]);
651 }
652 if let Some(ref user_agent) = configuration.user_agent {
653 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
654 }
655 if let Some(param_value) = p_header_x_workspace_id {
656 req_builder = req_builder.header("X-Workspace-ID", param_value.to_string());
657 }
658 if let Some(ref token) = configuration.bearer_access_token {
659 req_builder = req_builder.bearer_auth(token.to_owned());
660 };
661
662 let req = req_builder.build()?;
663 let resp = configuration.client.execute(req).await?;
664
665 let status = resp.status();
666 let content_type = resp
667 .headers()
668 .get("content-type")
669 .and_then(|v| v.to_str().ok())
670 .unwrap_or("application/octet-stream");
671 let content_type = super::ContentType::from(content_type);
672
673 if !status.is_client_error() && !status.is_server_error() {
674 let content = resp.text().await?;
675 match content_type {
676 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
677 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SpatioFile`"))),
678 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::SpatioFile`")))),
679 }
680 } else {
681 let content = resp.text().await?;
682 let entity: Option<GetFileError> = serde_json::from_str(&content).ok();
683 Err(Error::ResponseError(ResponseContent { status, content, entity }))
684 }
685}
686
687pub async fn get_file_download_url(configuration: &configuration::Configuration, id: &str, account_id: Option<&str>, x_workspace_id: Option<&str>) -> Result<models::DownloadFileResponse, Error<GetFileDownloadUrlError>> {
689 let p_path_id = id;
691 let p_query_account_id = account_id;
692 let p_header_x_workspace_id = x_workspace_id;
693
694 let uri_str = format!("{}/v1/files/{id}/download", configuration.base_path, id=crate::apis::urlencode(p_path_id));
695 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
696
697 if let Some(ref param_value) = p_query_account_id {
698 req_builder = req_builder.query(&[("accountId", ¶m_value.to_string())]);
699 }
700 if let Some(ref user_agent) = configuration.user_agent {
701 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
702 }
703 if let Some(param_value) = p_header_x_workspace_id {
704 req_builder = req_builder.header("X-Workspace-ID", param_value.to_string());
705 }
706 if let Some(ref token) = configuration.bearer_access_token {
707 req_builder = req_builder.bearer_auth(token.to_owned());
708 };
709
710 let req = req_builder.build()?;
711 let resp = configuration.client.execute(req).await?;
712
713 let status = resp.status();
714 let content_type = resp
715 .headers()
716 .get("content-type")
717 .and_then(|v| v.to_str().ok())
718 .unwrap_or("application/octet-stream");
719 let content_type = super::ContentType::from(content_type);
720
721 if !status.is_client_error() && !status.is_server_error() {
722 let content = resp.text().await?;
723 match content_type {
724 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
725 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DownloadFileResponse`"))),
726 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::DownloadFileResponse`")))),
727 }
728 } else {
729 let content = resp.text().await?;
730 let entity: Option<GetFileDownloadUrlError> = serde_json::from_str(&content).ok();
731 Err(Error::ResponseError(ResponseContent { status, content, entity }))
732 }
733}
734
735pub async fn init_chunked_upload(configuration: &configuration::Configuration, init_chunked_upload_request: models::InitChunkedUploadRequest) -> Result<models::InitChunkedUploadResponse, Error<InitChunkedUploadError>> {
737 let p_body_init_chunked_upload_request = init_chunked_upload_request;
739
740 let uri_str = format!("{}/v1/files/upload/chunked/init", configuration.base_path);
741 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
742
743 if let Some(ref user_agent) = configuration.user_agent {
744 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
745 }
746 if let Some(ref token) = configuration.bearer_access_token {
747 req_builder = req_builder.bearer_auth(token.to_owned());
748 };
749 req_builder = req_builder.json(&p_body_init_chunked_upload_request);
750
751 let req = req_builder.build()?;
752 let resp = configuration.client.execute(req).await?;
753
754 let status = resp.status();
755 let content_type = resp
756 .headers()
757 .get("content-type")
758 .and_then(|v| v.to_str().ok())
759 .unwrap_or("application/octet-stream");
760 let content_type = super::ContentType::from(content_type);
761
762 if !status.is_client_error() && !status.is_server_error() {
763 let content = resp.text().await?;
764 match content_type {
765 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
766 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::InitChunkedUploadResponse`"))),
767 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::InitChunkedUploadResponse`")))),
768 }
769 } else {
770 let content = resp.text().await?;
771 let entity: Option<InitChunkedUploadError> = serde_json::from_str(&content).ok();
772 Err(Error::ResponseError(ResponseContent { status, content, entity }))
773 }
774}
775
776pub async fn list_file_folders(configuration: &configuration::Configuration, account_id: Option<&str>, provider: Option<&str>, x_workspace_id: Option<&str>, parent_id: Option<&str>, workspace_id: Option<&str>, organization_id: Option<&str>, limit: Option<i32>, offset: Option<i32>) -> Result<models::FolderListEnvelope, Error<ListFileFoldersError>> {
777 let p_query_account_id = account_id;
779 let p_query_provider = provider;
780 let p_header_x_workspace_id = x_workspace_id;
781 let p_query_parent_id = parent_id;
782 let p_query_workspace_id = workspace_id;
783 let p_query_organization_id = organization_id;
784 let p_query_limit = limit;
785 let p_query_offset = offset;
786
787 let uri_str = format!("{}/v1/files/folders", configuration.base_path);
788 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
789
790 if let Some(ref param_value) = p_query_account_id {
791 req_builder = req_builder.query(&[("accountId", ¶m_value.to_string())]);
792 }
793 if let Some(ref param_value) = p_query_provider {
794 req_builder = req_builder.query(&[("provider", ¶m_value.to_string())]);
795 }
796 if let Some(ref param_value) = p_query_parent_id {
797 req_builder = req_builder.query(&[("parentId", ¶m_value.to_string())]);
798 }
799 if let Some(ref param_value) = p_query_workspace_id {
800 req_builder = req_builder.query(&[("workspaceId", ¶m_value.to_string())]);
801 }
802 if let Some(ref param_value) = p_query_organization_id {
803 req_builder = req_builder.query(&[("organizationId", ¶m_value.to_string())]);
804 }
805 if let Some(ref param_value) = p_query_limit {
806 req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
807 }
808 if let Some(ref param_value) = p_query_offset {
809 req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]);
810 }
811 if let Some(ref user_agent) = configuration.user_agent {
812 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
813 }
814 if let Some(param_value) = p_header_x_workspace_id {
815 req_builder = req_builder.header("X-Workspace-ID", param_value.to_string());
816 }
817 if let Some(ref token) = configuration.bearer_access_token {
818 req_builder = req_builder.bearer_auth(token.to_owned());
819 };
820
821 let req = req_builder.build()?;
822 let resp = configuration.client.execute(req).await?;
823
824 let status = resp.status();
825 let content_type = resp
826 .headers()
827 .get("content-type")
828 .and_then(|v| v.to_str().ok())
829 .unwrap_or("application/octet-stream");
830 let content_type = super::ContentType::from(content_type);
831
832 if !status.is_client_error() && !status.is_server_error() {
833 let content = resp.text().await?;
834 match content_type {
835 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
836 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FolderListEnvelope`"))),
837 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::FolderListEnvelope`")))),
838 }
839 } else {
840 let content = resp.text().await?;
841 let entity: Option<ListFileFoldersError> = serde_json::from_str(&content).ok();
842 Err(Error::ResponseError(ResponseContent { status, content, entity }))
843 }
844}
845
846pub async fn list_files(configuration: &configuration::Configuration, account_id: Option<&str>, provider: Option<&str>, x_workspace_id: Option<&str>, folder_id: Option<&str>, workspace_id: Option<&str>, organization_id: Option<&str>, limit: Option<i32>, offset: Option<i32>, sort_by: Option<&str>, sort_order: Option<&str>) -> Result<models::FileListEnvelope, Error<ListFilesError>> {
848 let p_query_account_id = account_id;
850 let p_query_provider = provider;
851 let p_header_x_workspace_id = x_workspace_id;
852 let p_query_folder_id = folder_id;
853 let p_query_workspace_id = workspace_id;
854 let p_query_organization_id = organization_id;
855 let p_query_limit = limit;
856 let p_query_offset = offset;
857 let p_query_sort_by = sort_by;
858 let p_query_sort_order = sort_order;
859
860 let uri_str = format!("{}/v1/files", configuration.base_path);
861 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
862
863 if let Some(ref param_value) = p_query_account_id {
864 req_builder = req_builder.query(&[("accountId", ¶m_value.to_string())]);
865 }
866 if let Some(ref param_value) = p_query_provider {
867 req_builder = req_builder.query(&[("provider", ¶m_value.to_string())]);
868 }
869 if let Some(ref param_value) = p_query_folder_id {
870 req_builder = req_builder.query(&[("folderId", ¶m_value.to_string())]);
871 }
872 if let Some(ref param_value) = p_query_workspace_id {
873 req_builder = req_builder.query(&[("workspaceId", ¶m_value.to_string())]);
874 }
875 if let Some(ref param_value) = p_query_organization_id {
876 req_builder = req_builder.query(&[("organizationId", ¶m_value.to_string())]);
877 }
878 if let Some(ref param_value) = p_query_limit {
879 req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
880 }
881 if let Some(ref param_value) = p_query_offset {
882 req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]);
883 }
884 if let Some(ref param_value) = p_query_sort_by {
885 req_builder = req_builder.query(&[("sortBy", ¶m_value.to_string())]);
886 }
887 if let Some(ref param_value) = p_query_sort_order {
888 req_builder = req_builder.query(&[("sortOrder", ¶m_value.to_string())]);
889 }
890 if let Some(ref user_agent) = configuration.user_agent {
891 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
892 }
893 if let Some(param_value) = p_header_x_workspace_id {
894 req_builder = req_builder.header("X-Workspace-ID", param_value.to_string());
895 }
896 if let Some(ref token) = configuration.bearer_access_token {
897 req_builder = req_builder.bearer_auth(token.to_owned());
898 };
899
900 let req = req_builder.build()?;
901 let resp = configuration.client.execute(req).await?;
902
903 let status = resp.status();
904 let content_type = resp
905 .headers()
906 .get("content-type")
907 .and_then(|v| v.to_str().ok())
908 .unwrap_or("application/octet-stream");
909 let content_type = super::ContentType::from(content_type);
910
911 if !status.is_client_error() && !status.is_server_error() {
912 let content = resp.text().await?;
913 match content_type {
914 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
915 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FileListEnvelope`"))),
916 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::FileListEnvelope`")))),
917 }
918 } else {
919 let content = resp.text().await?;
920 let entity: Option<ListFilesError> = serde_json::from_str(&content).ok();
921 Err(Error::ResponseError(ResponseContent { status, content, entity }))
922 }
923}
924
925pub async fn list_files_and_folders(configuration: &configuration::Configuration, account_id: Option<&str>, provider: Option<&str>, folder_id: Option<&str>, workspace_id: Option<&str>, organization_id: Option<&str>, limit: Option<i32>, offset: Option<i32>, sort_by: Option<&str>, sort_order: Option<&str>) -> Result<models::FilesAndFoldersResponse, Error<ListFilesAndFoldersError>> {
927 let p_query_account_id = account_id;
929 let p_query_provider = provider;
930 let p_query_folder_id = folder_id;
931 let p_query_workspace_id = workspace_id;
932 let p_query_organization_id = organization_id;
933 let p_query_limit = limit;
934 let p_query_offset = offset;
935 let p_query_sort_by = sort_by;
936 let p_query_sort_order = sort_order;
937
938 let uri_str = format!("{}/v1/files/list", configuration.base_path);
939 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
940
941 if let Some(ref param_value) = p_query_account_id {
942 req_builder = req_builder.query(&[("accountId", ¶m_value.to_string())]);
943 }
944 if let Some(ref param_value) = p_query_provider {
945 req_builder = req_builder.query(&[("provider", ¶m_value.to_string())]);
946 }
947 if let Some(ref param_value) = p_query_folder_id {
948 req_builder = req_builder.query(&[("folderId", ¶m_value.to_string())]);
949 }
950 if let Some(ref param_value) = p_query_workspace_id {
951 req_builder = req_builder.query(&[("workspaceId", ¶m_value.to_string())]);
952 }
953 if let Some(ref param_value) = p_query_organization_id {
954 req_builder = req_builder.query(&[("organizationId", ¶m_value.to_string())]);
955 }
956 if let Some(ref param_value) = p_query_limit {
957 req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
958 }
959 if let Some(ref param_value) = p_query_offset {
960 req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]);
961 }
962 if let Some(ref param_value) = p_query_sort_by {
963 req_builder = req_builder.query(&[("sortBy", ¶m_value.to_string())]);
964 }
965 if let Some(ref param_value) = p_query_sort_order {
966 req_builder = req_builder.query(&[("sortOrder", ¶m_value.to_string())]);
967 }
968 if let Some(ref user_agent) = configuration.user_agent {
969 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
970 }
971 if let Some(ref token) = configuration.bearer_access_token {
972 req_builder = req_builder.bearer_auth(token.to_owned());
973 };
974
975 let req = req_builder.build()?;
976 let resp = configuration.client.execute(req).await?;
977
978 let status = resp.status();
979 let content_type = resp
980 .headers()
981 .get("content-type")
982 .and_then(|v| v.to_str().ok())
983 .unwrap_or("application/octet-stream");
984 let content_type = super::ContentType::from(content_type);
985
986 if !status.is_client_error() && !status.is_server_error() {
987 let content = resp.text().await?;
988 match content_type {
989 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
990 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FilesAndFoldersResponse`"))),
991 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::FilesAndFoldersResponse`")))),
992 }
993 } else {
994 let content = resp.text().await?;
995 let entity: Option<ListFilesAndFoldersError> = serde_json::from_str(&content).ok();
996 Err(Error::ResponseError(ResponseContent { status, content, entity }))
997 }
998}
999
1000pub async fn move_file(configuration: &configuration::Configuration, id: &str, move_file_request: models::MoveFileRequest, account_id: Option<&str>, x_workspace_id: Option<&str>) -> Result<models::MoveFileResponse, Error<MoveFileError>> {
1001 let p_path_id = id;
1003 let p_body_move_file_request = move_file_request;
1004 let p_query_account_id = account_id;
1005 let p_header_x_workspace_id = x_workspace_id;
1006
1007 let uri_str = format!("{}/v1/files/{id}/move", configuration.base_path, id=crate::apis::urlencode(p_path_id));
1008 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1009
1010 if let Some(ref param_value) = p_query_account_id {
1011 req_builder = req_builder.query(&[("accountId", ¶m_value.to_string())]);
1012 }
1013 if let Some(ref user_agent) = configuration.user_agent {
1014 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1015 }
1016 if let Some(param_value) = p_header_x_workspace_id {
1017 req_builder = req_builder.header("X-Workspace-ID", param_value.to_string());
1018 }
1019 if let Some(ref token) = configuration.bearer_access_token {
1020 req_builder = req_builder.bearer_auth(token.to_owned());
1021 };
1022 req_builder = req_builder.json(&p_body_move_file_request);
1023
1024 let req = req_builder.build()?;
1025 let resp = configuration.client.execute(req).await?;
1026
1027 let status = resp.status();
1028 let content_type = resp
1029 .headers()
1030 .get("content-type")
1031 .and_then(|v| v.to_str().ok())
1032 .unwrap_or("application/octet-stream");
1033 let content_type = super::ContentType::from(content_type);
1034
1035 if !status.is_client_error() && !status.is_server_error() {
1036 let content = resp.text().await?;
1037 match content_type {
1038 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1039 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::MoveFileResponse`"))),
1040 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::MoveFileResponse`")))),
1041 }
1042 } else {
1043 let content = resp.text().await?;
1044 let entity: Option<MoveFileError> = serde_json::from_str(&content).ok();
1045 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1046 }
1047}
1048
1049pub async fn search_files(configuration: &configuration::Configuration, query: &str, account_id: Option<&str>, provider: Option<&str>, folder_id: Option<&str>, workspace_id: Option<&str>, organization_id: Option<&str>, limit: Option<i32>, offset: Option<i32>) -> Result<models::SearchFilesResponse, Error<SearchFilesError>> {
1051 let p_query_query = query;
1053 let p_query_account_id = account_id;
1054 let p_query_provider = provider;
1055 let p_query_folder_id = folder_id;
1056 let p_query_workspace_id = workspace_id;
1057 let p_query_organization_id = organization_id;
1058 let p_query_limit = limit;
1059 let p_query_offset = offset;
1060
1061 let uri_str = format!("{}/v1/files/search", configuration.base_path);
1062 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1063
1064 if let Some(ref param_value) = p_query_account_id {
1065 req_builder = req_builder.query(&[("accountId", ¶m_value.to_string())]);
1066 }
1067 if let Some(ref param_value) = p_query_provider {
1068 req_builder = req_builder.query(&[("provider", ¶m_value.to_string())]);
1069 }
1070 req_builder = req_builder.query(&[("query", &p_query_query.to_string())]);
1071 if let Some(ref param_value) = p_query_folder_id {
1072 req_builder = req_builder.query(&[("folderId", ¶m_value.to_string())]);
1073 }
1074 if let Some(ref param_value) = p_query_workspace_id {
1075 req_builder = req_builder.query(&[("workspaceId", ¶m_value.to_string())]);
1076 }
1077 if let Some(ref param_value) = p_query_organization_id {
1078 req_builder = req_builder.query(&[("organizationId", ¶m_value.to_string())]);
1079 }
1080 if let Some(ref param_value) = p_query_limit {
1081 req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
1082 }
1083 if let Some(ref param_value) = p_query_offset {
1084 req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]);
1085 }
1086 if let Some(ref user_agent) = configuration.user_agent {
1087 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1088 }
1089 if let Some(ref token) = configuration.bearer_access_token {
1090 req_builder = req_builder.bearer_auth(token.to_owned());
1091 };
1092
1093 let req = req_builder.build()?;
1094 let resp = configuration.client.execute(req).await?;
1095
1096 let status = resp.status();
1097 let content_type = resp
1098 .headers()
1099 .get("content-type")
1100 .and_then(|v| v.to_str().ok())
1101 .unwrap_or("application/octet-stream");
1102 let content_type = super::ContentType::from(content_type);
1103
1104 if !status.is_client_error() && !status.is_server_error() {
1105 let content = resp.text().await?;
1106 match content_type {
1107 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1108 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SearchFilesResponse`"))),
1109 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::SearchFilesResponse`")))),
1110 }
1111 } else {
1112 let content = resp.text().await?;
1113 let entity: Option<SearchFilesError> = serde_json::from_str(&content).ok();
1114 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1115 }
1116}
1117
1118pub async fn update_file(configuration: &configuration::Configuration, id: &str, update_file_request: models::UpdateFileRequest, account_id: Option<&str>, x_workspace_id: Option<&str>) -> Result<models::SpatioFile, Error<UpdateFileError>> {
1119 let p_path_id = id;
1121 let p_body_update_file_request = update_file_request;
1122 let p_query_account_id = account_id;
1123 let p_header_x_workspace_id = x_workspace_id;
1124
1125 let uri_str = format!("{}/v1/files/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
1126 let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
1127
1128 if let Some(ref param_value) = p_query_account_id {
1129 req_builder = req_builder.query(&[("accountId", ¶m_value.to_string())]);
1130 }
1131 if let Some(ref user_agent) = configuration.user_agent {
1132 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1133 }
1134 if let Some(param_value) = p_header_x_workspace_id {
1135 req_builder = req_builder.header("X-Workspace-ID", param_value.to_string());
1136 }
1137 if let Some(ref token) = configuration.bearer_access_token {
1138 req_builder = req_builder.bearer_auth(token.to_owned());
1139 };
1140 req_builder = req_builder.json(&p_body_update_file_request);
1141
1142 let req = req_builder.build()?;
1143 let resp = configuration.client.execute(req).await?;
1144
1145 let status = resp.status();
1146 let content_type = resp
1147 .headers()
1148 .get("content-type")
1149 .and_then(|v| v.to_str().ok())
1150 .unwrap_or("application/octet-stream");
1151 let content_type = super::ContentType::from(content_type);
1152
1153 if !status.is_client_error() && !status.is_server_error() {
1154 let content = resp.text().await?;
1155 match content_type {
1156 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1157 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SpatioFile`"))),
1158 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::SpatioFile`")))),
1159 }
1160 } else {
1161 let content = resp.text().await?;
1162 let entity: Option<UpdateFileError> = serde_json::from_str(&content).ok();
1163 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1164 }
1165}
1166
1167pub async fn upload_chunked_block(configuration: &configuration::Configuration, session_id: &str, block_hash: &str, block: std::path::PathBuf, block_index: Option<i32>) -> Result<models::UploadChunkedBlockResponse, Error<UploadChunkedBlockError>> {
1168 let p_form_session_id = session_id;
1170 let p_form_block_hash = block_hash;
1171 let p_form_block = block;
1172 let p_form_block_index = block_index;
1173
1174 let uri_str = format!("{}/v1/files/upload/chunked/blocks", configuration.base_path);
1175 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1176
1177 if let Some(ref user_agent) = configuration.user_agent {
1178 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1179 }
1180 if let Some(ref token) = configuration.bearer_access_token {
1181 req_builder = req_builder.bearer_auth(token.to_owned());
1182 };
1183 let mut multipart_form = reqwest::multipart::Form::new();
1184 multipart_form = multipart_form.text("sessionId", p_form_session_id.to_string());
1185 multipart_form = multipart_form.text("blockHash", p_form_block_hash.to_string());
1186 if let Some(param_value) = p_form_block_index {
1187 multipart_form = multipart_form.text("blockIndex", param_value.to_string());
1188 }
1189 let file = TokioFile::open(&p_form_block).await?;
1190 let stream = FramedRead::new(file, BytesCodec::new());
1191 let file_name = p_form_block.file_name().map(|n| n.to_string_lossy().to_string()).unwrap_or_default();
1192 let file_part = reqwest::multipart::Part::stream(reqwest::Body::wrap_stream(stream)).file_name(file_name);
1193 multipart_form = multipart_form.part("block", file_part);
1194 req_builder = req_builder.multipart(multipart_form);
1195
1196 let req = req_builder.build()?;
1197 let resp = configuration.client.execute(req).await?;
1198
1199 let status = resp.status();
1200 let content_type = resp
1201 .headers()
1202 .get("content-type")
1203 .and_then(|v| v.to_str().ok())
1204 .unwrap_or("application/octet-stream");
1205 let content_type = super::ContentType::from(content_type);
1206
1207 if !status.is_client_error() && !status.is_server_error() {
1208 let content = resp.text().await?;
1209 match content_type {
1210 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1211 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UploadChunkedBlockResponse`"))),
1212 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::UploadChunkedBlockResponse`")))),
1213 }
1214 } else {
1215 let content = resp.text().await?;
1216 let entity: Option<UploadChunkedBlockError> = serde_json::from_str(&content).ok();
1217 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1218 }
1219}
1220
1221pub async fn upload_file(configuration: &configuration::Configuration, file: std::path::PathBuf, folder_id: Option<&str>, workspace_id: Option<&str>, organization_id: Option<&str>, account_id: Option<&str>) -> Result<models::SpatioFile, Error<UploadFileError>> {
1223 let p_form_file = file;
1225 let p_form_folder_id = folder_id;
1226 let p_form_workspace_id = workspace_id;
1227 let p_form_organization_id = organization_id;
1228 let p_form_account_id = account_id;
1229
1230 let uri_str = format!("{}/v1/files/upload", configuration.base_path);
1231 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1232
1233 if let Some(ref user_agent) = configuration.user_agent {
1234 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1235 }
1236 if let Some(ref token) = configuration.bearer_access_token {
1237 req_builder = req_builder.bearer_auth(token.to_owned());
1238 };
1239 let mut multipart_form = reqwest::multipart::Form::new();
1240 let file = TokioFile::open(&p_form_file).await?;
1241 let stream = FramedRead::new(file, BytesCodec::new());
1242 let file_name = p_form_file.file_name().map(|n| n.to_string_lossy().to_string()).unwrap_or_default();
1243 let file_part = reqwest::multipart::Part::stream(reqwest::Body::wrap_stream(stream)).file_name(file_name);
1244 multipart_form = multipart_form.part("file", file_part);
1245 if let Some(param_value) = p_form_folder_id {
1246 multipart_form = multipart_form.text("folderId", param_value.to_string());
1247 }
1248 if let Some(param_value) = p_form_workspace_id {
1249 multipart_form = multipart_form.text("workspaceId", param_value.to_string());
1250 }
1251 if let Some(param_value) = p_form_organization_id {
1252 multipart_form = multipart_form.text("organizationId", param_value.to_string());
1253 }
1254 if let Some(param_value) = p_form_account_id {
1255 multipart_form = multipart_form.text("accountId", param_value.to_string());
1256 }
1257 req_builder = req_builder.multipart(multipart_form);
1258
1259 let req = req_builder.build()?;
1260 let resp = configuration.client.execute(req).await?;
1261
1262 let status = resp.status();
1263 let content_type = resp
1264 .headers()
1265 .get("content-type")
1266 .and_then(|v| v.to_str().ok())
1267 .unwrap_or("application/octet-stream");
1268 let content_type = super::ContentType::from(content_type);
1269
1270 if !status.is_client_error() && !status.is_server_error() {
1271 let content = resp.text().await?;
1272 match content_type {
1273 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1274 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SpatioFile`"))),
1275 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::SpatioFile`")))),
1276 }
1277 } else {
1278 let content = resp.text().await?;
1279 let entity: Option<UploadFileError> = serde_json::from_str(&content).ok();
1280 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1281 }
1282}
1283
1284pub async fn upload_file_base64(configuration: &configuration::Configuration, upload_file_base64_request: models::UploadFileBase64Request) -> Result<models::SpatioFile, Error<UploadFileBase64Error>> {
1286 let p_body_upload_file_base64_request = upload_file_base64_request;
1288
1289 let uri_str = format!("{}/v1/files/upload/base64", configuration.base_path);
1290 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1291
1292 if let Some(ref user_agent) = configuration.user_agent {
1293 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1294 }
1295 if let Some(ref token) = configuration.bearer_access_token {
1296 req_builder = req_builder.bearer_auth(token.to_owned());
1297 };
1298 req_builder = req_builder.json(&p_body_upload_file_base64_request);
1299
1300 let req = req_builder.build()?;
1301 let resp = configuration.client.execute(req).await?;
1302
1303 let status = resp.status();
1304 let content_type = resp
1305 .headers()
1306 .get("content-type")
1307 .and_then(|v| v.to_str().ok())
1308 .unwrap_or("application/octet-stream");
1309 let content_type = super::ContentType::from(content_type);
1310
1311 if !status.is_client_error() && !status.is_server_error() {
1312 let content = resp.text().await?;
1313 match content_type {
1314 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1315 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SpatioFile`"))),
1316 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::SpatioFile`")))),
1317 }
1318 } else {
1319 let content = resp.text().await?;
1320 let entity: Option<UploadFileBase64Error> = serde_json::from_str(&content).ok();
1321 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1322 }
1323}
1324
1325pub async fn workspace_commit_chunked_upload(configuration: &configuration::Configuration, org: &str, workspace: &str, request_body: std::collections::HashMap<String, serde_json::Value>) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceCommitChunkedUploadError>> {
1326 let p_path_org = org;
1328 let p_path_workspace = workspace;
1329 let p_body_request_body = request_body;
1330
1331 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/files/upload/chunked/commit", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace));
1332 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1333
1334 if let Some(ref user_agent) = configuration.user_agent {
1335 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1336 }
1337 if let Some(ref token) = configuration.bearer_access_token {
1338 req_builder = req_builder.bearer_auth(token.to_owned());
1339 };
1340 req_builder = req_builder.json(&p_body_request_body);
1341
1342 let req = req_builder.build()?;
1343 let resp = configuration.client.execute(req).await?;
1344
1345 let status = resp.status();
1346 let content_type = resp
1347 .headers()
1348 .get("content-type")
1349 .and_then(|v| v.to_str().ok())
1350 .unwrap_or("application/octet-stream");
1351 let content_type = super::ContentType::from(content_type);
1352
1353 if !status.is_client_error() && !status.is_server_error() {
1354 let content = resp.text().await?;
1355 match content_type {
1356 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1357 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
1358 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
1359 }
1360 } else {
1361 let content = resp.text().await?;
1362 let entity: Option<WorkspaceCommitChunkedUploadError> = serde_json::from_str(&content).ok();
1363 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1364 }
1365}
1366
1367pub async fn workspace_create_file_folder(configuration: &configuration::Configuration, org: &str, workspace: &str, request_body: std::collections::HashMap<String, serde_json::Value>) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceCreateFileFolderError>> {
1368 let p_path_org = org;
1370 let p_path_workspace = workspace;
1371 let p_body_request_body = request_body;
1372
1373 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/files/folders", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace));
1374 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1375
1376 if let Some(ref user_agent) = configuration.user_agent {
1377 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1378 }
1379 if let Some(ref token) = configuration.bearer_access_token {
1380 req_builder = req_builder.bearer_auth(token.to_owned());
1381 };
1382 req_builder = req_builder.json(&p_body_request_body);
1383
1384 let req = req_builder.build()?;
1385 let resp = configuration.client.execute(req).await?;
1386
1387 let status = resp.status();
1388 let content_type = resp
1389 .headers()
1390 .get("content-type")
1391 .and_then(|v| v.to_str().ok())
1392 .unwrap_or("application/octet-stream");
1393 let content_type = super::ContentType::from(content_type);
1394
1395 if !status.is_client_error() && !status.is_server_error() {
1396 let content = resp.text().await?;
1397 match content_type {
1398 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1399 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
1400 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
1401 }
1402 } else {
1403 let content = resp.text().await?;
1404 let entity: Option<WorkspaceCreateFileFolderError> = serde_json::from_str(&content).ok();
1405 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1406 }
1407}
1408
1409pub async fn workspace_delete_file(configuration: &configuration::Configuration, org: &str, workspace: &str, id: &str) -> Result<(), Error<WorkspaceDeleteFileError>> {
1410 let p_path_org = org;
1412 let p_path_workspace = workspace;
1413 let p_path_id = id;
1414
1415 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/files/{id}", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace), id=crate::apis::urlencode(p_path_id));
1416 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
1417
1418 if let Some(ref user_agent) = configuration.user_agent {
1419 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1420 }
1421 if let Some(ref token) = configuration.bearer_access_token {
1422 req_builder = req_builder.bearer_auth(token.to_owned());
1423 };
1424
1425 let req = req_builder.build()?;
1426 let resp = configuration.client.execute(req).await?;
1427
1428 let status = resp.status();
1429
1430 if !status.is_client_error() && !status.is_server_error() {
1431 Ok(())
1432 } else {
1433 let content = resp.text().await?;
1434 let entity: Option<WorkspaceDeleteFileError> = serde_json::from_str(&content).ok();
1435 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1436 }
1437}
1438
1439pub async fn workspace_get_file(configuration: &configuration::Configuration, org: &str, workspace: &str, id: &str) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceGetFileError>> {
1440 let p_path_org = org;
1442 let p_path_workspace = workspace;
1443 let p_path_id = id;
1444
1445 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/files/{id}", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace), id=crate::apis::urlencode(p_path_id));
1446 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1447
1448 if let Some(ref user_agent) = configuration.user_agent {
1449 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1450 }
1451 if let Some(ref token) = configuration.bearer_access_token {
1452 req_builder = req_builder.bearer_auth(token.to_owned());
1453 };
1454
1455 let req = req_builder.build()?;
1456 let resp = configuration.client.execute(req).await?;
1457
1458 let status = resp.status();
1459 let content_type = resp
1460 .headers()
1461 .get("content-type")
1462 .and_then(|v| v.to_str().ok())
1463 .unwrap_or("application/octet-stream");
1464 let content_type = super::ContentType::from(content_type);
1465
1466 if !status.is_client_error() && !status.is_server_error() {
1467 let content = resp.text().await?;
1468 match content_type {
1469 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1470 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
1471 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
1472 }
1473 } else {
1474 let content = resp.text().await?;
1475 let entity: Option<WorkspaceGetFileError> = serde_json::from_str(&content).ok();
1476 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1477 }
1478}
1479
1480pub async fn workspace_get_file_download(configuration: &configuration::Configuration, org: &str, workspace: &str, id: &str) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceGetFileDownloadError>> {
1481 let p_path_org = org;
1483 let p_path_workspace = workspace;
1484 let p_path_id = id;
1485
1486 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/files/{id}/download", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace), id=crate::apis::urlencode(p_path_id));
1487 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1488
1489 if let Some(ref user_agent) = configuration.user_agent {
1490 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1491 }
1492 if let Some(ref token) = configuration.bearer_access_token {
1493 req_builder = req_builder.bearer_auth(token.to_owned());
1494 };
1495
1496 let req = req_builder.build()?;
1497 let resp = configuration.client.execute(req).await?;
1498
1499 let status = resp.status();
1500 let content_type = resp
1501 .headers()
1502 .get("content-type")
1503 .and_then(|v| v.to_str().ok())
1504 .unwrap_or("application/octet-stream");
1505 let content_type = super::ContentType::from(content_type);
1506
1507 if !status.is_client_error() && !status.is_server_error() {
1508 let content = resp.text().await?;
1509 match content_type {
1510 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1511 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
1512 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
1513 }
1514 } else {
1515 let content = resp.text().await?;
1516 let entity: Option<WorkspaceGetFileDownloadError> = serde_json::from_str(&content).ok();
1517 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1518 }
1519}
1520
1521pub async fn workspace_get_file_manifest(configuration: &configuration::Configuration, org: &str, workspace: &str, id: &str) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceGetFileManifestError>> {
1522 let p_path_org = org;
1524 let p_path_workspace = workspace;
1525 let p_path_id = id;
1526
1527 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/files/{id}/manifest", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace), id=crate::apis::urlencode(p_path_id));
1528 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1529
1530 if let Some(ref user_agent) = configuration.user_agent {
1531 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1532 }
1533 if let Some(ref token) = configuration.bearer_access_token {
1534 req_builder = req_builder.bearer_auth(token.to_owned());
1535 };
1536
1537 let req = req_builder.build()?;
1538 let resp = configuration.client.execute(req).await?;
1539
1540 let status = resp.status();
1541 let content_type = resp
1542 .headers()
1543 .get("content-type")
1544 .and_then(|v| v.to_str().ok())
1545 .unwrap_or("application/octet-stream");
1546 let content_type = super::ContentType::from(content_type);
1547
1548 if !status.is_client_error() && !status.is_server_error() {
1549 let content = resp.text().await?;
1550 match content_type {
1551 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1552 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
1553 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
1554 }
1555 } else {
1556 let content = resp.text().await?;
1557 let entity: Option<WorkspaceGetFileManifestError> = serde_json::from_str(&content).ok();
1558 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1559 }
1560}
1561
1562pub async fn workspace_init_chunked_upload(configuration: &configuration::Configuration, org: &str, workspace: &str, request_body: std::collections::HashMap<String, serde_json::Value>) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceInitChunkedUploadError>> {
1563 let p_path_org = org;
1565 let p_path_workspace = workspace;
1566 let p_body_request_body = request_body;
1567
1568 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/files/upload/chunked/init", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace));
1569 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1570
1571 if let Some(ref user_agent) = configuration.user_agent {
1572 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1573 }
1574 if let Some(ref token) = configuration.bearer_access_token {
1575 req_builder = req_builder.bearer_auth(token.to_owned());
1576 };
1577 req_builder = req_builder.json(&p_body_request_body);
1578
1579 let req = req_builder.build()?;
1580 let resp = configuration.client.execute(req).await?;
1581
1582 let status = resp.status();
1583 let content_type = resp
1584 .headers()
1585 .get("content-type")
1586 .and_then(|v| v.to_str().ok())
1587 .unwrap_or("application/octet-stream");
1588 let content_type = super::ContentType::from(content_type);
1589
1590 if !status.is_client_error() && !status.is_server_error() {
1591 let content = resp.text().await?;
1592 match content_type {
1593 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1594 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
1595 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
1596 }
1597 } else {
1598 let content = resp.text().await?;
1599 let entity: Option<WorkspaceInitChunkedUploadError> = serde_json::from_str(&content).ok();
1600 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1601 }
1602}
1603
1604pub async fn workspace_list_file_folders(configuration: &configuration::Configuration, org: &str, workspace: &str) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceListFileFoldersError>> {
1605 let p_path_org = org;
1607 let p_path_workspace = workspace;
1608
1609 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/files/folders", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace));
1610 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1611
1612 if let Some(ref user_agent) = configuration.user_agent {
1613 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1614 }
1615 if let Some(ref token) = configuration.bearer_access_token {
1616 req_builder = req_builder.bearer_auth(token.to_owned());
1617 };
1618
1619 let req = req_builder.build()?;
1620 let resp = configuration.client.execute(req).await?;
1621
1622 let status = resp.status();
1623 let content_type = resp
1624 .headers()
1625 .get("content-type")
1626 .and_then(|v| v.to_str().ok())
1627 .unwrap_or("application/octet-stream");
1628 let content_type = super::ContentType::from(content_type);
1629
1630 if !status.is_client_error() && !status.is_server_error() {
1631 let content = resp.text().await?;
1632 match content_type {
1633 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1634 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
1635 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
1636 }
1637 } else {
1638 let content = resp.text().await?;
1639 let entity: Option<WorkspaceListFileFoldersError> = serde_json::from_str(&content).ok();
1640 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1641 }
1642}
1643
1644pub async fn workspace_list_files(configuration: &configuration::Configuration, org: &str, workspace: &str) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceListFilesError>> {
1645 let p_path_org = org;
1647 let p_path_workspace = workspace;
1648
1649 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/files", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace));
1650 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1651
1652 if let Some(ref user_agent) = configuration.user_agent {
1653 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1654 }
1655 if let Some(ref token) = configuration.bearer_access_token {
1656 req_builder = req_builder.bearer_auth(token.to_owned());
1657 };
1658
1659 let req = req_builder.build()?;
1660 let resp = configuration.client.execute(req).await?;
1661
1662 let status = resp.status();
1663 let content_type = resp
1664 .headers()
1665 .get("content-type")
1666 .and_then(|v| v.to_str().ok())
1667 .unwrap_or("application/octet-stream");
1668 let content_type = super::ContentType::from(content_type);
1669
1670 if !status.is_client_error() && !status.is_server_error() {
1671 let content = resp.text().await?;
1672 match content_type {
1673 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1674 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
1675 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
1676 }
1677 } else {
1678 let content = resp.text().await?;
1679 let entity: Option<WorkspaceListFilesError> = serde_json::from_str(&content).ok();
1680 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1681 }
1682}
1683
1684pub async fn workspace_move_file(configuration: &configuration::Configuration, org: &str, workspace: &str, id: &str, request_body: std::collections::HashMap<String, serde_json::Value>) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceMoveFileError>> {
1685 let p_path_org = org;
1687 let p_path_workspace = workspace;
1688 let p_path_id = id;
1689 let p_body_request_body = request_body;
1690
1691 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/files/{id}/move", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace), id=crate::apis::urlencode(p_path_id));
1692 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1693
1694 if let Some(ref user_agent) = configuration.user_agent {
1695 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1696 }
1697 if let Some(ref token) = configuration.bearer_access_token {
1698 req_builder = req_builder.bearer_auth(token.to_owned());
1699 };
1700 req_builder = req_builder.json(&p_body_request_body);
1701
1702 let req = req_builder.build()?;
1703 let resp = configuration.client.execute(req).await?;
1704
1705 let status = resp.status();
1706 let content_type = resp
1707 .headers()
1708 .get("content-type")
1709 .and_then(|v| v.to_str().ok())
1710 .unwrap_or("application/octet-stream");
1711 let content_type = super::ContentType::from(content_type);
1712
1713 if !status.is_client_error() && !status.is_server_error() {
1714 let content = resp.text().await?;
1715 match content_type {
1716 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1717 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
1718 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
1719 }
1720 } else {
1721 let content = resp.text().await?;
1722 let entity: Option<WorkspaceMoveFileError> = serde_json::from_str(&content).ok();
1723 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1724 }
1725}
1726
1727pub async fn workspace_update_file(configuration: &configuration::Configuration, org: &str, workspace: &str, id: &str, request_body: std::collections::HashMap<String, serde_json::Value>) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceUpdateFileError>> {
1728 let p_path_org = org;
1730 let p_path_workspace = workspace;
1731 let p_path_id = id;
1732 let p_body_request_body = request_body;
1733
1734 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/files/{id}", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace), id=crate::apis::urlencode(p_path_id));
1735 let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
1736
1737 if let Some(ref user_agent) = configuration.user_agent {
1738 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1739 }
1740 if let Some(ref token) = configuration.bearer_access_token {
1741 req_builder = req_builder.bearer_auth(token.to_owned());
1742 };
1743 req_builder = req_builder.json(&p_body_request_body);
1744
1745 let req = req_builder.build()?;
1746 let resp = configuration.client.execute(req).await?;
1747
1748 let status = resp.status();
1749 let content_type = resp
1750 .headers()
1751 .get("content-type")
1752 .and_then(|v| v.to_str().ok())
1753 .unwrap_or("application/octet-stream");
1754 let content_type = super::ContentType::from(content_type);
1755
1756 if !status.is_client_error() && !status.is_server_error() {
1757 let content = resp.text().await?;
1758 match content_type {
1759 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1760 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
1761 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
1762 }
1763 } else {
1764 let content = resp.text().await?;
1765 let entity: Option<WorkspaceUpdateFileError> = serde_json::from_str(&content).ok();
1766 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1767 }
1768}
1769
1770pub async fn workspace_upload_chunked_block(configuration: &configuration::Configuration, org: &str, workspace: &str, body: std::path::PathBuf) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceUploadChunkedBlockError>> {
1771 let p_path_org = org;
1773 let p_path_workspace = workspace;
1774 let p_body_body = body;
1775
1776 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/files/upload/chunked/blocks", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace));
1777 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1778
1779 if let Some(ref user_agent) = configuration.user_agent {
1780 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1781 }
1782 if let Some(ref token) = configuration.bearer_access_token {
1783 req_builder = req_builder.bearer_auth(token.to_owned());
1784 };
1785 let file = TokioFile::open(p_body_body).await?;
1786 let stream = FramedRead::new(file, BytesCodec::new());
1787 req_builder = req_builder.body(reqwest::Body::wrap_stream(stream));
1788
1789 let req = req_builder.build()?;
1790 let resp = configuration.client.execute(req).await?;
1791
1792 let status = resp.status();
1793 let content_type = resp
1794 .headers()
1795 .get("content-type")
1796 .and_then(|v| v.to_str().ok())
1797 .unwrap_or("application/octet-stream");
1798 let content_type = super::ContentType::from(content_type);
1799
1800 if !status.is_client_error() && !status.is_server_error() {
1801 let content = resp.text().await?;
1802 match content_type {
1803 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1804 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
1805 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
1806 }
1807 } else {
1808 let content = resp.text().await?;
1809 let entity: Option<WorkspaceUploadChunkedBlockError> = serde_json::from_str(&content).ok();
1810 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1811 }
1812}
1813
1814pub async fn workspace_upload_file(configuration: &configuration::Configuration, org: &str, workspace: &str, file: Option<std::path::PathBuf>) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceUploadFileError>> {
1815 let p_path_org = org;
1817 let p_path_workspace = workspace;
1818 let p_form_file = file;
1819
1820 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/files/upload", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace));
1821 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1822
1823 if let Some(ref user_agent) = configuration.user_agent {
1824 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1825 }
1826 if let Some(ref token) = configuration.bearer_access_token {
1827 req_builder = req_builder.bearer_auth(token.to_owned());
1828 };
1829 let mut multipart_form = reqwest::multipart::Form::new();
1830 if let Some(ref param_value) = p_form_file {
1831 let file = TokioFile::open(param_value).await?;
1832 let stream = FramedRead::new(file, BytesCodec::new());
1833 let file_name = param_value.file_name().map(|n| n.to_string_lossy().to_string()).unwrap_or_default();
1834 let file_part = reqwest::multipart::Part::stream(reqwest::Body::wrap_stream(stream)).file_name(file_name);
1835 multipart_form = multipart_form.part("file", file_part);
1836 }
1837 req_builder = req_builder.multipart(multipart_form);
1838
1839 let req = req_builder.build()?;
1840 let resp = configuration.client.execute(req).await?;
1841
1842 let status = resp.status();
1843 let content_type = resp
1844 .headers()
1845 .get("content-type")
1846 .and_then(|v| v.to_str().ok())
1847 .unwrap_or("application/octet-stream");
1848 let content_type = super::ContentType::from(content_type);
1849
1850 if !status.is_client_error() && !status.is_server_error() {
1851 let content = resp.text().await?;
1852 match content_type {
1853 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1854 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
1855 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
1856 }
1857 } else {
1858 let content = resp.text().await?;
1859 let entity: Option<WorkspaceUploadFileError> = serde_json::from_str(&content).ok();
1860 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1861 }
1862}
1863
1864pub async fn workspace_upload_file_base64(configuration: &configuration::Configuration, org: &str, workspace: &str, request_body: std::collections::HashMap<String, serde_json::Value>) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceUploadFileBase64Error>> {
1865 let p_path_org = org;
1867 let p_path_workspace = workspace;
1868 let p_body_request_body = request_body;
1869
1870 let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/files/upload/base64", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace));
1871 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1872
1873 if let Some(ref user_agent) = configuration.user_agent {
1874 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1875 }
1876 if let Some(ref token) = configuration.bearer_access_token {
1877 req_builder = req_builder.bearer_auth(token.to_owned());
1878 };
1879 req_builder = req_builder.json(&p_body_request_body);
1880
1881 let req = req_builder.build()?;
1882 let resp = configuration.client.execute(req).await?;
1883
1884 let status = resp.status();
1885 let content_type = resp
1886 .headers()
1887 .get("content-type")
1888 .and_then(|v| v.to_str().ok())
1889 .unwrap_or("application/octet-stream");
1890 let content_type = super::ContentType::from(content_type);
1891
1892 if !status.is_client_error() && !status.is_server_error() {
1893 let content = resp.text().await?;
1894 match content_type {
1895 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1896 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
1897 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
1898 }
1899 } else {
1900 let content = resp.text().await?;
1901 let entity: Option<WorkspaceUploadFileBase64Error> = serde_json::from_str(&content).ok();
1902 Err(Error::ResponseError(ResponseContent { status, content, entity }))
1903 }
1904}
1905