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::{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_user_agent) = local_var_configuration.user_agent {
139 local_var_req_builder = local_var_req_builder
140 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
141 }
142 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
143 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
144 };
145
146 let local_var_req = local_var_req_builder.build()?;
147 let local_var_resp = local_var_client.execute(local_var_req).await?;
148
149 let local_var_status = local_var_resp.status();
150 let local_var_content = local_var_resp.text().await?;
151
152 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
153 Ok(())
154 } else {
155 let local_var_entity: Option<DeleteError> =
156 serde_json::from_str(&local_var_content).ok();
157 let local_var_error = ResponseContent {
158 status: local_var_status,
159 content: local_var_content,
160 entity: local_var_entity,
161 };
162 Err(Error::ResponseError(local_var_error))
163 }
164 }
165
166 async fn delete_many<'a>(
167 &self,
168 org_id: uuid::Uuid,
169 collection_bulk_delete_request_model: Option<models::CollectionBulkDeleteRequestModel>,
170 ) -> Result<(), Error<DeleteManyError>> {
171 let local_var_configuration = &self.configuration;
172
173 let local_var_client = &local_var_configuration.client;
174
175 let local_var_uri_str = format!(
176 "{}/organizations/{orgId}/collections",
177 local_var_configuration.base_path,
178 orgId = org_id
179 );
180 let mut local_var_req_builder =
181 local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
182
183 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
184 local_var_req_builder = local_var_req_builder
185 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
186 }
187 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
188 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
189 };
190 local_var_req_builder = local_var_req_builder.json(&collection_bulk_delete_request_model);
191
192 let local_var_req = local_var_req_builder.build()?;
193 let local_var_resp = local_var_client.execute(local_var_req).await?;
194
195 let local_var_status = local_var_resp.status();
196 let local_var_content = local_var_resp.text().await?;
197
198 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
199 Ok(())
200 } else {
201 let local_var_entity: Option<DeleteManyError> =
202 serde_json::from_str(&local_var_content).ok();
203 let local_var_error = ResponseContent {
204 status: local_var_status,
205 content: local_var_content,
206 entity: local_var_entity,
207 };
208 Err(Error::ResponseError(local_var_error))
209 }
210 }
211
212 async fn get<'a>(
213 &self,
214 org_id: uuid::Uuid,
215 id: uuid::Uuid,
216 ) -> Result<models::CollectionResponseModel, Error<GetError>> {
217 let local_var_configuration = &self.configuration;
218
219 let local_var_client = &local_var_configuration.client;
220
221 let local_var_uri_str = format!(
222 "{}/organizations/{orgId}/collections/{id}",
223 local_var_configuration.base_path,
224 orgId = org_id,
225 id = id
226 );
227 let mut local_var_req_builder =
228 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
229
230 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
231 local_var_req_builder = local_var_req_builder
232 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
233 }
234 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
235 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
236 };
237
238 let local_var_req = local_var_req_builder.build()?;
239 let local_var_resp = local_var_client.execute(local_var_req).await?;
240
241 let local_var_status = local_var_resp.status();
242 let local_var_content_type = local_var_resp
243 .headers()
244 .get("content-type")
245 .and_then(|v| v.to_str().ok())
246 .unwrap_or("application/octet-stream");
247 let local_var_content_type = super::ContentType::from(local_var_content_type);
248 let local_var_content = local_var_resp.text().await?;
249
250 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
251 match local_var_content_type {
252 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
253 ContentType::Text => {
254 return Err(Error::from(serde_json::Error::custom(
255 "Received `text/plain` content type response that cannot be converted to `models::CollectionResponseModel`",
256 )));
257 }
258 ContentType::Unsupported(local_var_unknown_type) => {
259 return Err(Error::from(serde_json::Error::custom(format!(
260 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::CollectionResponseModel`"
261 ))));
262 }
263 }
264 } else {
265 let local_var_entity: Option<GetError> = serde_json::from_str(&local_var_content).ok();
266 let local_var_error = ResponseContent {
267 status: local_var_status,
268 content: local_var_content,
269 entity: local_var_entity,
270 };
271 Err(Error::ResponseError(local_var_error))
272 }
273 }
274
275 async fn get_all<'a>(
276 &self,
277 org_id: uuid::Uuid,
278 ) -> Result<models::CollectionResponseModelListResponseModel, Error<GetAllError>> {
279 let local_var_configuration = &self.configuration;
280
281 let local_var_client = &local_var_configuration.client;
282
283 let local_var_uri_str = format!(
284 "{}/organizations/{orgId}/collections",
285 local_var_configuration.base_path,
286 orgId = org_id
287 );
288 let mut local_var_req_builder =
289 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
290
291 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
292 local_var_req_builder = local_var_req_builder
293 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
294 }
295 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
296 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
297 };
298
299 let local_var_req = local_var_req_builder.build()?;
300 let local_var_resp = local_var_client.execute(local_var_req).await?;
301
302 let local_var_status = local_var_resp.status();
303 let local_var_content_type = local_var_resp
304 .headers()
305 .get("content-type")
306 .and_then(|v| v.to_str().ok())
307 .unwrap_or("application/octet-stream");
308 let local_var_content_type = super::ContentType::from(local_var_content_type);
309 let local_var_content = local_var_resp.text().await?;
310
311 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
312 match local_var_content_type {
313 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
314 ContentType::Text => {
315 return Err(Error::from(serde_json::Error::custom(
316 "Received `text/plain` content type response that cannot be converted to `models::CollectionResponseModelListResponseModel`",
317 )));
318 }
319 ContentType::Unsupported(local_var_unknown_type) => {
320 return Err(Error::from(serde_json::Error::custom(format!(
321 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::CollectionResponseModelListResponseModel`"
322 ))));
323 }
324 }
325 } else {
326 let local_var_entity: Option<GetAllError> =
327 serde_json::from_str(&local_var_content).ok();
328 let local_var_error = ResponseContent {
329 status: local_var_status,
330 content: local_var_content,
331 entity: local_var_entity,
332 };
333 Err(Error::ResponseError(local_var_error))
334 }
335 }
336
337 async fn get_details<'a>(
338 &self,
339 org_id: uuid::Uuid,
340 id: uuid::Uuid,
341 ) -> Result<models::CollectionAccessDetailsResponseModel, Error<GetDetailsError>> {
342 let local_var_configuration = &self.configuration;
343
344 let local_var_client = &local_var_configuration.client;
345
346 let local_var_uri_str = format!(
347 "{}/organizations/{orgId}/collections/{id}/details",
348 local_var_configuration.base_path,
349 orgId = org_id,
350 id = id
351 );
352 let mut local_var_req_builder =
353 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
354
355 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
356 local_var_req_builder = local_var_req_builder
357 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
358 }
359 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
360 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
361 };
362
363 let local_var_req = local_var_req_builder.build()?;
364 let local_var_resp = local_var_client.execute(local_var_req).await?;
365
366 let local_var_status = local_var_resp.status();
367 let local_var_content_type = local_var_resp
368 .headers()
369 .get("content-type")
370 .and_then(|v| v.to_str().ok())
371 .unwrap_or("application/octet-stream");
372 let local_var_content_type = super::ContentType::from(local_var_content_type);
373 let local_var_content = local_var_resp.text().await?;
374
375 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
376 match local_var_content_type {
377 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
378 ContentType::Text => {
379 return Err(Error::from(serde_json::Error::custom(
380 "Received `text/plain` content type response that cannot be converted to `models::CollectionAccessDetailsResponseModel`",
381 )));
382 }
383 ContentType::Unsupported(local_var_unknown_type) => {
384 return Err(Error::from(serde_json::Error::custom(format!(
385 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::CollectionAccessDetailsResponseModel`"
386 ))));
387 }
388 }
389 } else {
390 let local_var_entity: Option<GetDetailsError> =
391 serde_json::from_str(&local_var_content).ok();
392 let local_var_error = ResponseContent {
393 status: local_var_status,
394 content: local_var_content,
395 entity: local_var_entity,
396 };
397 Err(Error::ResponseError(local_var_error))
398 }
399 }
400
401 async fn get_many_with_details<'a>(
402 &self,
403 org_id: uuid::Uuid,
404 ) -> Result<
405 models::CollectionAccessDetailsResponseModelListResponseModel,
406 Error<GetManyWithDetailsError>,
407 > {
408 let local_var_configuration = &self.configuration;
409
410 let local_var_client = &local_var_configuration.client;
411
412 let local_var_uri_str = format!(
413 "{}/organizations/{orgId}/collections/details",
414 local_var_configuration.base_path,
415 orgId = org_id
416 );
417 let mut local_var_req_builder =
418 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
419
420 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
421 local_var_req_builder = local_var_req_builder
422 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
423 }
424 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
425 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
426 };
427
428 let local_var_req = local_var_req_builder.build()?;
429 let local_var_resp = local_var_client.execute(local_var_req).await?;
430
431 let local_var_status = local_var_resp.status();
432 let local_var_content_type = local_var_resp
433 .headers()
434 .get("content-type")
435 .and_then(|v| v.to_str().ok())
436 .unwrap_or("application/octet-stream");
437 let local_var_content_type = super::ContentType::from(local_var_content_type);
438 let local_var_content = local_var_resp.text().await?;
439
440 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
441 match local_var_content_type {
442 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
443 ContentType::Text => {
444 return Err(Error::from(serde_json::Error::custom(
445 "Received `text/plain` content type response that cannot be converted to `models::CollectionAccessDetailsResponseModelListResponseModel`",
446 )));
447 }
448 ContentType::Unsupported(local_var_unknown_type) => {
449 return Err(Error::from(serde_json::Error::custom(format!(
450 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::CollectionAccessDetailsResponseModelListResponseModel`"
451 ))));
452 }
453 }
454 } else {
455 let local_var_entity: Option<GetManyWithDetailsError> =
456 serde_json::from_str(&local_var_content).ok();
457 let local_var_error = ResponseContent {
458 status: local_var_status,
459 content: local_var_content,
460 entity: local_var_entity,
461 };
462 Err(Error::ResponseError(local_var_error))
463 }
464 }
465
466 async fn get_user(
467 &self,
468 ) -> Result<models::CollectionDetailsResponseModelListResponseModel, Error<GetUserError>> {
469 let local_var_configuration = &self.configuration;
470
471 let local_var_client = &local_var_configuration.client;
472
473 let local_var_uri_str = format!("{}/collections", local_var_configuration.base_path);
474 let mut local_var_req_builder =
475 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
476
477 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
478 local_var_req_builder = local_var_req_builder
479 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
480 }
481 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
482 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
483 };
484
485 let local_var_req = local_var_req_builder.build()?;
486 let local_var_resp = local_var_client.execute(local_var_req).await?;
487
488 let local_var_status = local_var_resp.status();
489 let local_var_content_type = local_var_resp
490 .headers()
491 .get("content-type")
492 .and_then(|v| v.to_str().ok())
493 .unwrap_or("application/octet-stream");
494 let local_var_content_type = super::ContentType::from(local_var_content_type);
495 let local_var_content = local_var_resp.text().await?;
496
497 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
498 match local_var_content_type {
499 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
500 ContentType::Text => {
501 return Err(Error::from(serde_json::Error::custom(
502 "Received `text/plain` content type response that cannot be converted to `models::CollectionDetailsResponseModelListResponseModel`",
503 )));
504 }
505 ContentType::Unsupported(local_var_unknown_type) => {
506 return Err(Error::from(serde_json::Error::custom(format!(
507 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::CollectionDetailsResponseModelListResponseModel`"
508 ))));
509 }
510 }
511 } else {
512 let local_var_entity: Option<GetUserError> =
513 serde_json::from_str(&local_var_content).ok();
514 let local_var_error = ResponseContent {
515 status: local_var_status,
516 content: local_var_content,
517 entity: local_var_entity,
518 };
519 Err(Error::ResponseError(local_var_error))
520 }
521 }
522
523 async fn get_users<'a>(
524 &self,
525 org_id: uuid::Uuid,
526 id: uuid::Uuid,
527 ) -> Result<Vec<models::SelectionReadOnlyResponseModel>, Error<GetUsersError>> {
528 let local_var_configuration = &self.configuration;
529
530 let local_var_client = &local_var_configuration.client;
531
532 let local_var_uri_str = format!(
533 "{}/organizations/{orgId}/collections/{id}/users",
534 local_var_configuration.base_path,
535 orgId = org_id,
536 id = id
537 );
538 let mut local_var_req_builder =
539 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
540
541 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
542 local_var_req_builder = local_var_req_builder
543 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
544 }
545 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
546 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
547 };
548
549 let local_var_req = local_var_req_builder.build()?;
550 let local_var_resp = local_var_client.execute(local_var_req).await?;
551
552 let local_var_status = local_var_resp.status();
553 let local_var_content_type = local_var_resp
554 .headers()
555 .get("content-type")
556 .and_then(|v| v.to_str().ok())
557 .unwrap_or("application/octet-stream");
558 let local_var_content_type = super::ContentType::from(local_var_content_type);
559 let local_var_content = local_var_resp.text().await?;
560
561 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
562 match local_var_content_type {
563 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
564 ContentType::Text => {
565 return Err(Error::from(serde_json::Error::custom(
566 "Received `text/plain` content type response that cannot be converted to `Vec<models::SelectionReadOnlyResponseModel>`",
567 )));
568 }
569 ContentType::Unsupported(local_var_unknown_type) => {
570 return Err(Error::from(serde_json::Error::custom(format!(
571 "Received `{local_var_unknown_type}` content type response that cannot be converted to `Vec<models::SelectionReadOnlyResponseModel>`"
572 ))));
573 }
574 }
575 } else {
576 let local_var_entity: Option<GetUsersError> =
577 serde_json::from_str(&local_var_content).ok();
578 let local_var_error = ResponseContent {
579 status: local_var_status,
580 content: local_var_content,
581 entity: local_var_entity,
582 };
583 Err(Error::ResponseError(local_var_error))
584 }
585 }
586
587 async fn post<'a>(
588 &self,
589 org_id: uuid::Uuid,
590 create_collection_request_model: Option<models::CreateCollectionRequestModel>,
591 ) -> Result<models::CollectionResponseModel, Error<PostError>> {
592 let local_var_configuration = &self.configuration;
593
594 let local_var_client = &local_var_configuration.client;
595
596 let local_var_uri_str = format!(
597 "{}/organizations/{orgId}/collections",
598 local_var_configuration.base_path,
599 orgId = org_id
600 );
601 let mut local_var_req_builder =
602 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
603
604 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
605 local_var_req_builder = local_var_req_builder
606 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
607 }
608 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
609 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
610 };
611 local_var_req_builder = local_var_req_builder.json(&create_collection_request_model);
612
613 let local_var_req = local_var_req_builder.build()?;
614 let local_var_resp = local_var_client.execute(local_var_req).await?;
615
616 let local_var_status = local_var_resp.status();
617 let local_var_content_type = local_var_resp
618 .headers()
619 .get("content-type")
620 .and_then(|v| v.to_str().ok())
621 .unwrap_or("application/octet-stream");
622 let local_var_content_type = super::ContentType::from(local_var_content_type);
623 let local_var_content = local_var_resp.text().await?;
624
625 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
626 match local_var_content_type {
627 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
628 ContentType::Text => {
629 return Err(Error::from(serde_json::Error::custom(
630 "Received `text/plain` content type response that cannot be converted to `models::CollectionResponseModel`",
631 )));
632 }
633 ContentType::Unsupported(local_var_unknown_type) => {
634 return Err(Error::from(serde_json::Error::custom(format!(
635 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::CollectionResponseModel`"
636 ))));
637 }
638 }
639 } else {
640 let local_var_entity: Option<PostError> = serde_json::from_str(&local_var_content).ok();
641 let local_var_error = ResponseContent {
642 status: local_var_status,
643 content: local_var_content,
644 entity: local_var_entity,
645 };
646 Err(Error::ResponseError(local_var_error))
647 }
648 }
649
650 async fn post_bulk_collection_access<'a>(
651 &self,
652 org_id: uuid::Uuid,
653 bulk_collection_access_request_model: Option<models::BulkCollectionAccessRequestModel>,
654 ) -> Result<(), Error<PostBulkCollectionAccessError>> {
655 let local_var_configuration = &self.configuration;
656
657 let local_var_client = &local_var_configuration.client;
658
659 let local_var_uri_str = format!(
660 "{}/organizations/{orgId}/collections/bulk-access",
661 local_var_configuration.base_path,
662 orgId = org_id
663 );
664 let mut local_var_req_builder =
665 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
666
667 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
668 local_var_req_builder = local_var_req_builder
669 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
670 }
671 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
672 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
673 };
674 local_var_req_builder = local_var_req_builder.json(&bulk_collection_access_request_model);
675
676 let local_var_req = local_var_req_builder.build()?;
677 let local_var_resp = local_var_client.execute(local_var_req).await?;
678
679 let local_var_status = local_var_resp.status();
680 let local_var_content = local_var_resp.text().await?;
681
682 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
683 Ok(())
684 } else {
685 let local_var_entity: Option<PostBulkCollectionAccessError> =
686 serde_json::from_str(&local_var_content).ok();
687 let local_var_error = ResponseContent {
688 status: local_var_status,
689 content: local_var_content,
690 entity: local_var_entity,
691 };
692 Err(Error::ResponseError(local_var_error))
693 }
694 }
695
696 async fn put<'a>(
697 &self,
698 org_id: uuid::Uuid,
699 id: uuid::Uuid,
700 update_collection_request_model: Option<models::UpdateCollectionRequestModel>,
701 ) -> Result<models::CollectionResponseModel, Error<PutError>> {
702 let local_var_configuration = &self.configuration;
703
704 let local_var_client = &local_var_configuration.client;
705
706 let local_var_uri_str = format!(
707 "{}/organizations/{orgId}/collections/{id}",
708 local_var_configuration.base_path,
709 orgId = org_id,
710 id = id
711 );
712 let mut local_var_req_builder =
713 local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
714
715 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
716 local_var_req_builder = local_var_req_builder
717 .header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
718 }
719 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
720 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
721 };
722 local_var_req_builder = local_var_req_builder.json(&update_collection_request_model);
723
724 let local_var_req = local_var_req_builder.build()?;
725 let local_var_resp = local_var_client.execute(local_var_req).await?;
726
727 let local_var_status = local_var_resp.status();
728 let local_var_content_type = local_var_resp
729 .headers()
730 .get("content-type")
731 .and_then(|v| v.to_str().ok())
732 .unwrap_or("application/octet-stream");
733 let local_var_content_type = super::ContentType::from(local_var_content_type);
734 let local_var_content = local_var_resp.text().await?;
735
736 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
737 match local_var_content_type {
738 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
739 ContentType::Text => {
740 return Err(Error::from(serde_json::Error::custom(
741 "Received `text/plain` content type response that cannot be converted to `models::CollectionResponseModel`",
742 )));
743 }
744 ContentType::Unsupported(local_var_unknown_type) => {
745 return Err(Error::from(serde_json::Error::custom(format!(
746 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::CollectionResponseModel`"
747 ))));
748 }
749 }
750 } else {
751 let local_var_entity: Option<PutError> = serde_json::from_str(&local_var_content).ok();
752 let local_var_error = ResponseContent {
753 status: local_var_status,
754 content: local_var_content,
755 entity: local_var_entity,
756 };
757 Err(Error::ResponseError(local_var_error))
758 }
759 }
760}
761
762#[derive(Debug, Clone, Serialize, Deserialize)]
764#[serde(untagged)]
765pub enum DeleteError {
766 UnknownValue(serde_json::Value),
767}
768#[derive(Debug, Clone, Serialize, Deserialize)]
770#[serde(untagged)]
771pub enum DeleteManyError {
772 UnknownValue(serde_json::Value),
773}
774#[derive(Debug, Clone, Serialize, Deserialize)]
776#[serde(untagged)]
777pub enum GetError {
778 UnknownValue(serde_json::Value),
779}
780#[derive(Debug, Clone, Serialize, Deserialize)]
782#[serde(untagged)]
783pub enum GetAllError {
784 UnknownValue(serde_json::Value),
785}
786#[derive(Debug, Clone, Serialize, Deserialize)]
788#[serde(untagged)]
789pub enum GetDetailsError {
790 UnknownValue(serde_json::Value),
791}
792#[derive(Debug, Clone, Serialize, Deserialize)]
794#[serde(untagged)]
795pub enum GetManyWithDetailsError {
796 UnknownValue(serde_json::Value),
797}
798#[derive(Debug, Clone, Serialize, Deserialize)]
800#[serde(untagged)]
801pub enum GetUserError {
802 UnknownValue(serde_json::Value),
803}
804#[derive(Debug, Clone, Serialize, Deserialize)]
806#[serde(untagged)]
807pub enum GetUsersError {
808 UnknownValue(serde_json::Value),
809}
810#[derive(Debug, Clone, Serialize, Deserialize)]
812#[serde(untagged)]
813pub enum PostError {
814 UnknownValue(serde_json::Value),
815}
816#[derive(Debug, Clone, Serialize, Deserialize)]
818#[serde(untagged)]
819pub enum PostBulkCollectionAccessError {
820 UnknownValue(serde_json::Value),
821}
822#[derive(Debug, Clone, Serialize, Deserialize)]
824#[serde(untagged)]
825pub enum PutError {
826 UnknownValue(serde_json::Value),
827}