bitwarden_api_api/apis/
access_policies_api.rs

1/*
2 * Bitwarden Internal API
3 *
4 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 *
6 * The version of the OpenAPI document: latest
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use reqwest;
12use serde::{de::Error as _, Deserialize, Serialize};
13
14use super::{configuration, ContentType, Error};
15use crate::{apis::ResponseContent, models};
16
17/// struct for typed errors of method
18/// [`organizations_id_access_policies_people_potential_grantees_get`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum OrganizationsIdAccessPoliciesPeoplePotentialGranteesGetError {
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method
26/// [`organizations_id_access_policies_projects_potential_grantees_get`]
27#[derive(Debug, Clone, Serialize, Deserialize)]
28#[serde(untagged)]
29pub enum OrganizationsIdAccessPoliciesProjectsPotentialGranteesGetError {
30    UnknownValue(serde_json::Value),
31}
32
33/// struct for typed errors of method
34/// [`organizations_id_access_policies_service_accounts_potential_grantees_get`]
35#[derive(Debug, Clone, Serialize, Deserialize)]
36#[serde(untagged)]
37pub enum OrganizationsIdAccessPoliciesServiceAccountsPotentialGranteesGetError {
38    UnknownValue(serde_json::Value),
39}
40
41/// struct for typed errors of method [`projects_id_access_policies_people_get`]
42#[derive(Debug, Clone, Serialize, Deserialize)]
43#[serde(untagged)]
44pub enum ProjectsIdAccessPoliciesPeopleGetError {
45    UnknownValue(serde_json::Value),
46}
47
48/// struct for typed errors of method [`projects_id_access_policies_people_put`]
49#[derive(Debug, Clone, Serialize, Deserialize)]
50#[serde(untagged)]
51pub enum ProjectsIdAccessPoliciesPeoplePutError {
52    UnknownValue(serde_json::Value),
53}
54
55/// struct for typed errors of method [`projects_id_access_policies_service_accounts_get`]
56#[derive(Debug, Clone, Serialize, Deserialize)]
57#[serde(untagged)]
58pub enum ProjectsIdAccessPoliciesServiceAccountsGetError {
59    UnknownValue(serde_json::Value),
60}
61
62/// struct for typed errors of method [`projects_id_access_policies_service_accounts_put`]
63#[derive(Debug, Clone, Serialize, Deserialize)]
64#[serde(untagged)]
65pub enum ProjectsIdAccessPoliciesServiceAccountsPutError {
66    UnknownValue(serde_json::Value),
67}
68
69/// struct for typed errors of method [`secrets_secret_id_access_policies_get`]
70#[derive(Debug, Clone, Serialize, Deserialize)]
71#[serde(untagged)]
72pub enum SecretsSecretIdAccessPoliciesGetError {
73    UnknownValue(serde_json::Value),
74}
75
76/// struct for typed errors of method [`service_accounts_id_access_policies_people_get`]
77#[derive(Debug, Clone, Serialize, Deserialize)]
78#[serde(untagged)]
79pub enum ServiceAccountsIdAccessPoliciesPeopleGetError {
80    UnknownValue(serde_json::Value),
81}
82
83/// struct for typed errors of method [`service_accounts_id_access_policies_people_put`]
84#[derive(Debug, Clone, Serialize, Deserialize)]
85#[serde(untagged)]
86pub enum ServiceAccountsIdAccessPoliciesPeoplePutError {
87    UnknownValue(serde_json::Value),
88}
89
90/// struct for typed errors of method [`service_accounts_id_granted_policies_get`]
91#[derive(Debug, Clone, Serialize, Deserialize)]
92#[serde(untagged)]
93pub enum ServiceAccountsIdGrantedPoliciesGetError {
94    UnknownValue(serde_json::Value),
95}
96
97/// struct for typed errors of method [`service_accounts_id_granted_policies_put`]
98#[derive(Debug, Clone, Serialize, Deserialize)]
99#[serde(untagged)]
100pub enum ServiceAccountsIdGrantedPoliciesPutError {
101    UnknownValue(serde_json::Value),
102}
103
104pub async fn organizations_id_access_policies_people_potential_grantees_get(
105    configuration: &configuration::Configuration,
106    id: uuid::Uuid,
107) -> Result<
108    models::PotentialGranteeResponseModelListResponseModel,
109    Error<OrganizationsIdAccessPoliciesPeoplePotentialGranteesGetError>,
110> {
111    // add a prefix to parameters to efficiently prevent name collisions
112    let p_id = id;
113
114    let uri_str = format!(
115        "{}/organizations/{id}/access-policies/people/potential-grantees",
116        configuration.base_path,
117        id = crate::apis::urlencode(p_id.to_string())
118    );
119    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
120
121    if let Some(ref user_agent) = configuration.user_agent {
122        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
123    }
124    if let Some(ref token) = configuration.oauth_access_token {
125        req_builder = req_builder.bearer_auth(token.to_owned());
126    };
127
128    let req = req_builder.build()?;
129    let resp = configuration.client.execute(req).await?;
130
131    let status = resp.status();
132    let content_type = resp
133        .headers()
134        .get("content-type")
135        .and_then(|v| v.to_str().ok())
136        .unwrap_or("application/octet-stream");
137    let content_type = super::ContentType::from(content_type);
138
139    if !status.is_client_error() && !status.is_server_error() {
140        let content = resp.text().await?;
141        match content_type {
142            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
143            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PotentialGranteeResponseModelListResponseModel`"))),
144            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PotentialGranteeResponseModelListResponseModel`")))),
145        }
146    } else {
147        let content = resp.text().await?;
148        let entity: Option<OrganizationsIdAccessPoliciesPeoplePotentialGranteesGetError> =
149            serde_json::from_str(&content).ok();
150        Err(Error::ResponseError(ResponseContent {
151            status,
152            content,
153            entity,
154        }))
155    }
156}
157
158pub async fn organizations_id_access_policies_projects_potential_grantees_get(
159    configuration: &configuration::Configuration,
160    id: uuid::Uuid,
161) -> Result<
162    models::PotentialGranteeResponseModelListResponseModel,
163    Error<OrganizationsIdAccessPoliciesProjectsPotentialGranteesGetError>,
164> {
165    // add a prefix to parameters to efficiently prevent name collisions
166    let p_id = id;
167
168    let uri_str = format!(
169        "{}/organizations/{id}/access-policies/projects/potential-grantees",
170        configuration.base_path,
171        id = crate::apis::urlencode(p_id.to_string())
172    );
173    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
174
175    if let Some(ref user_agent) = configuration.user_agent {
176        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
177    }
178    if let Some(ref token) = configuration.oauth_access_token {
179        req_builder = req_builder.bearer_auth(token.to_owned());
180    };
181
182    let req = req_builder.build()?;
183    let resp = configuration.client.execute(req).await?;
184
185    let status = resp.status();
186    let content_type = resp
187        .headers()
188        .get("content-type")
189        .and_then(|v| v.to_str().ok())
190        .unwrap_or("application/octet-stream");
191    let content_type = super::ContentType::from(content_type);
192
193    if !status.is_client_error() && !status.is_server_error() {
194        let content = resp.text().await?;
195        match content_type {
196            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
197            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PotentialGranteeResponseModelListResponseModel`"))),
198            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PotentialGranteeResponseModelListResponseModel`")))),
199        }
200    } else {
201        let content = resp.text().await?;
202        let entity: Option<OrganizationsIdAccessPoliciesProjectsPotentialGranteesGetError> =
203            serde_json::from_str(&content).ok();
204        Err(Error::ResponseError(ResponseContent {
205            status,
206            content,
207            entity,
208        }))
209    }
210}
211
212pub async fn organizations_id_access_policies_service_accounts_potential_grantees_get(
213    configuration: &configuration::Configuration,
214    id: uuid::Uuid,
215) -> Result<
216    models::PotentialGranteeResponseModelListResponseModel,
217    Error<OrganizationsIdAccessPoliciesServiceAccountsPotentialGranteesGetError>,
218> {
219    // add a prefix to parameters to efficiently prevent name collisions
220    let p_id = id;
221
222    let uri_str = format!(
223        "{}/organizations/{id}/access-policies/service-accounts/potential-grantees",
224        configuration.base_path,
225        id = crate::apis::urlencode(p_id.to_string())
226    );
227    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
228
229    if let Some(ref user_agent) = configuration.user_agent {
230        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
231    }
232    if let Some(ref token) = configuration.oauth_access_token {
233        req_builder = req_builder.bearer_auth(token.to_owned());
234    };
235
236    let req = req_builder.build()?;
237    let resp = configuration.client.execute(req).await?;
238
239    let status = resp.status();
240    let content_type = resp
241        .headers()
242        .get("content-type")
243        .and_then(|v| v.to_str().ok())
244        .unwrap_or("application/octet-stream");
245    let content_type = super::ContentType::from(content_type);
246
247    if !status.is_client_error() && !status.is_server_error() {
248        let content = resp.text().await?;
249        match content_type {
250            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
251            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PotentialGranteeResponseModelListResponseModel`"))),
252            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PotentialGranteeResponseModelListResponseModel`")))),
253        }
254    } else {
255        let content = resp.text().await?;
256        let entity: Option<OrganizationsIdAccessPoliciesServiceAccountsPotentialGranteesGetError> =
257            serde_json::from_str(&content).ok();
258        Err(Error::ResponseError(ResponseContent {
259            status,
260            content,
261            entity,
262        }))
263    }
264}
265
266pub async fn projects_id_access_policies_people_get(
267    configuration: &configuration::Configuration,
268    id: uuid::Uuid,
269) -> Result<
270    models::ProjectPeopleAccessPoliciesResponseModel,
271    Error<ProjectsIdAccessPoliciesPeopleGetError>,
272> {
273    // add a prefix to parameters to efficiently prevent name collisions
274    let p_id = id;
275
276    let uri_str = format!(
277        "{}/projects/{id}/access-policies/people",
278        configuration.base_path,
279        id = crate::apis::urlencode(p_id.to_string())
280    );
281    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
282
283    if let Some(ref user_agent) = configuration.user_agent {
284        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
285    }
286    if let Some(ref token) = configuration.oauth_access_token {
287        req_builder = req_builder.bearer_auth(token.to_owned());
288    };
289
290    let req = req_builder.build()?;
291    let resp = configuration.client.execute(req).await?;
292
293    let status = resp.status();
294    let content_type = resp
295        .headers()
296        .get("content-type")
297        .and_then(|v| v.to_str().ok())
298        .unwrap_or("application/octet-stream");
299    let content_type = super::ContentType::from(content_type);
300
301    if !status.is_client_error() && !status.is_server_error() {
302        let content = resp.text().await?;
303        match content_type {
304            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
305            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProjectPeopleAccessPoliciesResponseModel`"))),
306            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ProjectPeopleAccessPoliciesResponseModel`")))),
307        }
308    } else {
309        let content = resp.text().await?;
310        let entity: Option<ProjectsIdAccessPoliciesPeopleGetError> =
311            serde_json::from_str(&content).ok();
312        Err(Error::ResponseError(ResponseContent {
313            status,
314            content,
315            entity,
316        }))
317    }
318}
319
320pub async fn projects_id_access_policies_people_put(
321    configuration: &configuration::Configuration,
322    id: uuid::Uuid,
323    people_access_policies_request_model: Option<models::PeopleAccessPoliciesRequestModel>,
324) -> Result<
325    models::ProjectPeopleAccessPoliciesResponseModel,
326    Error<ProjectsIdAccessPoliciesPeoplePutError>,
327> {
328    // add a prefix to parameters to efficiently prevent name collisions
329    let p_id = id;
330    let p_people_access_policies_request_model = people_access_policies_request_model;
331
332    let uri_str = format!(
333        "{}/projects/{id}/access-policies/people",
334        configuration.base_path,
335        id = crate::apis::urlencode(p_id.to_string())
336    );
337    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
338
339    if let Some(ref user_agent) = configuration.user_agent {
340        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
341    }
342    if let Some(ref token) = configuration.oauth_access_token {
343        req_builder = req_builder.bearer_auth(token.to_owned());
344    };
345    req_builder = req_builder.json(&p_people_access_policies_request_model);
346
347    let req = req_builder.build()?;
348    let resp = configuration.client.execute(req).await?;
349
350    let status = resp.status();
351    let content_type = resp
352        .headers()
353        .get("content-type")
354        .and_then(|v| v.to_str().ok())
355        .unwrap_or("application/octet-stream");
356    let content_type = super::ContentType::from(content_type);
357
358    if !status.is_client_error() && !status.is_server_error() {
359        let content = resp.text().await?;
360        match content_type {
361            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
362            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProjectPeopleAccessPoliciesResponseModel`"))),
363            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ProjectPeopleAccessPoliciesResponseModel`")))),
364        }
365    } else {
366        let content = resp.text().await?;
367        let entity: Option<ProjectsIdAccessPoliciesPeoplePutError> =
368            serde_json::from_str(&content).ok();
369        Err(Error::ResponseError(ResponseContent {
370            status,
371            content,
372            entity,
373        }))
374    }
375}
376
377pub async fn projects_id_access_policies_service_accounts_get(
378    configuration: &configuration::Configuration,
379    id: uuid::Uuid,
380) -> Result<
381    models::ProjectServiceAccountsAccessPoliciesResponseModel,
382    Error<ProjectsIdAccessPoliciesServiceAccountsGetError>,
383> {
384    // add a prefix to parameters to efficiently prevent name collisions
385    let p_id = id;
386
387    let uri_str = format!(
388        "{}/projects/{id}/access-policies/service-accounts",
389        configuration.base_path,
390        id = crate::apis::urlencode(p_id.to_string())
391    );
392    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
393
394    if let Some(ref user_agent) = configuration.user_agent {
395        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
396    }
397    if let Some(ref token) = configuration.oauth_access_token {
398        req_builder = req_builder.bearer_auth(token.to_owned());
399    };
400
401    let req = req_builder.build()?;
402    let resp = configuration.client.execute(req).await?;
403
404    let status = resp.status();
405    let content_type = resp
406        .headers()
407        .get("content-type")
408        .and_then(|v| v.to_str().ok())
409        .unwrap_or("application/octet-stream");
410    let content_type = super::ContentType::from(content_type);
411
412    if !status.is_client_error() && !status.is_server_error() {
413        let content = resp.text().await?;
414        match content_type {
415            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
416            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProjectServiceAccountsAccessPoliciesResponseModel`"))),
417            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ProjectServiceAccountsAccessPoliciesResponseModel`")))),
418        }
419    } else {
420        let content = resp.text().await?;
421        let entity: Option<ProjectsIdAccessPoliciesServiceAccountsGetError> =
422            serde_json::from_str(&content).ok();
423        Err(Error::ResponseError(ResponseContent {
424            status,
425            content,
426            entity,
427        }))
428    }
429}
430
431pub async fn projects_id_access_policies_service_accounts_put(
432    configuration: &configuration::Configuration,
433    id: uuid::Uuid,
434    project_service_accounts_access_policies_request_model: Option<
435        models::ProjectServiceAccountsAccessPoliciesRequestModel,
436    >,
437) -> Result<
438    models::ProjectServiceAccountsAccessPoliciesResponseModel,
439    Error<ProjectsIdAccessPoliciesServiceAccountsPutError>,
440> {
441    // add a prefix to parameters to efficiently prevent name collisions
442    let p_id = id;
443    let p_project_service_accounts_access_policies_request_model =
444        project_service_accounts_access_policies_request_model;
445
446    let uri_str = format!(
447        "{}/projects/{id}/access-policies/service-accounts",
448        configuration.base_path,
449        id = crate::apis::urlencode(p_id.to_string())
450    );
451    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
452
453    if let Some(ref user_agent) = configuration.user_agent {
454        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
455    }
456    if let Some(ref token) = configuration.oauth_access_token {
457        req_builder = req_builder.bearer_auth(token.to_owned());
458    };
459    req_builder = req_builder.json(&p_project_service_accounts_access_policies_request_model);
460
461    let req = req_builder.build()?;
462    let resp = configuration.client.execute(req).await?;
463
464    let status = resp.status();
465    let content_type = resp
466        .headers()
467        .get("content-type")
468        .and_then(|v| v.to_str().ok())
469        .unwrap_or("application/octet-stream");
470    let content_type = super::ContentType::from(content_type);
471
472    if !status.is_client_error() && !status.is_server_error() {
473        let content = resp.text().await?;
474        match content_type {
475            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
476            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProjectServiceAccountsAccessPoliciesResponseModel`"))),
477            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ProjectServiceAccountsAccessPoliciesResponseModel`")))),
478        }
479    } else {
480        let content = resp.text().await?;
481        let entity: Option<ProjectsIdAccessPoliciesServiceAccountsPutError> =
482            serde_json::from_str(&content).ok();
483        Err(Error::ResponseError(ResponseContent {
484            status,
485            content,
486            entity,
487        }))
488    }
489}
490
491pub async fn secrets_secret_id_access_policies_get(
492    configuration: &configuration::Configuration,
493    secret_id: uuid::Uuid,
494) -> Result<models::SecretAccessPoliciesResponseModel, Error<SecretsSecretIdAccessPoliciesGetError>>
495{
496    // add a prefix to parameters to efficiently prevent name collisions
497    let p_secret_id = secret_id;
498
499    let uri_str = format!(
500        "{}/secrets/{secretId}/access-policies",
501        configuration.base_path,
502        secretId = crate::apis::urlencode(p_secret_id.to_string())
503    );
504    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
505
506    if let Some(ref user_agent) = configuration.user_agent {
507        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
508    }
509    if let Some(ref token) = configuration.oauth_access_token {
510        req_builder = req_builder.bearer_auth(token.to_owned());
511    };
512
513    let req = req_builder.build()?;
514    let resp = configuration.client.execute(req).await?;
515
516    let status = resp.status();
517    let content_type = resp
518        .headers()
519        .get("content-type")
520        .and_then(|v| v.to_str().ok())
521        .unwrap_or("application/octet-stream");
522    let content_type = super::ContentType::from(content_type);
523
524    if !status.is_client_error() && !status.is_server_error() {
525        let content = resp.text().await?;
526        match content_type {
527            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
528            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SecretAccessPoliciesResponseModel`"))),
529            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SecretAccessPoliciesResponseModel`")))),
530        }
531    } else {
532        let content = resp.text().await?;
533        let entity: Option<SecretsSecretIdAccessPoliciesGetError> =
534            serde_json::from_str(&content).ok();
535        Err(Error::ResponseError(ResponseContent {
536            status,
537            content,
538            entity,
539        }))
540    }
541}
542
543pub async fn service_accounts_id_access_policies_people_get(
544    configuration: &configuration::Configuration,
545    id: uuid::Uuid,
546) -> Result<
547    models::ServiceAccountPeopleAccessPoliciesResponseModel,
548    Error<ServiceAccountsIdAccessPoliciesPeopleGetError>,
549> {
550    // add a prefix to parameters to efficiently prevent name collisions
551    let p_id = id;
552
553    let uri_str = format!(
554        "{}/service-accounts/{id}/access-policies/people",
555        configuration.base_path,
556        id = crate::apis::urlencode(p_id.to_string())
557    );
558    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
559
560    if let Some(ref user_agent) = configuration.user_agent {
561        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
562    }
563    if let Some(ref token) = configuration.oauth_access_token {
564        req_builder = req_builder.bearer_auth(token.to_owned());
565    };
566
567    let req = req_builder.build()?;
568    let resp = configuration.client.execute(req).await?;
569
570    let status = resp.status();
571    let content_type = resp
572        .headers()
573        .get("content-type")
574        .and_then(|v| v.to_str().ok())
575        .unwrap_or("application/octet-stream");
576    let content_type = super::ContentType::from(content_type);
577
578    if !status.is_client_error() && !status.is_server_error() {
579        let content = resp.text().await?;
580        match content_type {
581            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
582            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ServiceAccountPeopleAccessPoliciesResponseModel`"))),
583            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ServiceAccountPeopleAccessPoliciesResponseModel`")))),
584        }
585    } else {
586        let content = resp.text().await?;
587        let entity: Option<ServiceAccountsIdAccessPoliciesPeopleGetError> =
588            serde_json::from_str(&content).ok();
589        Err(Error::ResponseError(ResponseContent {
590            status,
591            content,
592            entity,
593        }))
594    }
595}
596
597pub async fn service_accounts_id_access_policies_people_put(
598    configuration: &configuration::Configuration,
599    id: uuid::Uuid,
600    people_access_policies_request_model: Option<models::PeopleAccessPoliciesRequestModel>,
601) -> Result<
602    models::ServiceAccountPeopleAccessPoliciesResponseModel,
603    Error<ServiceAccountsIdAccessPoliciesPeoplePutError>,
604> {
605    // add a prefix to parameters to efficiently prevent name collisions
606    let p_id = id;
607    let p_people_access_policies_request_model = people_access_policies_request_model;
608
609    let uri_str = format!(
610        "{}/service-accounts/{id}/access-policies/people",
611        configuration.base_path,
612        id = crate::apis::urlencode(p_id.to_string())
613    );
614    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
615
616    if let Some(ref user_agent) = configuration.user_agent {
617        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
618    }
619    if let Some(ref token) = configuration.oauth_access_token {
620        req_builder = req_builder.bearer_auth(token.to_owned());
621    };
622    req_builder = req_builder.json(&p_people_access_policies_request_model);
623
624    let req = req_builder.build()?;
625    let resp = configuration.client.execute(req).await?;
626
627    let status = resp.status();
628    let content_type = resp
629        .headers()
630        .get("content-type")
631        .and_then(|v| v.to_str().ok())
632        .unwrap_or("application/octet-stream");
633    let content_type = super::ContentType::from(content_type);
634
635    if !status.is_client_error() && !status.is_server_error() {
636        let content = resp.text().await?;
637        match content_type {
638            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
639            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ServiceAccountPeopleAccessPoliciesResponseModel`"))),
640            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ServiceAccountPeopleAccessPoliciesResponseModel`")))),
641        }
642    } else {
643        let content = resp.text().await?;
644        let entity: Option<ServiceAccountsIdAccessPoliciesPeoplePutError> =
645            serde_json::from_str(&content).ok();
646        Err(Error::ResponseError(ResponseContent {
647            status,
648            content,
649            entity,
650        }))
651    }
652}
653
654pub async fn service_accounts_id_granted_policies_get(
655    configuration: &configuration::Configuration,
656    id: uuid::Uuid,
657) -> Result<
658    models::ServiceAccountGrantedPoliciesPermissionDetailsResponseModel,
659    Error<ServiceAccountsIdGrantedPoliciesGetError>,
660> {
661    // add a prefix to parameters to efficiently prevent name collisions
662    let p_id = id;
663
664    let uri_str = format!(
665        "{}/service-accounts/{id}/granted-policies",
666        configuration.base_path,
667        id = crate::apis::urlencode(p_id.to_string())
668    );
669    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
670
671    if let Some(ref user_agent) = configuration.user_agent {
672        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
673    }
674    if let Some(ref token) = configuration.oauth_access_token {
675        req_builder = req_builder.bearer_auth(token.to_owned());
676    };
677
678    let req = req_builder.build()?;
679    let resp = configuration.client.execute(req).await?;
680
681    let status = resp.status();
682    let content_type = resp
683        .headers()
684        .get("content-type")
685        .and_then(|v| v.to_str().ok())
686        .unwrap_or("application/octet-stream");
687    let content_type = super::ContentType::from(content_type);
688
689    if !status.is_client_error() && !status.is_server_error() {
690        let content = resp.text().await?;
691        match content_type {
692            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
693            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ServiceAccountGrantedPoliciesPermissionDetailsResponseModel`"))),
694            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ServiceAccountGrantedPoliciesPermissionDetailsResponseModel`")))),
695        }
696    } else {
697        let content = resp.text().await?;
698        let entity: Option<ServiceAccountsIdGrantedPoliciesGetError> =
699            serde_json::from_str(&content).ok();
700        Err(Error::ResponseError(ResponseContent {
701            status,
702            content,
703            entity,
704        }))
705    }
706}
707
708pub async fn service_accounts_id_granted_policies_put(
709    configuration: &configuration::Configuration,
710    id: uuid::Uuid,
711    service_account_granted_policies_request_model: Option<
712        models::ServiceAccountGrantedPoliciesRequestModel,
713    >,
714) -> Result<
715    models::ServiceAccountGrantedPoliciesPermissionDetailsResponseModel,
716    Error<ServiceAccountsIdGrantedPoliciesPutError>,
717> {
718    // add a prefix to parameters to efficiently prevent name collisions
719    let p_id = id;
720    let p_service_account_granted_policies_request_model =
721        service_account_granted_policies_request_model;
722
723    let uri_str = format!(
724        "{}/service-accounts/{id}/granted-policies",
725        configuration.base_path,
726        id = crate::apis::urlencode(p_id.to_string())
727    );
728    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
729
730    if let Some(ref user_agent) = configuration.user_agent {
731        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
732    }
733    if let Some(ref token) = configuration.oauth_access_token {
734        req_builder = req_builder.bearer_auth(token.to_owned());
735    };
736    req_builder = req_builder.json(&p_service_account_granted_policies_request_model);
737
738    let req = req_builder.build()?;
739    let resp = configuration.client.execute(req).await?;
740
741    let status = resp.status();
742    let content_type = resp
743        .headers()
744        .get("content-type")
745        .and_then(|v| v.to_str().ok())
746        .unwrap_or("application/octet-stream");
747    let content_type = super::ContentType::from(content_type);
748
749    if !status.is_client_error() && !status.is_server_error() {
750        let content = resp.text().await?;
751        match content_type {
752            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
753            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ServiceAccountGrantedPoliciesPermissionDetailsResponseModel`"))),
754            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ServiceAccountGrantedPoliciesPermissionDetailsResponseModel`")))),
755        }
756    } else {
757        let content = resp.text().await?;
758        let entity: Option<ServiceAccountsIdGrantedPoliciesPutError> =
759            serde_json::from_str(&content).ok();
760        Err(Error::ResponseError(ResponseContent {
761            status,
762            content,
763            entity,
764        }))
765    }
766}