1use std::sync::Arc;
12
13use async_trait::async_trait;
14#[cfg(feature = "mockall")]
15use mockall::automock;
16use reqwest;
17use serde::{Deserialize, Serialize, de::Error as _};
18
19use super::{Error, configuration};
20use crate::{
21 apis::{AuthRequired, ContentType, ResponseContent},
22 models,
23};
24
25#[cfg_attr(feature = "mockall", automock)]
26#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
27#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
28pub trait CollectionsApi: Send + Sync {
29 async fn delete<'a>(
31 &self,
32 org_id: uuid::Uuid,
33 id: uuid::Uuid,
34 ) -> Result<(), Error<DeleteError>>;
35
36 async fn delete_many<'a>(
38 &self,
39 org_id: uuid::Uuid,
40 collection_bulk_delete_request_model: Option<models::CollectionBulkDeleteRequestModel>,
41 ) -> Result<(), Error<DeleteManyError>>;
42
43 async fn get<'a>(
45 &self,
46 org_id: uuid::Uuid,
47 id: uuid::Uuid,
48 ) -> Result<models::CollectionResponseModel, Error<GetError>>;
49
50 async fn get_all<'a>(
52 &self,
53 org_id: uuid::Uuid,
54 ) -> Result<models::CollectionResponseModelListResponseModel, Error<GetAllError>>;
55
56 async fn get_details<'a>(
58 &self,
59 org_id: uuid::Uuid,
60 id: uuid::Uuid,
61 ) -> Result<models::CollectionAccessDetailsResponseModel, Error<GetDetailsError>>;
62
63 async fn get_many_with_details<'a>(
65 &self,
66 org_id: uuid::Uuid,
67 ) -> Result<
68 models::CollectionAccessDetailsResponseModelListResponseModel,
69 Error<GetManyWithDetailsError>,
70 >;
71
72 async fn get_user(
74 &self,
75 ) -> Result<models::CollectionDetailsResponseModelListResponseModel, Error<GetUserError>>;
76
77 async fn get_users<'a>(
79 &self,
80 org_id: uuid::Uuid,
81 id: uuid::Uuid,
82 ) -> Result<Vec<models::SelectionReadOnlyResponseModel>, Error<GetUsersError>>;
83
84 async fn post<'a>(
86 &self,
87 org_id: uuid::Uuid,
88 create_collection_request_model: Option<models::CreateCollectionRequestModel>,
89 ) -> Result<models::CollectionResponseModel, Error<PostError>>;
90
91 async fn post_bulk_collection_access<'a>(
93 &self,
94 org_id: uuid::Uuid,
95 bulk_collection_access_request_model: Option<models::BulkCollectionAccessRequestModel>,
96 ) -> Result<(), Error<PostBulkCollectionAccessError>>;
97
98 async fn put<'a>(
100 &self,
101 org_id: uuid::Uuid,
102 id: uuid::Uuid,
103 update_collection_request_model: Option<models::UpdateCollectionRequestModel>,
104 ) -> Result<models::CollectionResponseModel, Error<PutError>>;
105}
106
107pub struct CollectionsApiClient {
108 configuration: Arc<configuration::Configuration>,
109}
110
111impl CollectionsApiClient {
112 pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
113 Self { configuration }
114 }
115}
116
117#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
118#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
119impl CollectionsApi for CollectionsApiClient {
120 async fn delete<'a>(
121 &self,
122 org_id: uuid::Uuid,
123 id: uuid::Uuid,
124 ) -> Result<(), Error<DeleteError>> {
125 let local_var_configuration = &self.configuration;
126
127 let local_var_client = &local_var_configuration.client;
128
129 let local_var_uri_str = format!(
130 "{}/organizations/{orgId}/collections/{id}",
131 local_var_configuration.base_path,
132 orgId = org_id,
133 id = id
134 );
135 let mut local_var_req_builder =
136 local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
137
138 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
139 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
140 };
141 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
142
143 let local_var_req = local_var_req_builder.build()?;
144 let local_var_resp = local_var_client.execute(local_var_req).await?;
145
146 let local_var_status = local_var_resp.status();
147 let local_var_content = local_var_resp.text().await?;
148
149 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
150 Ok(())
151 } else {
152 let local_var_entity: Option<DeleteError> =
153 serde_json::from_str(&local_var_content).ok();
154 let local_var_error = ResponseContent {
155 status: local_var_status,
156 content: local_var_content,
157 entity: local_var_entity,
158 };
159 Err(Error::ResponseError(local_var_error))
160 }
161 }
162
163 async fn delete_many<'a>(
164 &self,
165 org_id: uuid::Uuid,
166 collection_bulk_delete_request_model: Option<models::CollectionBulkDeleteRequestModel>,
167 ) -> Result<(), Error<DeleteManyError>> {
168 let local_var_configuration = &self.configuration;
169
170 let local_var_client = &local_var_configuration.client;
171
172 let local_var_uri_str = format!(
173 "{}/organizations/{orgId}/collections",
174 local_var_configuration.base_path,
175 orgId = org_id
176 );
177 let mut local_var_req_builder =
178 local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
179
180 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
181 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
182 };
183 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
184 local_var_req_builder = local_var_req_builder.json(&collection_bulk_delete_request_model);
185
186 let local_var_req = local_var_req_builder.build()?;
187 let local_var_resp = local_var_client.execute(local_var_req).await?;
188
189 let local_var_status = local_var_resp.status();
190 let local_var_content = local_var_resp.text().await?;
191
192 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
193 Ok(())
194 } else {
195 let local_var_entity: Option<DeleteManyError> =
196 serde_json::from_str(&local_var_content).ok();
197 let local_var_error = ResponseContent {
198 status: local_var_status,
199 content: local_var_content,
200 entity: local_var_entity,
201 };
202 Err(Error::ResponseError(local_var_error))
203 }
204 }
205
206 async fn get<'a>(
207 &self,
208 org_id: uuid::Uuid,
209 id: uuid::Uuid,
210 ) -> Result<models::CollectionResponseModel, Error<GetError>> {
211 let local_var_configuration = &self.configuration;
212
213 let local_var_client = &local_var_configuration.client;
214
215 let local_var_uri_str = format!(
216 "{}/organizations/{orgId}/collections/{id}",
217 local_var_configuration.base_path,
218 orgId = org_id,
219 id = id
220 );
221 let mut local_var_req_builder =
222 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
223
224 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
225 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
226 };
227 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
228
229 let local_var_req = local_var_req_builder.build()?;
230 let local_var_resp = local_var_client.execute(local_var_req).await?;
231
232 let local_var_status = local_var_resp.status();
233 let local_var_content_type = local_var_resp
234 .headers()
235 .get("content-type")
236 .and_then(|v| v.to_str().ok())
237 .unwrap_or("application/octet-stream");
238 let local_var_content_type = super::ContentType::from(local_var_content_type);
239 let local_var_content = local_var_resp.text().await?;
240
241 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
242 match local_var_content_type {
243 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
244 ContentType::Text => {
245 return Err(Error::from(serde_json::Error::custom(
246 "Received `text/plain` content type response that cannot be converted to `models::CollectionResponseModel`",
247 )));
248 }
249 ContentType::Unsupported(local_var_unknown_type) => {
250 return Err(Error::from(serde_json::Error::custom(format!(
251 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::CollectionResponseModel`"
252 ))));
253 }
254 }
255 } else {
256 let local_var_entity: Option<GetError> = serde_json::from_str(&local_var_content).ok();
257 let local_var_error = ResponseContent {
258 status: local_var_status,
259 content: local_var_content,
260 entity: local_var_entity,
261 };
262 Err(Error::ResponseError(local_var_error))
263 }
264 }
265
266 async fn get_all<'a>(
267 &self,
268 org_id: uuid::Uuid,
269 ) -> Result<models::CollectionResponseModelListResponseModel, Error<GetAllError>> {
270 let local_var_configuration = &self.configuration;
271
272 let local_var_client = &local_var_configuration.client;
273
274 let local_var_uri_str = format!(
275 "{}/organizations/{orgId}/collections",
276 local_var_configuration.base_path,
277 orgId = org_id
278 );
279 let mut local_var_req_builder =
280 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
281
282 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
283 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
284 };
285 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
286
287 let local_var_req = local_var_req_builder.build()?;
288 let local_var_resp = local_var_client.execute(local_var_req).await?;
289
290 let local_var_status = local_var_resp.status();
291 let local_var_content_type = local_var_resp
292 .headers()
293 .get("content-type")
294 .and_then(|v| v.to_str().ok())
295 .unwrap_or("application/octet-stream");
296 let local_var_content_type = super::ContentType::from(local_var_content_type);
297 let local_var_content = local_var_resp.text().await?;
298
299 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
300 match local_var_content_type {
301 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
302 ContentType::Text => {
303 return Err(Error::from(serde_json::Error::custom(
304 "Received `text/plain` content type response that cannot be converted to `models::CollectionResponseModelListResponseModel`",
305 )));
306 }
307 ContentType::Unsupported(local_var_unknown_type) => {
308 return Err(Error::from(serde_json::Error::custom(format!(
309 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::CollectionResponseModelListResponseModel`"
310 ))));
311 }
312 }
313 } else {
314 let local_var_entity: Option<GetAllError> =
315 serde_json::from_str(&local_var_content).ok();
316 let local_var_error = ResponseContent {
317 status: local_var_status,
318 content: local_var_content,
319 entity: local_var_entity,
320 };
321 Err(Error::ResponseError(local_var_error))
322 }
323 }
324
325 async fn get_details<'a>(
326 &self,
327 org_id: uuid::Uuid,
328 id: uuid::Uuid,
329 ) -> Result<models::CollectionAccessDetailsResponseModel, Error<GetDetailsError>> {
330 let local_var_configuration = &self.configuration;
331
332 let local_var_client = &local_var_configuration.client;
333
334 let local_var_uri_str = format!(
335 "{}/organizations/{orgId}/collections/{id}/details",
336 local_var_configuration.base_path,
337 orgId = org_id,
338 id = id
339 );
340 let mut local_var_req_builder =
341 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
342
343 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
344 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
345 };
346 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
347
348 let local_var_req = local_var_req_builder.build()?;
349 let local_var_resp = local_var_client.execute(local_var_req).await?;
350
351 let local_var_status = local_var_resp.status();
352 let local_var_content_type = local_var_resp
353 .headers()
354 .get("content-type")
355 .and_then(|v| v.to_str().ok())
356 .unwrap_or("application/octet-stream");
357 let local_var_content_type = super::ContentType::from(local_var_content_type);
358 let local_var_content = local_var_resp.text().await?;
359
360 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
361 match local_var_content_type {
362 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
363 ContentType::Text => {
364 return Err(Error::from(serde_json::Error::custom(
365 "Received `text/plain` content type response that cannot be converted to `models::CollectionAccessDetailsResponseModel`",
366 )));
367 }
368 ContentType::Unsupported(local_var_unknown_type) => {
369 return Err(Error::from(serde_json::Error::custom(format!(
370 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::CollectionAccessDetailsResponseModel`"
371 ))));
372 }
373 }
374 } else {
375 let local_var_entity: Option<GetDetailsError> =
376 serde_json::from_str(&local_var_content).ok();
377 let local_var_error = ResponseContent {
378 status: local_var_status,
379 content: local_var_content,
380 entity: local_var_entity,
381 };
382 Err(Error::ResponseError(local_var_error))
383 }
384 }
385
386 async fn get_many_with_details<'a>(
387 &self,
388 org_id: uuid::Uuid,
389 ) -> Result<
390 models::CollectionAccessDetailsResponseModelListResponseModel,
391 Error<GetManyWithDetailsError>,
392 > {
393 let local_var_configuration = &self.configuration;
394
395 let local_var_client = &local_var_configuration.client;
396
397 let local_var_uri_str = format!(
398 "{}/organizations/{orgId}/collections/details",
399 local_var_configuration.base_path,
400 orgId = org_id
401 );
402 let mut local_var_req_builder =
403 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
404
405 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
406 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
407 };
408 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
409
410 let local_var_req = local_var_req_builder.build()?;
411 let local_var_resp = local_var_client.execute(local_var_req).await?;
412
413 let local_var_status = local_var_resp.status();
414 let local_var_content_type = local_var_resp
415 .headers()
416 .get("content-type")
417 .and_then(|v| v.to_str().ok())
418 .unwrap_or("application/octet-stream");
419 let local_var_content_type = super::ContentType::from(local_var_content_type);
420 let local_var_content = local_var_resp.text().await?;
421
422 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
423 match local_var_content_type {
424 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
425 ContentType::Text => {
426 return Err(Error::from(serde_json::Error::custom(
427 "Received `text/plain` content type response that cannot be converted to `models::CollectionAccessDetailsResponseModelListResponseModel`",
428 )));
429 }
430 ContentType::Unsupported(local_var_unknown_type) => {
431 return Err(Error::from(serde_json::Error::custom(format!(
432 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::CollectionAccessDetailsResponseModelListResponseModel`"
433 ))));
434 }
435 }
436 } else {
437 let local_var_entity: Option<GetManyWithDetailsError> =
438 serde_json::from_str(&local_var_content).ok();
439 let local_var_error = ResponseContent {
440 status: local_var_status,
441 content: local_var_content,
442 entity: local_var_entity,
443 };
444 Err(Error::ResponseError(local_var_error))
445 }
446 }
447
448 async fn get_user(
449 &self,
450 ) -> Result<models::CollectionDetailsResponseModelListResponseModel, Error<GetUserError>> {
451 let local_var_configuration = &self.configuration;
452
453 let local_var_client = &local_var_configuration.client;
454
455 let local_var_uri_str = format!("{}/collections", local_var_configuration.base_path);
456 let mut local_var_req_builder =
457 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
458
459 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
460 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
461 };
462 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
463
464 let local_var_req = local_var_req_builder.build()?;
465 let local_var_resp = local_var_client.execute(local_var_req).await?;
466
467 let local_var_status = local_var_resp.status();
468 let local_var_content_type = local_var_resp
469 .headers()
470 .get("content-type")
471 .and_then(|v| v.to_str().ok())
472 .unwrap_or("application/octet-stream");
473 let local_var_content_type = super::ContentType::from(local_var_content_type);
474 let local_var_content = local_var_resp.text().await?;
475
476 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
477 match local_var_content_type {
478 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
479 ContentType::Text => {
480 return Err(Error::from(serde_json::Error::custom(
481 "Received `text/plain` content type response that cannot be converted to `models::CollectionDetailsResponseModelListResponseModel`",
482 )));
483 }
484 ContentType::Unsupported(local_var_unknown_type) => {
485 return Err(Error::from(serde_json::Error::custom(format!(
486 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::CollectionDetailsResponseModelListResponseModel`"
487 ))));
488 }
489 }
490 } else {
491 let local_var_entity: Option<GetUserError> =
492 serde_json::from_str(&local_var_content).ok();
493 let local_var_error = ResponseContent {
494 status: local_var_status,
495 content: local_var_content,
496 entity: local_var_entity,
497 };
498 Err(Error::ResponseError(local_var_error))
499 }
500 }
501
502 async fn get_users<'a>(
503 &self,
504 org_id: uuid::Uuid,
505 id: uuid::Uuid,
506 ) -> Result<Vec<models::SelectionReadOnlyResponseModel>, Error<GetUsersError>> {
507 let local_var_configuration = &self.configuration;
508
509 let local_var_client = &local_var_configuration.client;
510
511 let local_var_uri_str = format!(
512 "{}/organizations/{orgId}/collections/{id}/users",
513 local_var_configuration.base_path,
514 orgId = org_id,
515 id = id
516 );
517 let mut local_var_req_builder =
518 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
519
520 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
521 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
522 };
523 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
524
525 let local_var_req = local_var_req_builder.build()?;
526 let local_var_resp = local_var_client.execute(local_var_req).await?;
527
528 let local_var_status = local_var_resp.status();
529 let local_var_content_type = local_var_resp
530 .headers()
531 .get("content-type")
532 .and_then(|v| v.to_str().ok())
533 .unwrap_or("application/octet-stream");
534 let local_var_content_type = super::ContentType::from(local_var_content_type);
535 let local_var_content = local_var_resp.text().await?;
536
537 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
538 match local_var_content_type {
539 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
540 ContentType::Text => {
541 return Err(Error::from(serde_json::Error::custom(
542 "Received `text/plain` content type response that cannot be converted to `Vec<models::SelectionReadOnlyResponseModel>`",
543 )));
544 }
545 ContentType::Unsupported(local_var_unknown_type) => {
546 return Err(Error::from(serde_json::Error::custom(format!(
547 "Received `{local_var_unknown_type}` content type response that cannot be converted to `Vec<models::SelectionReadOnlyResponseModel>`"
548 ))));
549 }
550 }
551 } else {
552 let local_var_entity: Option<GetUsersError> =
553 serde_json::from_str(&local_var_content).ok();
554 let local_var_error = ResponseContent {
555 status: local_var_status,
556 content: local_var_content,
557 entity: local_var_entity,
558 };
559 Err(Error::ResponseError(local_var_error))
560 }
561 }
562
563 async fn post<'a>(
564 &self,
565 org_id: uuid::Uuid,
566 create_collection_request_model: Option<models::CreateCollectionRequestModel>,
567 ) -> Result<models::CollectionResponseModel, Error<PostError>> {
568 let local_var_configuration = &self.configuration;
569
570 let local_var_client = &local_var_configuration.client;
571
572 let local_var_uri_str = format!(
573 "{}/organizations/{orgId}/collections",
574 local_var_configuration.base_path,
575 orgId = org_id
576 );
577 let mut local_var_req_builder =
578 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
579
580 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
581 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
582 };
583 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
584 local_var_req_builder = local_var_req_builder.json(&create_collection_request_model);
585
586 let local_var_req = local_var_req_builder.build()?;
587 let local_var_resp = local_var_client.execute(local_var_req).await?;
588
589 let local_var_status = local_var_resp.status();
590 let local_var_content_type = local_var_resp
591 .headers()
592 .get("content-type")
593 .and_then(|v| v.to_str().ok())
594 .unwrap_or("application/octet-stream");
595 let local_var_content_type = super::ContentType::from(local_var_content_type);
596 let local_var_content = local_var_resp.text().await?;
597
598 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
599 match local_var_content_type {
600 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
601 ContentType::Text => {
602 return Err(Error::from(serde_json::Error::custom(
603 "Received `text/plain` content type response that cannot be converted to `models::CollectionResponseModel`",
604 )));
605 }
606 ContentType::Unsupported(local_var_unknown_type) => {
607 return Err(Error::from(serde_json::Error::custom(format!(
608 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::CollectionResponseModel`"
609 ))));
610 }
611 }
612 } else {
613 let local_var_entity: Option<PostError> = serde_json::from_str(&local_var_content).ok();
614 let local_var_error = ResponseContent {
615 status: local_var_status,
616 content: local_var_content,
617 entity: local_var_entity,
618 };
619 Err(Error::ResponseError(local_var_error))
620 }
621 }
622
623 async fn post_bulk_collection_access<'a>(
624 &self,
625 org_id: uuid::Uuid,
626 bulk_collection_access_request_model: Option<models::BulkCollectionAccessRequestModel>,
627 ) -> Result<(), Error<PostBulkCollectionAccessError>> {
628 let local_var_configuration = &self.configuration;
629
630 let local_var_client = &local_var_configuration.client;
631
632 let local_var_uri_str = format!(
633 "{}/organizations/{orgId}/collections/bulk-access",
634 local_var_configuration.base_path,
635 orgId = org_id
636 );
637 let mut local_var_req_builder =
638 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
639
640 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
641 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
642 };
643 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
644 local_var_req_builder = local_var_req_builder.json(&bulk_collection_access_request_model);
645
646 let local_var_req = local_var_req_builder.build()?;
647 let local_var_resp = local_var_client.execute(local_var_req).await?;
648
649 let local_var_status = local_var_resp.status();
650 let local_var_content = local_var_resp.text().await?;
651
652 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
653 Ok(())
654 } else {
655 let local_var_entity: Option<PostBulkCollectionAccessError> =
656 serde_json::from_str(&local_var_content).ok();
657 let local_var_error = ResponseContent {
658 status: local_var_status,
659 content: local_var_content,
660 entity: local_var_entity,
661 };
662 Err(Error::ResponseError(local_var_error))
663 }
664 }
665
666 async fn put<'a>(
667 &self,
668 org_id: uuid::Uuid,
669 id: uuid::Uuid,
670 update_collection_request_model: Option<models::UpdateCollectionRequestModel>,
671 ) -> Result<models::CollectionResponseModel, Error<PutError>> {
672 let local_var_configuration = &self.configuration;
673
674 let local_var_client = &local_var_configuration.client;
675
676 let local_var_uri_str = format!(
677 "{}/organizations/{orgId}/collections/{id}",
678 local_var_configuration.base_path,
679 orgId = org_id,
680 id = id
681 );
682 let mut local_var_req_builder =
683 local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
684
685 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
686 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
687 };
688 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
689 local_var_req_builder = local_var_req_builder.json(&update_collection_request_model);
690
691 let local_var_req = local_var_req_builder.build()?;
692 let local_var_resp = local_var_client.execute(local_var_req).await?;
693
694 let local_var_status = local_var_resp.status();
695 let local_var_content_type = local_var_resp
696 .headers()
697 .get("content-type")
698 .and_then(|v| v.to_str().ok())
699 .unwrap_or("application/octet-stream");
700 let local_var_content_type = super::ContentType::from(local_var_content_type);
701 let local_var_content = local_var_resp.text().await?;
702
703 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
704 match local_var_content_type {
705 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
706 ContentType::Text => {
707 return Err(Error::from(serde_json::Error::custom(
708 "Received `text/plain` content type response that cannot be converted to `models::CollectionResponseModel`",
709 )));
710 }
711 ContentType::Unsupported(local_var_unknown_type) => {
712 return Err(Error::from(serde_json::Error::custom(format!(
713 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::CollectionResponseModel`"
714 ))));
715 }
716 }
717 } else {
718 let local_var_entity: Option<PutError> = serde_json::from_str(&local_var_content).ok();
719 let local_var_error = ResponseContent {
720 status: local_var_status,
721 content: local_var_content,
722 entity: local_var_entity,
723 };
724 Err(Error::ResponseError(local_var_error))
725 }
726 }
727}
728
729#[derive(Debug, Clone, Serialize, Deserialize)]
731#[serde(untagged)]
732pub enum DeleteError {
733 UnknownValue(serde_json::Value),
734}
735#[derive(Debug, Clone, Serialize, Deserialize)]
737#[serde(untagged)]
738pub enum DeleteManyError {
739 UnknownValue(serde_json::Value),
740}
741#[derive(Debug, Clone, Serialize, Deserialize)]
743#[serde(untagged)]
744pub enum GetError {
745 UnknownValue(serde_json::Value),
746}
747#[derive(Debug, Clone, Serialize, Deserialize)]
749#[serde(untagged)]
750pub enum GetAllError {
751 UnknownValue(serde_json::Value),
752}
753#[derive(Debug, Clone, Serialize, Deserialize)]
755#[serde(untagged)]
756pub enum GetDetailsError {
757 UnknownValue(serde_json::Value),
758}
759#[derive(Debug, Clone, Serialize, Deserialize)]
761#[serde(untagged)]
762pub enum GetManyWithDetailsError {
763 UnknownValue(serde_json::Value),
764}
765#[derive(Debug, Clone, Serialize, Deserialize)]
767#[serde(untagged)]
768pub enum GetUserError {
769 UnknownValue(serde_json::Value),
770}
771#[derive(Debug, Clone, Serialize, Deserialize)]
773#[serde(untagged)]
774pub enum GetUsersError {
775 UnknownValue(serde_json::Value),
776}
777#[derive(Debug, Clone, Serialize, Deserialize)]
779#[serde(untagged)]
780pub enum PostError {
781 UnknownValue(serde_json::Value),
782}
783#[derive(Debug, Clone, Serialize, Deserialize)]
785#[serde(untagged)]
786pub enum PostBulkCollectionAccessError {
787 UnknownValue(serde_json::Value),
788}
789#[derive(Debug, Clone, Serialize, Deserialize)]
791#[serde(untagged)]
792pub enum PutError {
793 UnknownValue(serde_json::Value),
794}