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 AccessPoliciesApi: Send + Sync {
29 async fn get_people_potential_grantees<'a>(
31 &self,
32 id: uuid::Uuid,
33 ) -> Result<
34 models::PotentialGranteeResponseModelListResponseModel,
35 Error<GetPeoplePotentialGranteesError>,
36 >;
37
38 async fn get_project_people_access_policies<'a>(
40 &self,
41 id: uuid::Uuid,
42 ) -> Result<
43 models::ProjectPeopleAccessPoliciesResponseModel,
44 Error<GetProjectPeopleAccessPoliciesError>,
45 >;
46
47 async fn get_project_potential_grantees<'a>(
49 &self,
50 id: uuid::Uuid,
51 ) -> Result<
52 models::PotentialGranteeResponseModelListResponseModel,
53 Error<GetProjectPotentialGranteesError>,
54 >;
55
56 async fn get_project_service_accounts_access_policies<'a>(
58 &self,
59 id: uuid::Uuid,
60 ) -> Result<
61 models::ProjectServiceAccountsAccessPoliciesResponseModel,
62 Error<GetProjectServiceAccountsAccessPoliciesError>,
63 >;
64
65 async fn get_secret_access_policies<'a>(
67 &self,
68 secret_id: uuid::Uuid,
69 ) -> Result<models::SecretAccessPoliciesResponseModel, Error<GetSecretAccessPoliciesError>>;
70
71 async fn get_service_account_granted_policies<'a>(
73 &self,
74 id: uuid::Uuid,
75 ) -> Result<
76 models::ServiceAccountGrantedPoliciesPermissionDetailsResponseModel,
77 Error<GetServiceAccountGrantedPoliciesError>,
78 >;
79
80 async fn get_service_account_people_access_policies<'a>(
82 &self,
83 id: uuid::Uuid,
84 ) -> Result<
85 models::ServiceAccountPeopleAccessPoliciesResponseModel,
86 Error<GetServiceAccountPeopleAccessPoliciesError>,
87 >;
88
89 async fn get_service_accounts_potential_grantees<'a>(
91 &self,
92 id: uuid::Uuid,
93 ) -> Result<
94 models::PotentialGranteeResponseModelListResponseModel,
95 Error<GetServiceAccountsPotentialGranteesError>,
96 >;
97
98 async fn put_project_people_access_policies<'a>(
100 &self,
101 id: uuid::Uuid,
102 people_access_policies_request_model: Option<models::PeopleAccessPoliciesRequestModel>,
103 ) -> Result<
104 models::ProjectPeopleAccessPoliciesResponseModel,
105 Error<PutProjectPeopleAccessPoliciesError>,
106 >;
107
108 async fn put_project_service_accounts_access_policies<'a>(
110 &self,
111 id: uuid::Uuid,
112 project_service_accounts_access_policies_request_model: Option<
113 models::ProjectServiceAccountsAccessPoliciesRequestModel,
114 >,
115 ) -> Result<
116 models::ProjectServiceAccountsAccessPoliciesResponseModel,
117 Error<PutProjectServiceAccountsAccessPoliciesError>,
118 >;
119
120 async fn put_service_account_granted_policies<'a>(
122 &self,
123 id: uuid::Uuid,
124 service_account_granted_policies_request_model: Option<
125 models::ServiceAccountGrantedPoliciesRequestModel,
126 >,
127 ) -> Result<
128 models::ServiceAccountGrantedPoliciesPermissionDetailsResponseModel,
129 Error<PutServiceAccountGrantedPoliciesError>,
130 >;
131
132 async fn put_service_account_people_access_policies<'a>(
134 &self,
135 id: uuid::Uuid,
136 people_access_policies_request_model: Option<models::PeopleAccessPoliciesRequestModel>,
137 ) -> Result<
138 models::ServiceAccountPeopleAccessPoliciesResponseModel,
139 Error<PutServiceAccountPeopleAccessPoliciesError>,
140 >;
141}
142
143pub struct AccessPoliciesApiClient {
144 configuration: Arc<configuration::Configuration>,
145}
146
147impl AccessPoliciesApiClient {
148 pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
149 Self { configuration }
150 }
151}
152
153#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
154#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
155impl AccessPoliciesApi for AccessPoliciesApiClient {
156 async fn get_people_potential_grantees<'a>(
157 &self,
158 id: uuid::Uuid,
159 ) -> Result<
160 models::PotentialGranteeResponseModelListResponseModel,
161 Error<GetPeoplePotentialGranteesError>,
162 > {
163 let local_var_configuration = &self.configuration;
164
165 let local_var_client = &local_var_configuration.client;
166
167 let local_var_uri_str = format!(
168 "{}/organizations/{id}/access-policies/people/potential-grantees",
169 local_var_configuration.base_path,
170 id = id
171 );
172 let mut local_var_req_builder =
173 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
174
175 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
176
177 let local_var_resp = local_var_req_builder.send().await?;
178
179 let local_var_status = local_var_resp.status();
180 let local_var_content_type = local_var_resp
181 .headers()
182 .get("content-type")
183 .and_then(|v| v.to_str().ok())
184 .unwrap_or("application/octet-stream");
185 let local_var_content_type = super::ContentType::from(local_var_content_type);
186 let local_var_content = local_var_resp.text().await?;
187
188 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
189 match local_var_content_type {
190 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
191 ContentType::Text => {
192 return Err(Error::from(serde_json::Error::custom(
193 "Received `text/plain` content type response that cannot be converted to `models::PotentialGranteeResponseModelListResponseModel`",
194 )));
195 }
196 ContentType::Unsupported(local_var_unknown_type) => {
197 return Err(Error::from(serde_json::Error::custom(format!(
198 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::PotentialGranteeResponseModelListResponseModel`"
199 ))));
200 }
201 }
202 } else {
203 let local_var_entity: Option<GetPeoplePotentialGranteesError> =
204 serde_json::from_str(&local_var_content).ok();
205 let local_var_error = ResponseContent {
206 status: local_var_status,
207 content: local_var_content,
208 entity: local_var_entity,
209 };
210 Err(Error::ResponseError(local_var_error))
211 }
212 }
213
214 async fn get_project_people_access_policies<'a>(
215 &self,
216 id: uuid::Uuid,
217 ) -> Result<
218 models::ProjectPeopleAccessPoliciesResponseModel,
219 Error<GetProjectPeopleAccessPoliciesError>,
220 > {
221 let local_var_configuration = &self.configuration;
222
223 let local_var_client = &local_var_configuration.client;
224
225 let local_var_uri_str = format!(
226 "{}/projects/{id}/access-policies/people",
227 local_var_configuration.base_path,
228 id = id
229 );
230 let mut local_var_req_builder =
231 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
232
233 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
234
235 let local_var_resp = local_var_req_builder.send().await?;
236
237 let local_var_status = local_var_resp.status();
238 let local_var_content_type = local_var_resp
239 .headers()
240 .get("content-type")
241 .and_then(|v| v.to_str().ok())
242 .unwrap_or("application/octet-stream");
243 let local_var_content_type = super::ContentType::from(local_var_content_type);
244 let local_var_content = local_var_resp.text().await?;
245
246 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
247 match local_var_content_type {
248 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
249 ContentType::Text => {
250 return Err(Error::from(serde_json::Error::custom(
251 "Received `text/plain` content type response that cannot be converted to `models::ProjectPeopleAccessPoliciesResponseModel`",
252 )));
253 }
254 ContentType::Unsupported(local_var_unknown_type) => {
255 return Err(Error::from(serde_json::Error::custom(format!(
256 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ProjectPeopleAccessPoliciesResponseModel`"
257 ))));
258 }
259 }
260 } else {
261 let local_var_entity: Option<GetProjectPeopleAccessPoliciesError> =
262 serde_json::from_str(&local_var_content).ok();
263 let local_var_error = ResponseContent {
264 status: local_var_status,
265 content: local_var_content,
266 entity: local_var_entity,
267 };
268 Err(Error::ResponseError(local_var_error))
269 }
270 }
271
272 async fn get_project_potential_grantees<'a>(
273 &self,
274 id: uuid::Uuid,
275 ) -> Result<
276 models::PotentialGranteeResponseModelListResponseModel,
277 Error<GetProjectPotentialGranteesError>,
278 > {
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/{id}/access-policies/projects/potential-grantees",
285 local_var_configuration.base_path,
286 id = 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 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
292
293 let local_var_resp = local_var_req_builder.send().await?;
294
295 let local_var_status = local_var_resp.status();
296 let local_var_content_type = local_var_resp
297 .headers()
298 .get("content-type")
299 .and_then(|v| v.to_str().ok())
300 .unwrap_or("application/octet-stream");
301 let local_var_content_type = super::ContentType::from(local_var_content_type);
302 let local_var_content = local_var_resp.text().await?;
303
304 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
305 match local_var_content_type {
306 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
307 ContentType::Text => {
308 return Err(Error::from(serde_json::Error::custom(
309 "Received `text/plain` content type response that cannot be converted to `models::PotentialGranteeResponseModelListResponseModel`",
310 )));
311 }
312 ContentType::Unsupported(local_var_unknown_type) => {
313 return Err(Error::from(serde_json::Error::custom(format!(
314 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::PotentialGranteeResponseModelListResponseModel`"
315 ))));
316 }
317 }
318 } else {
319 let local_var_entity: Option<GetProjectPotentialGranteesError> =
320 serde_json::from_str(&local_var_content).ok();
321 let local_var_error = ResponseContent {
322 status: local_var_status,
323 content: local_var_content,
324 entity: local_var_entity,
325 };
326 Err(Error::ResponseError(local_var_error))
327 }
328 }
329
330 async fn get_project_service_accounts_access_policies<'a>(
331 &self,
332 id: uuid::Uuid,
333 ) -> Result<
334 models::ProjectServiceAccountsAccessPoliciesResponseModel,
335 Error<GetProjectServiceAccountsAccessPoliciesError>,
336 > {
337 let local_var_configuration = &self.configuration;
338
339 let local_var_client = &local_var_configuration.client;
340
341 let local_var_uri_str = format!(
342 "{}/projects/{id}/access-policies/service-accounts",
343 local_var_configuration.base_path,
344 id = id
345 );
346 let mut local_var_req_builder =
347 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
348
349 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
350
351 let local_var_resp = local_var_req_builder.send().await?;
352
353 let local_var_status = local_var_resp.status();
354 let local_var_content_type = local_var_resp
355 .headers()
356 .get("content-type")
357 .and_then(|v| v.to_str().ok())
358 .unwrap_or("application/octet-stream");
359 let local_var_content_type = super::ContentType::from(local_var_content_type);
360 let local_var_content = local_var_resp.text().await?;
361
362 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
363 match local_var_content_type {
364 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
365 ContentType::Text => {
366 return Err(Error::from(serde_json::Error::custom(
367 "Received `text/plain` content type response that cannot be converted to `models::ProjectServiceAccountsAccessPoliciesResponseModel`",
368 )));
369 }
370 ContentType::Unsupported(local_var_unknown_type) => {
371 return Err(Error::from(serde_json::Error::custom(format!(
372 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ProjectServiceAccountsAccessPoliciesResponseModel`"
373 ))));
374 }
375 }
376 } else {
377 let local_var_entity: Option<GetProjectServiceAccountsAccessPoliciesError> =
378 serde_json::from_str(&local_var_content).ok();
379 let local_var_error = ResponseContent {
380 status: local_var_status,
381 content: local_var_content,
382 entity: local_var_entity,
383 };
384 Err(Error::ResponseError(local_var_error))
385 }
386 }
387
388 async fn get_secret_access_policies<'a>(
389 &self,
390 secret_id: uuid::Uuid,
391 ) -> Result<models::SecretAccessPoliciesResponseModel, Error<GetSecretAccessPoliciesError>>
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 "{}/secrets/{secretId}/access-policies",
399 local_var_configuration.base_path,
400 secretId = secret_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 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
406
407 let local_var_resp = local_var_req_builder.send().await?;
408
409 let local_var_status = local_var_resp.status();
410 let local_var_content_type = local_var_resp
411 .headers()
412 .get("content-type")
413 .and_then(|v| v.to_str().ok())
414 .unwrap_or("application/octet-stream");
415 let local_var_content_type = super::ContentType::from(local_var_content_type);
416 let local_var_content = local_var_resp.text().await?;
417
418 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
419 match local_var_content_type {
420 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
421 ContentType::Text => {
422 return Err(Error::from(serde_json::Error::custom(
423 "Received `text/plain` content type response that cannot be converted to `models::SecretAccessPoliciesResponseModel`",
424 )));
425 }
426 ContentType::Unsupported(local_var_unknown_type) => {
427 return Err(Error::from(serde_json::Error::custom(format!(
428 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::SecretAccessPoliciesResponseModel`"
429 ))));
430 }
431 }
432 } else {
433 let local_var_entity: Option<GetSecretAccessPoliciesError> =
434 serde_json::from_str(&local_var_content).ok();
435 let local_var_error = ResponseContent {
436 status: local_var_status,
437 content: local_var_content,
438 entity: local_var_entity,
439 };
440 Err(Error::ResponseError(local_var_error))
441 }
442 }
443
444 async fn get_service_account_granted_policies<'a>(
445 &self,
446 id: uuid::Uuid,
447 ) -> Result<
448 models::ServiceAccountGrantedPoliciesPermissionDetailsResponseModel,
449 Error<GetServiceAccountGrantedPoliciesError>,
450 > {
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!(
456 "{}/service-accounts/{id}/granted-policies",
457 local_var_configuration.base_path,
458 id = id
459 );
460 let mut local_var_req_builder =
461 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
462
463 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
464
465 let local_var_resp = local_var_req_builder.send().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::ServiceAccountGrantedPoliciesPermissionDetailsResponseModel`",
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::ServiceAccountGrantedPoliciesPermissionDetailsResponseModel`"
487 ))));
488 }
489 }
490 } else {
491 let local_var_entity: Option<GetServiceAccountGrantedPoliciesError> =
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_service_account_people_access_policies<'a>(
503 &self,
504 id: uuid::Uuid,
505 ) -> Result<
506 models::ServiceAccountPeopleAccessPoliciesResponseModel,
507 Error<GetServiceAccountPeopleAccessPoliciesError>,
508 > {
509 let local_var_configuration = &self.configuration;
510
511 let local_var_client = &local_var_configuration.client;
512
513 let local_var_uri_str = format!(
514 "{}/service-accounts/{id}/access-policies/people",
515 local_var_configuration.base_path,
516 id = id
517 );
518 let mut local_var_req_builder =
519 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
520
521 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
522
523 let local_var_resp = local_var_req_builder.send().await?;
524
525 let local_var_status = local_var_resp.status();
526 let local_var_content_type = local_var_resp
527 .headers()
528 .get("content-type")
529 .and_then(|v| v.to_str().ok())
530 .unwrap_or("application/octet-stream");
531 let local_var_content_type = super::ContentType::from(local_var_content_type);
532 let local_var_content = local_var_resp.text().await?;
533
534 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
535 match local_var_content_type {
536 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
537 ContentType::Text => {
538 return Err(Error::from(serde_json::Error::custom(
539 "Received `text/plain` content type response that cannot be converted to `models::ServiceAccountPeopleAccessPoliciesResponseModel`",
540 )));
541 }
542 ContentType::Unsupported(local_var_unknown_type) => {
543 return Err(Error::from(serde_json::Error::custom(format!(
544 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ServiceAccountPeopleAccessPoliciesResponseModel`"
545 ))));
546 }
547 }
548 } else {
549 let local_var_entity: Option<GetServiceAccountPeopleAccessPoliciesError> =
550 serde_json::from_str(&local_var_content).ok();
551 let local_var_error = ResponseContent {
552 status: local_var_status,
553 content: local_var_content,
554 entity: local_var_entity,
555 };
556 Err(Error::ResponseError(local_var_error))
557 }
558 }
559
560 async fn get_service_accounts_potential_grantees<'a>(
561 &self,
562 id: uuid::Uuid,
563 ) -> Result<
564 models::PotentialGranteeResponseModelListResponseModel,
565 Error<GetServiceAccountsPotentialGranteesError>,
566 > {
567 let local_var_configuration = &self.configuration;
568
569 let local_var_client = &local_var_configuration.client;
570
571 let local_var_uri_str = format!(
572 "{}/organizations/{id}/access-policies/service-accounts/potential-grantees",
573 local_var_configuration.base_path,
574 id = id
575 );
576 let mut local_var_req_builder =
577 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
578
579 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
580
581 let local_var_resp = local_var_req_builder.send().await?;
582
583 let local_var_status = local_var_resp.status();
584 let local_var_content_type = local_var_resp
585 .headers()
586 .get("content-type")
587 .and_then(|v| v.to_str().ok())
588 .unwrap_or("application/octet-stream");
589 let local_var_content_type = super::ContentType::from(local_var_content_type);
590 let local_var_content = local_var_resp.text().await?;
591
592 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
593 match local_var_content_type {
594 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
595 ContentType::Text => {
596 return Err(Error::from(serde_json::Error::custom(
597 "Received `text/plain` content type response that cannot be converted to `models::PotentialGranteeResponseModelListResponseModel`",
598 )));
599 }
600 ContentType::Unsupported(local_var_unknown_type) => {
601 return Err(Error::from(serde_json::Error::custom(format!(
602 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::PotentialGranteeResponseModelListResponseModel`"
603 ))));
604 }
605 }
606 } else {
607 let local_var_entity: Option<GetServiceAccountsPotentialGranteesError> =
608 serde_json::from_str(&local_var_content).ok();
609 let local_var_error = ResponseContent {
610 status: local_var_status,
611 content: local_var_content,
612 entity: local_var_entity,
613 };
614 Err(Error::ResponseError(local_var_error))
615 }
616 }
617
618 async fn put_project_people_access_policies<'a>(
619 &self,
620 id: uuid::Uuid,
621 people_access_policies_request_model: Option<models::PeopleAccessPoliciesRequestModel>,
622 ) -> Result<
623 models::ProjectPeopleAccessPoliciesResponseModel,
624 Error<PutProjectPeopleAccessPoliciesError>,
625 > {
626 let local_var_configuration = &self.configuration;
627
628 let local_var_client = &local_var_configuration.client;
629
630 let local_var_uri_str = format!(
631 "{}/projects/{id}/access-policies/people",
632 local_var_configuration.base_path,
633 id = id
634 );
635 let mut local_var_req_builder =
636 local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
637
638 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
639 local_var_req_builder = local_var_req_builder.json(&people_access_policies_request_model);
640
641 let local_var_resp = local_var_req_builder.send().await?;
642
643 let local_var_status = local_var_resp.status();
644 let local_var_content_type = local_var_resp
645 .headers()
646 .get("content-type")
647 .and_then(|v| v.to_str().ok())
648 .unwrap_or("application/octet-stream");
649 let local_var_content_type = super::ContentType::from(local_var_content_type);
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 match local_var_content_type {
654 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
655 ContentType::Text => {
656 return Err(Error::from(serde_json::Error::custom(
657 "Received `text/plain` content type response that cannot be converted to `models::ProjectPeopleAccessPoliciesResponseModel`",
658 )));
659 }
660 ContentType::Unsupported(local_var_unknown_type) => {
661 return Err(Error::from(serde_json::Error::custom(format!(
662 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ProjectPeopleAccessPoliciesResponseModel`"
663 ))));
664 }
665 }
666 } else {
667 let local_var_entity: Option<PutProjectPeopleAccessPoliciesError> =
668 serde_json::from_str(&local_var_content).ok();
669 let local_var_error = ResponseContent {
670 status: local_var_status,
671 content: local_var_content,
672 entity: local_var_entity,
673 };
674 Err(Error::ResponseError(local_var_error))
675 }
676 }
677
678 async fn put_project_service_accounts_access_policies<'a>(
679 &self,
680 id: uuid::Uuid,
681 project_service_accounts_access_policies_request_model: Option<
682 models::ProjectServiceAccountsAccessPoliciesRequestModel,
683 >,
684 ) -> Result<
685 models::ProjectServiceAccountsAccessPoliciesResponseModel,
686 Error<PutProjectServiceAccountsAccessPoliciesError>,
687 > {
688 let local_var_configuration = &self.configuration;
689
690 let local_var_client = &local_var_configuration.client;
691
692 let local_var_uri_str = format!(
693 "{}/projects/{id}/access-policies/service-accounts",
694 local_var_configuration.base_path,
695 id = id
696 );
697 let mut local_var_req_builder =
698 local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
699
700 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
701 local_var_req_builder =
702 local_var_req_builder.json(&project_service_accounts_access_policies_request_model);
703
704 let local_var_resp = local_var_req_builder.send().await?;
705
706 let local_var_status = local_var_resp.status();
707 let local_var_content_type = local_var_resp
708 .headers()
709 .get("content-type")
710 .and_then(|v| v.to_str().ok())
711 .unwrap_or("application/octet-stream");
712 let local_var_content_type = super::ContentType::from(local_var_content_type);
713 let local_var_content = local_var_resp.text().await?;
714
715 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
716 match local_var_content_type {
717 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
718 ContentType::Text => {
719 return Err(Error::from(serde_json::Error::custom(
720 "Received `text/plain` content type response that cannot be converted to `models::ProjectServiceAccountsAccessPoliciesResponseModel`",
721 )));
722 }
723 ContentType::Unsupported(local_var_unknown_type) => {
724 return Err(Error::from(serde_json::Error::custom(format!(
725 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ProjectServiceAccountsAccessPoliciesResponseModel`"
726 ))));
727 }
728 }
729 } else {
730 let local_var_entity: Option<PutProjectServiceAccountsAccessPoliciesError> =
731 serde_json::from_str(&local_var_content).ok();
732 let local_var_error = ResponseContent {
733 status: local_var_status,
734 content: local_var_content,
735 entity: local_var_entity,
736 };
737 Err(Error::ResponseError(local_var_error))
738 }
739 }
740
741 async fn put_service_account_granted_policies<'a>(
742 &self,
743 id: uuid::Uuid,
744 service_account_granted_policies_request_model: Option<
745 models::ServiceAccountGrantedPoliciesRequestModel,
746 >,
747 ) -> Result<
748 models::ServiceAccountGrantedPoliciesPermissionDetailsResponseModel,
749 Error<PutServiceAccountGrantedPoliciesError>,
750 > {
751 let local_var_configuration = &self.configuration;
752
753 let local_var_client = &local_var_configuration.client;
754
755 let local_var_uri_str = format!(
756 "{}/service-accounts/{id}/granted-policies",
757 local_var_configuration.base_path,
758 id = id
759 );
760 let mut local_var_req_builder =
761 local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
762
763 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
764 local_var_req_builder =
765 local_var_req_builder.json(&service_account_granted_policies_request_model);
766
767 let local_var_resp = local_var_req_builder.send().await?;
768
769 let local_var_status = local_var_resp.status();
770 let local_var_content_type = local_var_resp
771 .headers()
772 .get("content-type")
773 .and_then(|v| v.to_str().ok())
774 .unwrap_or("application/octet-stream");
775 let local_var_content_type = super::ContentType::from(local_var_content_type);
776 let local_var_content = local_var_resp.text().await?;
777
778 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
779 match local_var_content_type {
780 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
781 ContentType::Text => {
782 return Err(Error::from(serde_json::Error::custom(
783 "Received `text/plain` content type response that cannot be converted to `models::ServiceAccountGrantedPoliciesPermissionDetailsResponseModel`",
784 )));
785 }
786 ContentType::Unsupported(local_var_unknown_type) => {
787 return Err(Error::from(serde_json::Error::custom(format!(
788 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ServiceAccountGrantedPoliciesPermissionDetailsResponseModel`"
789 ))));
790 }
791 }
792 } else {
793 let local_var_entity: Option<PutServiceAccountGrantedPoliciesError> =
794 serde_json::from_str(&local_var_content).ok();
795 let local_var_error = ResponseContent {
796 status: local_var_status,
797 content: local_var_content,
798 entity: local_var_entity,
799 };
800 Err(Error::ResponseError(local_var_error))
801 }
802 }
803
804 async fn put_service_account_people_access_policies<'a>(
805 &self,
806 id: uuid::Uuid,
807 people_access_policies_request_model: Option<models::PeopleAccessPoliciesRequestModel>,
808 ) -> Result<
809 models::ServiceAccountPeopleAccessPoliciesResponseModel,
810 Error<PutServiceAccountPeopleAccessPoliciesError>,
811 > {
812 let local_var_configuration = &self.configuration;
813
814 let local_var_client = &local_var_configuration.client;
815
816 let local_var_uri_str = format!(
817 "{}/service-accounts/{id}/access-policies/people",
818 local_var_configuration.base_path,
819 id = id
820 );
821 let mut local_var_req_builder =
822 local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
823
824 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
825 local_var_req_builder = local_var_req_builder.json(&people_access_policies_request_model);
826
827 let local_var_resp = local_var_req_builder.send().await?;
828
829 let local_var_status = local_var_resp.status();
830 let local_var_content_type = local_var_resp
831 .headers()
832 .get("content-type")
833 .and_then(|v| v.to_str().ok())
834 .unwrap_or("application/octet-stream");
835 let local_var_content_type = super::ContentType::from(local_var_content_type);
836 let local_var_content = local_var_resp.text().await?;
837
838 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
839 match local_var_content_type {
840 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
841 ContentType::Text => {
842 return Err(Error::from(serde_json::Error::custom(
843 "Received `text/plain` content type response that cannot be converted to `models::ServiceAccountPeopleAccessPoliciesResponseModel`",
844 )));
845 }
846 ContentType::Unsupported(local_var_unknown_type) => {
847 return Err(Error::from(serde_json::Error::custom(format!(
848 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ServiceAccountPeopleAccessPoliciesResponseModel`"
849 ))));
850 }
851 }
852 } else {
853 let local_var_entity: Option<PutServiceAccountPeopleAccessPoliciesError> =
854 serde_json::from_str(&local_var_content).ok();
855 let local_var_error = ResponseContent {
856 status: local_var_status,
857 content: local_var_content,
858 entity: local_var_entity,
859 };
860 Err(Error::ResponseError(local_var_error))
861 }
862 }
863}
864
865#[derive(Debug, Clone, Serialize, Deserialize)]
867#[serde(untagged)]
868pub enum GetPeoplePotentialGranteesError {
869 UnknownValue(serde_json::Value),
870}
871#[derive(Debug, Clone, Serialize, Deserialize)]
873#[serde(untagged)]
874pub enum GetProjectPeopleAccessPoliciesError {
875 UnknownValue(serde_json::Value),
876}
877#[derive(Debug, Clone, Serialize, Deserialize)]
879#[serde(untagged)]
880pub enum GetProjectPotentialGranteesError {
881 UnknownValue(serde_json::Value),
882}
883#[derive(Debug, Clone, Serialize, Deserialize)]
886#[serde(untagged)]
887pub enum GetProjectServiceAccountsAccessPoliciesError {
888 UnknownValue(serde_json::Value),
889}
890#[derive(Debug, Clone, Serialize, Deserialize)]
892#[serde(untagged)]
893pub enum GetSecretAccessPoliciesError {
894 UnknownValue(serde_json::Value),
895}
896#[derive(Debug, Clone, Serialize, Deserialize)]
898#[serde(untagged)]
899pub enum GetServiceAccountGrantedPoliciesError {
900 UnknownValue(serde_json::Value),
901}
902#[derive(Debug, Clone, Serialize, Deserialize)]
905#[serde(untagged)]
906pub enum GetServiceAccountPeopleAccessPoliciesError {
907 UnknownValue(serde_json::Value),
908}
909#[derive(Debug, Clone, Serialize, Deserialize)]
911#[serde(untagged)]
912pub enum GetServiceAccountsPotentialGranteesError {
913 UnknownValue(serde_json::Value),
914}
915#[derive(Debug, Clone, Serialize, Deserialize)]
917#[serde(untagged)]
918pub enum PutProjectPeopleAccessPoliciesError {
919 UnknownValue(serde_json::Value),
920}
921#[derive(Debug, Clone, Serialize, Deserialize)]
924#[serde(untagged)]
925pub enum PutProjectServiceAccountsAccessPoliciesError {
926 UnknownValue(serde_json::Value),
927}
928#[derive(Debug, Clone, Serialize, Deserialize)]
930#[serde(untagged)]
931pub enum PutServiceAccountGrantedPoliciesError {
932 UnknownValue(serde_json::Value),
933}
934#[derive(Debug, Clone, Serialize, Deserialize)]
937#[serde(untagged)]
938pub enum PutServiceAccountPeopleAccessPoliciesError {
939 UnknownValue(serde_json::Value),
940}