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 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
176 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
177 };
178 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
179
180 let local_var_req = local_var_req_builder.build()?;
181 let local_var_resp = local_var_client.execute(local_var_req).await?;
182
183 let local_var_status = local_var_resp.status();
184 let local_var_content_type = local_var_resp
185 .headers()
186 .get("content-type")
187 .and_then(|v| v.to_str().ok())
188 .unwrap_or("application/octet-stream");
189 let local_var_content_type = super::ContentType::from(local_var_content_type);
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 match local_var_content_type {
194 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
195 ContentType::Text => {
196 return Err(Error::from(serde_json::Error::custom(
197 "Received `text/plain` content type response that cannot be converted to `models::PotentialGranteeResponseModelListResponseModel`",
198 )));
199 }
200 ContentType::Unsupported(local_var_unknown_type) => {
201 return Err(Error::from(serde_json::Error::custom(format!(
202 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::PotentialGranteeResponseModelListResponseModel`"
203 ))));
204 }
205 }
206 } else {
207 let local_var_entity: Option<GetPeoplePotentialGranteesError> =
208 serde_json::from_str(&local_var_content).ok();
209 let local_var_error = ResponseContent {
210 status: local_var_status,
211 content: local_var_content,
212 entity: local_var_entity,
213 };
214 Err(Error::ResponseError(local_var_error))
215 }
216 }
217
218 async fn get_project_people_access_policies<'a>(
219 &self,
220 id: uuid::Uuid,
221 ) -> Result<
222 models::ProjectPeopleAccessPoliciesResponseModel,
223 Error<GetProjectPeopleAccessPoliciesError>,
224 > {
225 let local_var_configuration = &self.configuration;
226
227 let local_var_client = &local_var_configuration.client;
228
229 let local_var_uri_str = format!(
230 "{}/projects/{id}/access-policies/people",
231 local_var_configuration.base_path,
232 id = id
233 );
234 let mut local_var_req_builder =
235 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
236
237 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
238 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
239 };
240 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
241
242 let local_var_req = local_var_req_builder.build()?;
243 let local_var_resp = local_var_client.execute(local_var_req).await?;
244
245 let local_var_status = local_var_resp.status();
246 let local_var_content_type = local_var_resp
247 .headers()
248 .get("content-type")
249 .and_then(|v| v.to_str().ok())
250 .unwrap_or("application/octet-stream");
251 let local_var_content_type = super::ContentType::from(local_var_content_type);
252 let local_var_content = local_var_resp.text().await?;
253
254 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
255 match local_var_content_type {
256 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
257 ContentType::Text => {
258 return Err(Error::from(serde_json::Error::custom(
259 "Received `text/plain` content type response that cannot be converted to `models::ProjectPeopleAccessPoliciesResponseModel`",
260 )));
261 }
262 ContentType::Unsupported(local_var_unknown_type) => {
263 return Err(Error::from(serde_json::Error::custom(format!(
264 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ProjectPeopleAccessPoliciesResponseModel`"
265 ))));
266 }
267 }
268 } else {
269 let local_var_entity: Option<GetProjectPeopleAccessPoliciesError> =
270 serde_json::from_str(&local_var_content).ok();
271 let local_var_error = ResponseContent {
272 status: local_var_status,
273 content: local_var_content,
274 entity: local_var_entity,
275 };
276 Err(Error::ResponseError(local_var_error))
277 }
278 }
279
280 async fn get_project_potential_grantees<'a>(
281 &self,
282 id: uuid::Uuid,
283 ) -> Result<
284 models::PotentialGranteeResponseModelListResponseModel,
285 Error<GetProjectPotentialGranteesError>,
286 > {
287 let local_var_configuration = &self.configuration;
288
289 let local_var_client = &local_var_configuration.client;
290
291 let local_var_uri_str = format!(
292 "{}/organizations/{id}/access-policies/projects/potential-grantees",
293 local_var_configuration.base_path,
294 id = id
295 );
296 let mut local_var_req_builder =
297 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
298
299 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
300 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
301 };
302 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
303
304 let local_var_req = local_var_req_builder.build()?;
305 let local_var_resp = local_var_client.execute(local_var_req).await?;
306
307 let local_var_status = local_var_resp.status();
308 let local_var_content_type = local_var_resp
309 .headers()
310 .get("content-type")
311 .and_then(|v| v.to_str().ok())
312 .unwrap_or("application/octet-stream");
313 let local_var_content_type = super::ContentType::from(local_var_content_type);
314 let local_var_content = local_var_resp.text().await?;
315
316 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
317 match local_var_content_type {
318 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
319 ContentType::Text => {
320 return Err(Error::from(serde_json::Error::custom(
321 "Received `text/plain` content type response that cannot be converted to `models::PotentialGranteeResponseModelListResponseModel`",
322 )));
323 }
324 ContentType::Unsupported(local_var_unknown_type) => {
325 return Err(Error::from(serde_json::Error::custom(format!(
326 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::PotentialGranteeResponseModelListResponseModel`"
327 ))));
328 }
329 }
330 } else {
331 let local_var_entity: Option<GetProjectPotentialGranteesError> =
332 serde_json::from_str(&local_var_content).ok();
333 let local_var_error = ResponseContent {
334 status: local_var_status,
335 content: local_var_content,
336 entity: local_var_entity,
337 };
338 Err(Error::ResponseError(local_var_error))
339 }
340 }
341
342 async fn get_project_service_accounts_access_policies<'a>(
343 &self,
344 id: uuid::Uuid,
345 ) -> Result<
346 models::ProjectServiceAccountsAccessPoliciesResponseModel,
347 Error<GetProjectServiceAccountsAccessPoliciesError>,
348 > {
349 let local_var_configuration = &self.configuration;
350
351 let local_var_client = &local_var_configuration.client;
352
353 let local_var_uri_str = format!(
354 "{}/projects/{id}/access-policies/service-accounts",
355 local_var_configuration.base_path,
356 id = id
357 );
358 let mut local_var_req_builder =
359 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
360
361 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
362 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
363 };
364 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
365
366 let local_var_req = local_var_req_builder.build()?;
367 let local_var_resp = local_var_client.execute(local_var_req).await?;
368
369 let local_var_status = local_var_resp.status();
370 let local_var_content_type = local_var_resp
371 .headers()
372 .get("content-type")
373 .and_then(|v| v.to_str().ok())
374 .unwrap_or("application/octet-stream");
375 let local_var_content_type = super::ContentType::from(local_var_content_type);
376 let local_var_content = local_var_resp.text().await?;
377
378 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
379 match local_var_content_type {
380 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
381 ContentType::Text => {
382 return Err(Error::from(serde_json::Error::custom(
383 "Received `text/plain` content type response that cannot be converted to `models::ProjectServiceAccountsAccessPoliciesResponseModel`",
384 )));
385 }
386 ContentType::Unsupported(local_var_unknown_type) => {
387 return Err(Error::from(serde_json::Error::custom(format!(
388 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ProjectServiceAccountsAccessPoliciesResponseModel`"
389 ))));
390 }
391 }
392 } else {
393 let local_var_entity: Option<GetProjectServiceAccountsAccessPoliciesError> =
394 serde_json::from_str(&local_var_content).ok();
395 let local_var_error = ResponseContent {
396 status: local_var_status,
397 content: local_var_content,
398 entity: local_var_entity,
399 };
400 Err(Error::ResponseError(local_var_error))
401 }
402 }
403
404 async fn get_secret_access_policies<'a>(
405 &self,
406 secret_id: uuid::Uuid,
407 ) -> Result<models::SecretAccessPoliciesResponseModel, Error<GetSecretAccessPoliciesError>>
408 {
409 let local_var_configuration = &self.configuration;
410
411 let local_var_client = &local_var_configuration.client;
412
413 let local_var_uri_str = format!(
414 "{}/secrets/{secretId}/access-policies",
415 local_var_configuration.base_path,
416 secretId = secret_id
417 );
418 let mut local_var_req_builder =
419 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
420
421 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
422 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
423 };
424 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
425
426 let local_var_req = local_var_req_builder.build()?;
427 let local_var_resp = local_var_client.execute(local_var_req).await?;
428
429 let local_var_status = local_var_resp.status();
430 let local_var_content_type = local_var_resp
431 .headers()
432 .get("content-type")
433 .and_then(|v| v.to_str().ok())
434 .unwrap_or("application/octet-stream");
435 let local_var_content_type = super::ContentType::from(local_var_content_type);
436 let local_var_content = local_var_resp.text().await?;
437
438 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
439 match local_var_content_type {
440 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
441 ContentType::Text => {
442 return Err(Error::from(serde_json::Error::custom(
443 "Received `text/plain` content type response that cannot be converted to `models::SecretAccessPoliciesResponseModel`",
444 )));
445 }
446 ContentType::Unsupported(local_var_unknown_type) => {
447 return Err(Error::from(serde_json::Error::custom(format!(
448 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::SecretAccessPoliciesResponseModel`"
449 ))));
450 }
451 }
452 } else {
453 let local_var_entity: Option<GetSecretAccessPoliciesError> =
454 serde_json::from_str(&local_var_content).ok();
455 let local_var_error = ResponseContent {
456 status: local_var_status,
457 content: local_var_content,
458 entity: local_var_entity,
459 };
460 Err(Error::ResponseError(local_var_error))
461 }
462 }
463
464 async fn get_service_account_granted_policies<'a>(
465 &self,
466 id: uuid::Uuid,
467 ) -> Result<
468 models::ServiceAccountGrantedPoliciesPermissionDetailsResponseModel,
469 Error<GetServiceAccountGrantedPoliciesError>,
470 > {
471 let local_var_configuration = &self.configuration;
472
473 let local_var_client = &local_var_configuration.client;
474
475 let local_var_uri_str = format!(
476 "{}/service-accounts/{id}/granted-policies",
477 local_var_configuration.base_path,
478 id = id
479 );
480 let mut local_var_req_builder =
481 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
482
483 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
484 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
485 };
486 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
487
488 let local_var_req = local_var_req_builder.build()?;
489 let local_var_resp = local_var_client.execute(local_var_req).await?;
490
491 let local_var_status = local_var_resp.status();
492 let local_var_content_type = local_var_resp
493 .headers()
494 .get("content-type")
495 .and_then(|v| v.to_str().ok())
496 .unwrap_or("application/octet-stream");
497 let local_var_content_type = super::ContentType::from(local_var_content_type);
498 let local_var_content = local_var_resp.text().await?;
499
500 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
501 match local_var_content_type {
502 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
503 ContentType::Text => {
504 return Err(Error::from(serde_json::Error::custom(
505 "Received `text/plain` content type response that cannot be converted to `models::ServiceAccountGrantedPoliciesPermissionDetailsResponseModel`",
506 )));
507 }
508 ContentType::Unsupported(local_var_unknown_type) => {
509 return Err(Error::from(serde_json::Error::custom(format!(
510 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ServiceAccountGrantedPoliciesPermissionDetailsResponseModel`"
511 ))));
512 }
513 }
514 } else {
515 let local_var_entity: Option<GetServiceAccountGrantedPoliciesError> =
516 serde_json::from_str(&local_var_content).ok();
517 let local_var_error = ResponseContent {
518 status: local_var_status,
519 content: local_var_content,
520 entity: local_var_entity,
521 };
522 Err(Error::ResponseError(local_var_error))
523 }
524 }
525
526 async fn get_service_account_people_access_policies<'a>(
527 &self,
528 id: uuid::Uuid,
529 ) -> Result<
530 models::ServiceAccountPeopleAccessPoliciesResponseModel,
531 Error<GetServiceAccountPeopleAccessPoliciesError>,
532 > {
533 let local_var_configuration = &self.configuration;
534
535 let local_var_client = &local_var_configuration.client;
536
537 let local_var_uri_str = format!(
538 "{}/service-accounts/{id}/access-policies/people",
539 local_var_configuration.base_path,
540 id = id
541 );
542 let mut local_var_req_builder =
543 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
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 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
549
550 let local_var_req = local_var_req_builder.build()?;
551 let local_var_resp = local_var_client.execute(local_var_req).await?;
552
553 let local_var_status = local_var_resp.status();
554 let local_var_content_type = local_var_resp
555 .headers()
556 .get("content-type")
557 .and_then(|v| v.to_str().ok())
558 .unwrap_or("application/octet-stream");
559 let local_var_content_type = super::ContentType::from(local_var_content_type);
560 let local_var_content = local_var_resp.text().await?;
561
562 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
563 match local_var_content_type {
564 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
565 ContentType::Text => {
566 return Err(Error::from(serde_json::Error::custom(
567 "Received `text/plain` content type response that cannot be converted to `models::ServiceAccountPeopleAccessPoliciesResponseModel`",
568 )));
569 }
570 ContentType::Unsupported(local_var_unknown_type) => {
571 return Err(Error::from(serde_json::Error::custom(format!(
572 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ServiceAccountPeopleAccessPoliciesResponseModel`"
573 ))));
574 }
575 }
576 } else {
577 let local_var_entity: Option<GetServiceAccountPeopleAccessPoliciesError> =
578 serde_json::from_str(&local_var_content).ok();
579 let local_var_error = ResponseContent {
580 status: local_var_status,
581 content: local_var_content,
582 entity: local_var_entity,
583 };
584 Err(Error::ResponseError(local_var_error))
585 }
586 }
587
588 async fn get_service_accounts_potential_grantees<'a>(
589 &self,
590 id: uuid::Uuid,
591 ) -> Result<
592 models::PotentialGranteeResponseModelListResponseModel,
593 Error<GetServiceAccountsPotentialGranteesError>,
594 > {
595 let local_var_configuration = &self.configuration;
596
597 let local_var_client = &local_var_configuration.client;
598
599 let local_var_uri_str = format!(
600 "{}/organizations/{id}/access-policies/service-accounts/potential-grantees",
601 local_var_configuration.base_path,
602 id = id
603 );
604 let mut local_var_req_builder =
605 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
606
607 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
608 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
609 };
610 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
611
612 let local_var_req = local_var_req_builder.build()?;
613 let local_var_resp = local_var_client.execute(local_var_req).await?;
614
615 let local_var_status = local_var_resp.status();
616 let local_var_content_type = local_var_resp
617 .headers()
618 .get("content-type")
619 .and_then(|v| v.to_str().ok())
620 .unwrap_or("application/octet-stream");
621 let local_var_content_type = super::ContentType::from(local_var_content_type);
622 let local_var_content = local_var_resp.text().await?;
623
624 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
625 match local_var_content_type {
626 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
627 ContentType::Text => {
628 return Err(Error::from(serde_json::Error::custom(
629 "Received `text/plain` content type response that cannot be converted to `models::PotentialGranteeResponseModelListResponseModel`",
630 )));
631 }
632 ContentType::Unsupported(local_var_unknown_type) => {
633 return Err(Error::from(serde_json::Error::custom(format!(
634 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::PotentialGranteeResponseModelListResponseModel`"
635 ))));
636 }
637 }
638 } else {
639 let local_var_entity: Option<GetServiceAccountsPotentialGranteesError> =
640 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 put_project_people_access_policies<'a>(
651 &self,
652 id: uuid::Uuid,
653 people_access_policies_request_model: Option<models::PeopleAccessPoliciesRequestModel>,
654 ) -> Result<
655 models::ProjectPeopleAccessPoliciesResponseModel,
656 Error<PutProjectPeopleAccessPoliciesError>,
657 > {
658 let local_var_configuration = &self.configuration;
659
660 let local_var_client = &local_var_configuration.client;
661
662 let local_var_uri_str = format!(
663 "{}/projects/{id}/access-policies/people",
664 local_var_configuration.base_path,
665 id = id
666 );
667 let mut local_var_req_builder =
668 local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
669
670 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
671 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
672 };
673 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
674 local_var_req_builder = local_var_req_builder.json(&people_access_policies_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_type = local_var_resp
681 .headers()
682 .get("content-type")
683 .and_then(|v| v.to_str().ok())
684 .unwrap_or("application/octet-stream");
685 let local_var_content_type = super::ContentType::from(local_var_content_type);
686 let local_var_content = local_var_resp.text().await?;
687
688 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
689 match local_var_content_type {
690 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
691 ContentType::Text => {
692 return Err(Error::from(serde_json::Error::custom(
693 "Received `text/plain` content type response that cannot be converted to `models::ProjectPeopleAccessPoliciesResponseModel`",
694 )));
695 }
696 ContentType::Unsupported(local_var_unknown_type) => {
697 return Err(Error::from(serde_json::Error::custom(format!(
698 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ProjectPeopleAccessPoliciesResponseModel`"
699 ))));
700 }
701 }
702 } else {
703 let local_var_entity: Option<PutProjectPeopleAccessPoliciesError> =
704 serde_json::from_str(&local_var_content).ok();
705 let local_var_error = ResponseContent {
706 status: local_var_status,
707 content: local_var_content,
708 entity: local_var_entity,
709 };
710 Err(Error::ResponseError(local_var_error))
711 }
712 }
713
714 async fn put_project_service_accounts_access_policies<'a>(
715 &self,
716 id: uuid::Uuid,
717 project_service_accounts_access_policies_request_model: Option<
718 models::ProjectServiceAccountsAccessPoliciesRequestModel,
719 >,
720 ) -> Result<
721 models::ProjectServiceAccountsAccessPoliciesResponseModel,
722 Error<PutProjectServiceAccountsAccessPoliciesError>,
723 > {
724 let local_var_configuration = &self.configuration;
725
726 let local_var_client = &local_var_configuration.client;
727
728 let local_var_uri_str = format!(
729 "{}/projects/{id}/access-policies/service-accounts",
730 local_var_configuration.base_path,
731 id = id
732 );
733 let mut local_var_req_builder =
734 local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
735
736 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
737 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
738 };
739 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
740 local_var_req_builder =
741 local_var_req_builder.json(&project_service_accounts_access_policies_request_model);
742
743 let local_var_req = local_var_req_builder.build()?;
744 let local_var_resp = local_var_client.execute(local_var_req).await?;
745
746 let local_var_status = local_var_resp.status();
747 let local_var_content_type = local_var_resp
748 .headers()
749 .get("content-type")
750 .and_then(|v| v.to_str().ok())
751 .unwrap_or("application/octet-stream");
752 let local_var_content_type = super::ContentType::from(local_var_content_type);
753 let local_var_content = local_var_resp.text().await?;
754
755 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
756 match local_var_content_type {
757 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
758 ContentType::Text => {
759 return Err(Error::from(serde_json::Error::custom(
760 "Received `text/plain` content type response that cannot be converted to `models::ProjectServiceAccountsAccessPoliciesResponseModel`",
761 )));
762 }
763 ContentType::Unsupported(local_var_unknown_type) => {
764 return Err(Error::from(serde_json::Error::custom(format!(
765 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ProjectServiceAccountsAccessPoliciesResponseModel`"
766 ))));
767 }
768 }
769 } else {
770 let local_var_entity: Option<PutProjectServiceAccountsAccessPoliciesError> =
771 serde_json::from_str(&local_var_content).ok();
772 let local_var_error = ResponseContent {
773 status: local_var_status,
774 content: local_var_content,
775 entity: local_var_entity,
776 };
777 Err(Error::ResponseError(local_var_error))
778 }
779 }
780
781 async fn put_service_account_granted_policies<'a>(
782 &self,
783 id: uuid::Uuid,
784 service_account_granted_policies_request_model: Option<
785 models::ServiceAccountGrantedPoliciesRequestModel,
786 >,
787 ) -> Result<
788 models::ServiceAccountGrantedPoliciesPermissionDetailsResponseModel,
789 Error<PutServiceAccountGrantedPoliciesError>,
790 > {
791 let local_var_configuration = &self.configuration;
792
793 let local_var_client = &local_var_configuration.client;
794
795 let local_var_uri_str = format!(
796 "{}/service-accounts/{id}/granted-policies",
797 local_var_configuration.base_path,
798 id = id
799 );
800 let mut local_var_req_builder =
801 local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
802
803 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
804 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
805 };
806 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
807 local_var_req_builder =
808 local_var_req_builder.json(&service_account_granted_policies_request_model);
809
810 let local_var_req = local_var_req_builder.build()?;
811 let local_var_resp = local_var_client.execute(local_var_req).await?;
812
813 let local_var_status = local_var_resp.status();
814 let local_var_content_type = local_var_resp
815 .headers()
816 .get("content-type")
817 .and_then(|v| v.to_str().ok())
818 .unwrap_or("application/octet-stream");
819 let local_var_content_type = super::ContentType::from(local_var_content_type);
820 let local_var_content = local_var_resp.text().await?;
821
822 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
823 match local_var_content_type {
824 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
825 ContentType::Text => {
826 return Err(Error::from(serde_json::Error::custom(
827 "Received `text/plain` content type response that cannot be converted to `models::ServiceAccountGrantedPoliciesPermissionDetailsResponseModel`",
828 )));
829 }
830 ContentType::Unsupported(local_var_unknown_type) => {
831 return Err(Error::from(serde_json::Error::custom(format!(
832 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ServiceAccountGrantedPoliciesPermissionDetailsResponseModel`"
833 ))));
834 }
835 }
836 } else {
837 let local_var_entity: Option<PutServiceAccountGrantedPoliciesError> =
838 serde_json::from_str(&local_var_content).ok();
839 let local_var_error = ResponseContent {
840 status: local_var_status,
841 content: local_var_content,
842 entity: local_var_entity,
843 };
844 Err(Error::ResponseError(local_var_error))
845 }
846 }
847
848 async fn put_service_account_people_access_policies<'a>(
849 &self,
850 id: uuid::Uuid,
851 people_access_policies_request_model: Option<models::PeopleAccessPoliciesRequestModel>,
852 ) -> Result<
853 models::ServiceAccountPeopleAccessPoliciesResponseModel,
854 Error<PutServiceAccountPeopleAccessPoliciesError>,
855 > {
856 let local_var_configuration = &self.configuration;
857
858 let local_var_client = &local_var_configuration.client;
859
860 let local_var_uri_str = format!(
861 "{}/service-accounts/{id}/access-policies/people",
862 local_var_configuration.base_path,
863 id = id
864 );
865 let mut local_var_req_builder =
866 local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
867
868 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
869 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
870 };
871 local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
872 local_var_req_builder = local_var_req_builder.json(&people_access_policies_request_model);
873
874 let local_var_req = local_var_req_builder.build()?;
875 let local_var_resp = local_var_client.execute(local_var_req).await?;
876
877 let local_var_status = local_var_resp.status();
878 let local_var_content_type = local_var_resp
879 .headers()
880 .get("content-type")
881 .and_then(|v| v.to_str().ok())
882 .unwrap_or("application/octet-stream");
883 let local_var_content_type = super::ContentType::from(local_var_content_type);
884 let local_var_content = local_var_resp.text().await?;
885
886 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
887 match local_var_content_type {
888 ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from),
889 ContentType::Text => {
890 return Err(Error::from(serde_json::Error::custom(
891 "Received `text/plain` content type response that cannot be converted to `models::ServiceAccountPeopleAccessPoliciesResponseModel`",
892 )));
893 }
894 ContentType::Unsupported(local_var_unknown_type) => {
895 return Err(Error::from(serde_json::Error::custom(format!(
896 "Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ServiceAccountPeopleAccessPoliciesResponseModel`"
897 ))));
898 }
899 }
900 } else {
901 let local_var_entity: Option<PutServiceAccountPeopleAccessPoliciesError> =
902 serde_json::from_str(&local_var_content).ok();
903 let local_var_error = ResponseContent {
904 status: local_var_status,
905 content: local_var_content,
906 entity: local_var_entity,
907 };
908 Err(Error::ResponseError(local_var_error))
909 }
910 }
911}
912
913#[derive(Debug, Clone, Serialize, Deserialize)]
915#[serde(untagged)]
916pub enum GetPeoplePotentialGranteesError {
917 UnknownValue(serde_json::Value),
918}
919#[derive(Debug, Clone, Serialize, Deserialize)]
921#[serde(untagged)]
922pub enum GetProjectPeopleAccessPoliciesError {
923 UnknownValue(serde_json::Value),
924}
925#[derive(Debug, Clone, Serialize, Deserialize)]
927#[serde(untagged)]
928pub enum GetProjectPotentialGranteesError {
929 UnknownValue(serde_json::Value),
930}
931#[derive(Debug, Clone, Serialize, Deserialize)]
934#[serde(untagged)]
935pub enum GetProjectServiceAccountsAccessPoliciesError {
936 UnknownValue(serde_json::Value),
937}
938#[derive(Debug, Clone, Serialize, Deserialize)]
940#[serde(untagged)]
941pub enum GetSecretAccessPoliciesError {
942 UnknownValue(serde_json::Value),
943}
944#[derive(Debug, Clone, Serialize, Deserialize)]
946#[serde(untagged)]
947pub enum GetServiceAccountGrantedPoliciesError {
948 UnknownValue(serde_json::Value),
949}
950#[derive(Debug, Clone, Serialize, Deserialize)]
953#[serde(untagged)]
954pub enum GetServiceAccountPeopleAccessPoliciesError {
955 UnknownValue(serde_json::Value),
956}
957#[derive(Debug, Clone, Serialize, Deserialize)]
959#[serde(untagged)]
960pub enum GetServiceAccountsPotentialGranteesError {
961 UnknownValue(serde_json::Value),
962}
963#[derive(Debug, Clone, Serialize, Deserialize)]
965#[serde(untagged)]
966pub enum PutProjectPeopleAccessPoliciesError {
967 UnknownValue(serde_json::Value),
968}
969#[derive(Debug, Clone, Serialize, Deserialize)]
972#[serde(untagged)]
973pub enum PutProjectServiceAccountsAccessPoliciesError {
974 UnknownValue(serde_json::Value),
975}
976#[derive(Debug, Clone, Serialize, Deserialize)]
978#[serde(untagged)]
979pub enum PutServiceAccountGrantedPoliciesError {
980 UnknownValue(serde_json::Value),
981}
982#[derive(Debug, Clone, Serialize, Deserialize)]
985#[serde(untagged)]
986pub enum PutServiceAccountPeopleAccessPoliciesError {
987 UnknownValue(serde_json::Value),
988}