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