authentik_client/apis/
rbac_api.rs

1/*
2 * authentik
3 *
4 * Making authentication simple.
5 *
6 * The version of the OpenAPI document: 2025.10.2
7 * Contact: hello@goauthentik.io
8 * Generated by: https://openapi-generator.tech
9 */
10
11use super::{configuration, ContentType, Error};
12use crate::{apis::ResponseContent, models};
13use reqwest;
14use serde::{de::Error as _, Deserialize, Serialize};
15
16/// struct for typed errors of method [`rbac_initial_permissions_create`]
17#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum RbacInitialPermissionsCreateError {
20    Status400(models::ValidationError),
21    Status403(models::GenericError),
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`rbac_initial_permissions_destroy`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum RbacInitialPermissionsDestroyError {
29    Status400(models::ValidationError),
30    Status403(models::GenericError),
31    UnknownValue(serde_json::Value),
32}
33
34/// struct for typed errors of method [`rbac_initial_permissions_list`]
35#[derive(Debug, Clone, Serialize, Deserialize)]
36#[serde(untagged)]
37pub enum RbacInitialPermissionsListError {
38    Status400(models::ValidationError),
39    Status403(models::GenericError),
40    UnknownValue(serde_json::Value),
41}
42
43/// struct for typed errors of method [`rbac_initial_permissions_partial_update`]
44#[derive(Debug, Clone, Serialize, Deserialize)]
45#[serde(untagged)]
46pub enum RbacInitialPermissionsPartialUpdateError {
47    Status400(models::ValidationError),
48    Status403(models::GenericError),
49    UnknownValue(serde_json::Value),
50}
51
52/// struct for typed errors of method [`rbac_initial_permissions_retrieve`]
53#[derive(Debug, Clone, Serialize, Deserialize)]
54#[serde(untagged)]
55pub enum RbacInitialPermissionsRetrieveError {
56    Status400(models::ValidationError),
57    Status403(models::GenericError),
58    UnknownValue(serde_json::Value),
59}
60
61/// struct for typed errors of method [`rbac_initial_permissions_update`]
62#[derive(Debug, Clone, Serialize, Deserialize)]
63#[serde(untagged)]
64pub enum RbacInitialPermissionsUpdateError {
65    Status400(models::ValidationError),
66    Status403(models::GenericError),
67    UnknownValue(serde_json::Value),
68}
69
70/// struct for typed errors of method [`rbac_initial_permissions_used_by_list`]
71#[derive(Debug, Clone, Serialize, Deserialize)]
72#[serde(untagged)]
73pub enum RbacInitialPermissionsUsedByListError {
74    Status400(models::ValidationError),
75    Status403(models::GenericError),
76    UnknownValue(serde_json::Value),
77}
78
79/// struct for typed errors of method [`rbac_permissions_assigned_by_roles_assign`]
80#[derive(Debug, Clone, Serialize, Deserialize)]
81#[serde(untagged)]
82pub enum RbacPermissionsAssignedByRolesAssignError {
83    Status400(models::ValidationError),
84    Status403(models::GenericError),
85    UnknownValue(serde_json::Value),
86}
87
88/// struct for typed errors of method [`rbac_permissions_assigned_by_roles_list`]
89#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum RbacPermissionsAssignedByRolesListError {
92    Status400(models::ValidationError),
93    Status403(models::GenericError),
94    UnknownValue(serde_json::Value),
95}
96
97/// struct for typed errors of method [`rbac_permissions_assigned_by_roles_unassign_partial_update`]
98#[derive(Debug, Clone, Serialize, Deserialize)]
99#[serde(untagged)]
100pub enum RbacPermissionsAssignedByRolesUnassignPartialUpdateError {
101    Status400(models::ValidationError),
102    Status403(models::GenericError),
103    UnknownValue(serde_json::Value),
104}
105
106/// struct for typed errors of method [`rbac_permissions_assigned_by_users_assign`]
107#[derive(Debug, Clone, Serialize, Deserialize)]
108#[serde(untagged)]
109pub enum RbacPermissionsAssignedByUsersAssignError {
110    Status400(models::ValidationError),
111    Status403(models::GenericError),
112    UnknownValue(serde_json::Value),
113}
114
115/// struct for typed errors of method [`rbac_permissions_assigned_by_users_list`]
116#[derive(Debug, Clone, Serialize, Deserialize)]
117#[serde(untagged)]
118pub enum RbacPermissionsAssignedByUsersListError {
119    Status400(models::ValidationError),
120    Status403(models::GenericError),
121    UnknownValue(serde_json::Value),
122}
123
124/// struct for typed errors of method [`rbac_permissions_assigned_by_users_unassign_partial_update`]
125#[derive(Debug, Clone, Serialize, Deserialize)]
126#[serde(untagged)]
127pub enum RbacPermissionsAssignedByUsersUnassignPartialUpdateError {
128    Status400(models::ValidationError),
129    Status403(models::GenericError),
130    UnknownValue(serde_json::Value),
131}
132
133/// struct for typed errors of method [`rbac_permissions_list`]
134#[derive(Debug, Clone, Serialize, Deserialize)]
135#[serde(untagged)]
136pub enum RbacPermissionsListError {
137    Status400(models::ValidationError),
138    Status403(models::GenericError),
139    UnknownValue(serde_json::Value),
140}
141
142/// struct for typed errors of method [`rbac_permissions_retrieve`]
143#[derive(Debug, Clone, Serialize, Deserialize)]
144#[serde(untagged)]
145pub enum RbacPermissionsRetrieveError {
146    Status400(models::ValidationError),
147    Status403(models::GenericError),
148    UnknownValue(serde_json::Value),
149}
150
151/// struct for typed errors of method [`rbac_permissions_roles_destroy`]
152#[derive(Debug, Clone, Serialize, Deserialize)]
153#[serde(untagged)]
154pub enum RbacPermissionsRolesDestroyError {
155    Status400(models::ValidationError),
156    Status403(models::GenericError),
157    UnknownValue(serde_json::Value),
158}
159
160/// struct for typed errors of method [`rbac_permissions_roles_list`]
161#[derive(Debug, Clone, Serialize, Deserialize)]
162#[serde(untagged)]
163pub enum RbacPermissionsRolesListError {
164    Status400(models::ValidationError),
165    Status403(models::GenericError),
166    UnknownValue(serde_json::Value),
167}
168
169/// struct for typed errors of method [`rbac_permissions_roles_partial_update`]
170#[derive(Debug, Clone, Serialize, Deserialize)]
171#[serde(untagged)]
172pub enum RbacPermissionsRolesPartialUpdateError {
173    Status400(models::ValidationError),
174    Status403(models::GenericError),
175    UnknownValue(serde_json::Value),
176}
177
178/// struct for typed errors of method [`rbac_permissions_roles_retrieve`]
179#[derive(Debug, Clone, Serialize, Deserialize)]
180#[serde(untagged)]
181pub enum RbacPermissionsRolesRetrieveError {
182    Status400(models::ValidationError),
183    Status403(models::GenericError),
184    UnknownValue(serde_json::Value),
185}
186
187/// struct for typed errors of method [`rbac_permissions_roles_update`]
188#[derive(Debug, Clone, Serialize, Deserialize)]
189#[serde(untagged)]
190pub enum RbacPermissionsRolesUpdateError {
191    Status400(models::ValidationError),
192    Status403(models::GenericError),
193    UnknownValue(serde_json::Value),
194}
195
196/// struct for typed errors of method [`rbac_permissions_users_destroy`]
197#[derive(Debug, Clone, Serialize, Deserialize)]
198#[serde(untagged)]
199pub enum RbacPermissionsUsersDestroyError {
200    Status400(models::ValidationError),
201    Status403(models::GenericError),
202    UnknownValue(serde_json::Value),
203}
204
205/// struct for typed errors of method [`rbac_permissions_users_list`]
206#[derive(Debug, Clone, Serialize, Deserialize)]
207#[serde(untagged)]
208pub enum RbacPermissionsUsersListError {
209    Status400(models::ValidationError),
210    Status403(models::GenericError),
211    UnknownValue(serde_json::Value),
212}
213
214/// struct for typed errors of method [`rbac_permissions_users_partial_update`]
215#[derive(Debug, Clone, Serialize, Deserialize)]
216#[serde(untagged)]
217pub enum RbacPermissionsUsersPartialUpdateError {
218    Status400(models::ValidationError),
219    Status403(models::GenericError),
220    UnknownValue(serde_json::Value),
221}
222
223/// struct for typed errors of method [`rbac_permissions_users_retrieve`]
224#[derive(Debug, Clone, Serialize, Deserialize)]
225#[serde(untagged)]
226pub enum RbacPermissionsUsersRetrieveError {
227    Status400(models::ValidationError),
228    Status403(models::GenericError),
229    UnknownValue(serde_json::Value),
230}
231
232/// struct for typed errors of method [`rbac_permissions_users_update`]
233#[derive(Debug, Clone, Serialize, Deserialize)]
234#[serde(untagged)]
235pub enum RbacPermissionsUsersUpdateError {
236    Status400(models::ValidationError),
237    Status403(models::GenericError),
238    UnknownValue(serde_json::Value),
239}
240
241/// struct for typed errors of method [`rbac_roles_create`]
242#[derive(Debug, Clone, Serialize, Deserialize)]
243#[serde(untagged)]
244pub enum RbacRolesCreateError {
245    Status400(models::ValidationError),
246    Status403(models::GenericError),
247    UnknownValue(serde_json::Value),
248}
249
250/// struct for typed errors of method [`rbac_roles_destroy`]
251#[derive(Debug, Clone, Serialize, Deserialize)]
252#[serde(untagged)]
253pub enum RbacRolesDestroyError {
254    Status400(models::ValidationError),
255    Status403(models::GenericError),
256    UnknownValue(serde_json::Value),
257}
258
259/// struct for typed errors of method [`rbac_roles_list`]
260#[derive(Debug, Clone, Serialize, Deserialize)]
261#[serde(untagged)]
262pub enum RbacRolesListError {
263    Status400(models::ValidationError),
264    Status403(models::GenericError),
265    UnknownValue(serde_json::Value),
266}
267
268/// struct for typed errors of method [`rbac_roles_partial_update`]
269#[derive(Debug, Clone, Serialize, Deserialize)]
270#[serde(untagged)]
271pub enum RbacRolesPartialUpdateError {
272    Status400(models::ValidationError),
273    Status403(models::GenericError),
274    UnknownValue(serde_json::Value),
275}
276
277/// struct for typed errors of method [`rbac_roles_retrieve`]
278#[derive(Debug, Clone, Serialize, Deserialize)]
279#[serde(untagged)]
280pub enum RbacRolesRetrieveError {
281    Status400(models::ValidationError),
282    Status403(models::GenericError),
283    UnknownValue(serde_json::Value),
284}
285
286/// struct for typed errors of method [`rbac_roles_update`]
287#[derive(Debug, Clone, Serialize, Deserialize)]
288#[serde(untagged)]
289pub enum RbacRolesUpdateError {
290    Status400(models::ValidationError),
291    Status403(models::GenericError),
292    UnknownValue(serde_json::Value),
293}
294
295/// struct for typed errors of method [`rbac_roles_used_by_list`]
296#[derive(Debug, Clone, Serialize, Deserialize)]
297#[serde(untagged)]
298pub enum RbacRolesUsedByListError {
299    Status400(models::ValidationError),
300    Status403(models::GenericError),
301    UnknownValue(serde_json::Value),
302}
303
304/// InitialPermissions viewset
305pub async fn rbac_initial_permissions_create(
306    configuration: &configuration::Configuration,
307    initial_permissions_request: models::InitialPermissionsRequest,
308) -> Result<models::InitialPermissions, Error<RbacInitialPermissionsCreateError>> {
309    // add a prefix to parameters to efficiently prevent name collisions
310    let p_body_initial_permissions_request = initial_permissions_request;
311
312    let uri_str = format!("{}/rbac/initial_permissions/", configuration.base_path);
313    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
314
315    if let Some(ref user_agent) = configuration.user_agent {
316        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
317    }
318    if let Some(ref token) = configuration.bearer_access_token {
319        req_builder = req_builder.bearer_auth(token.to_owned());
320    };
321    req_builder = req_builder.json(&p_body_initial_permissions_request);
322
323    let req = req_builder.build()?;
324    let resp = configuration.client.execute(req).await?;
325
326    let status = resp.status();
327    let content_type = resp
328        .headers()
329        .get("content-type")
330        .and_then(|v| v.to_str().ok())
331        .unwrap_or("application/octet-stream");
332    let content_type = super::ContentType::from(content_type);
333
334    if !status.is_client_error() && !status.is_server_error() {
335        let content = resp.text().await?;
336        match content_type {
337            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
338            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::InitialPermissions`"))),
339            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::InitialPermissions`")))),
340        }
341    } else {
342        let content = resp.text().await?;
343        let entity: Option<RbacInitialPermissionsCreateError> = serde_json::from_str(&content).ok();
344        Err(Error::ResponseError(ResponseContent {
345            status,
346            content,
347            entity,
348        }))
349    }
350}
351
352/// InitialPermissions viewset
353pub async fn rbac_initial_permissions_destroy(
354    configuration: &configuration::Configuration,
355    id: i32,
356) -> Result<(), Error<RbacInitialPermissionsDestroyError>> {
357    // add a prefix to parameters to efficiently prevent name collisions
358    let p_path_id = id;
359
360    let uri_str = format!(
361        "{}/rbac/initial_permissions/{id}/",
362        configuration.base_path,
363        id = p_path_id
364    );
365    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
366
367    if let Some(ref user_agent) = configuration.user_agent {
368        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
369    }
370    if let Some(ref token) = configuration.bearer_access_token {
371        req_builder = req_builder.bearer_auth(token.to_owned());
372    };
373
374    let req = req_builder.build()?;
375    let resp = configuration.client.execute(req).await?;
376
377    let status = resp.status();
378
379    if !status.is_client_error() && !status.is_server_error() {
380        Ok(())
381    } else {
382        let content = resp.text().await?;
383        let entity: Option<RbacInitialPermissionsDestroyError> = serde_json::from_str(&content).ok();
384        Err(Error::ResponseError(ResponseContent {
385            status,
386            content,
387            entity,
388        }))
389    }
390}
391
392/// InitialPermissions viewset
393pub async fn rbac_initial_permissions_list(
394    configuration: &configuration::Configuration,
395    name: Option<&str>,
396    ordering: Option<&str>,
397    page: Option<i32>,
398    page_size: Option<i32>,
399    search: Option<&str>,
400) -> Result<models::PaginatedInitialPermissionsList, Error<RbacInitialPermissionsListError>> {
401    // add a prefix to parameters to efficiently prevent name collisions
402    let p_query_name = name;
403    let p_query_ordering = ordering;
404    let p_query_page = page;
405    let p_query_page_size = page_size;
406    let p_query_search = search;
407
408    let uri_str = format!("{}/rbac/initial_permissions/", configuration.base_path);
409    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
410
411    if let Some(ref param_value) = p_query_name {
412        req_builder = req_builder.query(&[("name", &param_value.to_string())]);
413    }
414    if let Some(ref param_value) = p_query_ordering {
415        req_builder = req_builder.query(&[("ordering", &param_value.to_string())]);
416    }
417    if let Some(ref param_value) = p_query_page {
418        req_builder = req_builder.query(&[("page", &param_value.to_string())]);
419    }
420    if let Some(ref param_value) = p_query_page_size {
421        req_builder = req_builder.query(&[("page_size", &param_value.to_string())]);
422    }
423    if let Some(ref param_value) = p_query_search {
424        req_builder = req_builder.query(&[("search", &param_value.to_string())]);
425    }
426    if let Some(ref user_agent) = configuration.user_agent {
427        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
428    }
429    if let Some(ref token) = configuration.bearer_access_token {
430        req_builder = req_builder.bearer_auth(token.to_owned());
431    };
432
433    let req = req_builder.build()?;
434    let resp = configuration.client.execute(req).await?;
435
436    let status = resp.status();
437    let content_type = resp
438        .headers()
439        .get("content-type")
440        .and_then(|v| v.to_str().ok())
441        .unwrap_or("application/octet-stream");
442    let content_type = super::ContentType::from(content_type);
443
444    if !status.is_client_error() && !status.is_server_error() {
445        let content = resp.text().await?;
446        match content_type {
447            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
448            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaginatedInitialPermissionsList`"))),
449            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::PaginatedInitialPermissionsList`")))),
450        }
451    } else {
452        let content = resp.text().await?;
453        let entity: Option<RbacInitialPermissionsListError> = serde_json::from_str(&content).ok();
454        Err(Error::ResponseError(ResponseContent {
455            status,
456            content,
457            entity,
458        }))
459    }
460}
461
462/// InitialPermissions viewset
463pub async fn rbac_initial_permissions_partial_update(
464    configuration: &configuration::Configuration,
465    id: i32,
466    patched_initial_permissions_request: Option<models::PatchedInitialPermissionsRequest>,
467) -> Result<models::InitialPermissions, Error<RbacInitialPermissionsPartialUpdateError>> {
468    // add a prefix to parameters to efficiently prevent name collisions
469    let p_path_id = id;
470    let p_body_patched_initial_permissions_request = patched_initial_permissions_request;
471
472    let uri_str = format!(
473        "{}/rbac/initial_permissions/{id}/",
474        configuration.base_path,
475        id = p_path_id
476    );
477    let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
478
479    if let Some(ref user_agent) = configuration.user_agent {
480        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
481    }
482    if let Some(ref token) = configuration.bearer_access_token {
483        req_builder = req_builder.bearer_auth(token.to_owned());
484    };
485    req_builder = req_builder.json(&p_body_patched_initial_permissions_request);
486
487    let req = req_builder.build()?;
488    let resp = configuration.client.execute(req).await?;
489
490    let status = resp.status();
491    let content_type = resp
492        .headers()
493        .get("content-type")
494        .and_then(|v| v.to_str().ok())
495        .unwrap_or("application/octet-stream");
496    let content_type = super::ContentType::from(content_type);
497
498    if !status.is_client_error() && !status.is_server_error() {
499        let content = resp.text().await?;
500        match content_type {
501            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
502            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::InitialPermissions`"))),
503            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::InitialPermissions`")))),
504        }
505    } else {
506        let content = resp.text().await?;
507        let entity: Option<RbacInitialPermissionsPartialUpdateError> = serde_json::from_str(&content).ok();
508        Err(Error::ResponseError(ResponseContent {
509            status,
510            content,
511            entity,
512        }))
513    }
514}
515
516/// InitialPermissions viewset
517pub async fn rbac_initial_permissions_retrieve(
518    configuration: &configuration::Configuration,
519    id: i32,
520) -> Result<models::InitialPermissions, Error<RbacInitialPermissionsRetrieveError>> {
521    // add a prefix to parameters to efficiently prevent name collisions
522    let p_path_id = id;
523
524    let uri_str = format!(
525        "{}/rbac/initial_permissions/{id}/",
526        configuration.base_path,
527        id = p_path_id
528    );
529    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
530
531    if let Some(ref user_agent) = configuration.user_agent {
532        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
533    }
534    if let Some(ref token) = configuration.bearer_access_token {
535        req_builder = req_builder.bearer_auth(token.to_owned());
536    };
537
538    let req = req_builder.build()?;
539    let resp = configuration.client.execute(req).await?;
540
541    let status = resp.status();
542    let content_type = resp
543        .headers()
544        .get("content-type")
545        .and_then(|v| v.to_str().ok())
546        .unwrap_or("application/octet-stream");
547    let content_type = super::ContentType::from(content_type);
548
549    if !status.is_client_error() && !status.is_server_error() {
550        let content = resp.text().await?;
551        match content_type {
552            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
553            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::InitialPermissions`"))),
554            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::InitialPermissions`")))),
555        }
556    } else {
557        let content = resp.text().await?;
558        let entity: Option<RbacInitialPermissionsRetrieveError> = serde_json::from_str(&content).ok();
559        Err(Error::ResponseError(ResponseContent {
560            status,
561            content,
562            entity,
563        }))
564    }
565}
566
567/// InitialPermissions viewset
568pub async fn rbac_initial_permissions_update(
569    configuration: &configuration::Configuration,
570    id: i32,
571    initial_permissions_request: models::InitialPermissionsRequest,
572) -> Result<models::InitialPermissions, Error<RbacInitialPermissionsUpdateError>> {
573    // add a prefix to parameters to efficiently prevent name collisions
574    let p_path_id = id;
575    let p_body_initial_permissions_request = initial_permissions_request;
576
577    let uri_str = format!(
578        "{}/rbac/initial_permissions/{id}/",
579        configuration.base_path,
580        id = p_path_id
581    );
582    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
583
584    if let Some(ref user_agent) = configuration.user_agent {
585        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
586    }
587    if let Some(ref token) = configuration.bearer_access_token {
588        req_builder = req_builder.bearer_auth(token.to_owned());
589    };
590    req_builder = req_builder.json(&p_body_initial_permissions_request);
591
592    let req = req_builder.build()?;
593    let resp = configuration.client.execute(req).await?;
594
595    let status = resp.status();
596    let content_type = resp
597        .headers()
598        .get("content-type")
599        .and_then(|v| v.to_str().ok())
600        .unwrap_or("application/octet-stream");
601    let content_type = super::ContentType::from(content_type);
602
603    if !status.is_client_error() && !status.is_server_error() {
604        let content = resp.text().await?;
605        match content_type {
606            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
607            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::InitialPermissions`"))),
608            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::InitialPermissions`")))),
609        }
610    } else {
611        let content = resp.text().await?;
612        let entity: Option<RbacInitialPermissionsUpdateError> = serde_json::from_str(&content).ok();
613        Err(Error::ResponseError(ResponseContent {
614            status,
615            content,
616            entity,
617        }))
618    }
619}
620
621/// Get a list of all objects that use this object
622pub async fn rbac_initial_permissions_used_by_list(
623    configuration: &configuration::Configuration,
624    id: i32,
625) -> Result<Vec<models::UsedBy>, Error<RbacInitialPermissionsUsedByListError>> {
626    // add a prefix to parameters to efficiently prevent name collisions
627    let p_path_id = id;
628
629    let uri_str = format!(
630        "{}/rbac/initial_permissions/{id}/used_by/",
631        configuration.base_path,
632        id = p_path_id
633    );
634    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
635
636    if let Some(ref user_agent) = configuration.user_agent {
637        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
638    }
639    if let Some(ref token) = configuration.bearer_access_token {
640        req_builder = req_builder.bearer_auth(token.to_owned());
641    };
642
643    let req = req_builder.build()?;
644    let resp = configuration.client.execute(req).await?;
645
646    let status = resp.status();
647    let content_type = resp
648        .headers()
649        .get("content-type")
650        .and_then(|v| v.to_str().ok())
651        .unwrap_or("application/octet-stream");
652    let content_type = super::ContentType::from(content_type);
653
654    if !status.is_client_error() && !status.is_server_error() {
655        let content = resp.text().await?;
656        match content_type {
657            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
658            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::UsedBy&gt;`"))),
659            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::UsedBy&gt;`")))),
660        }
661    } else {
662        let content = resp.text().await?;
663        let entity: Option<RbacInitialPermissionsUsedByListError> = serde_json::from_str(&content).ok();
664        Err(Error::ResponseError(ResponseContent {
665            status,
666            content,
667            entity,
668        }))
669    }
670}
671
672/// Assign permission(s) to role. When `object_pk` is set, the permissions are only assigned to the specific object, otherwise they are assigned globally.
673pub async fn rbac_permissions_assigned_by_roles_assign(
674    configuration: &configuration::Configuration,
675    uuid: &str,
676    permission_assign_request: models::PermissionAssignRequest,
677) -> Result<Vec<models::PermissionAssignResult>, Error<RbacPermissionsAssignedByRolesAssignError>> {
678    // add a prefix to parameters to efficiently prevent name collisions
679    let p_path_uuid = uuid;
680    let p_body_permission_assign_request = permission_assign_request;
681
682    let uri_str = format!(
683        "{}/rbac/permissions/assigned_by_roles/{uuid}/assign/",
684        configuration.base_path,
685        uuid = crate::apis::urlencode(p_path_uuid)
686    );
687    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
688
689    if let Some(ref user_agent) = configuration.user_agent {
690        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
691    }
692    if let Some(ref token) = configuration.bearer_access_token {
693        req_builder = req_builder.bearer_auth(token.to_owned());
694    };
695    req_builder = req_builder.json(&p_body_permission_assign_request);
696
697    let req = req_builder.build()?;
698    let resp = configuration.client.execute(req).await?;
699
700    let status = resp.status();
701    let content_type = resp
702        .headers()
703        .get("content-type")
704        .and_then(|v| v.to_str().ok())
705        .unwrap_or("application/octet-stream");
706    let content_type = super::ContentType::from(content_type);
707
708    if !status.is_client_error() && !status.is_server_error() {
709        let content = resp.text().await?;
710        match content_type {
711            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
712            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::PermissionAssignResult&gt;`"))),
713            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::PermissionAssignResult&gt;`")))),
714        }
715    } else {
716        let content = resp.text().await?;
717        let entity: Option<RbacPermissionsAssignedByRolesAssignError> = serde_json::from_str(&content).ok();
718        Err(Error::ResponseError(ResponseContent {
719            status,
720            content,
721            entity,
722        }))
723    }
724}
725
726/// Get assigned object permissions for a single object
727pub async fn rbac_permissions_assigned_by_roles_list(
728    configuration: &configuration::Configuration,
729    model: &str,
730    object_pk: Option<&str>,
731    ordering: Option<&str>,
732    page: Option<i32>,
733    page_size: Option<i32>,
734    search: Option<&str>,
735) -> Result<models::PaginatedRoleAssignedObjectPermissionList, Error<RbacPermissionsAssignedByRolesListError>> {
736    // add a prefix to parameters to efficiently prevent name collisions
737    let p_query_model = model;
738    let p_query_object_pk = object_pk;
739    let p_query_ordering = ordering;
740    let p_query_page = page;
741    let p_query_page_size = page_size;
742    let p_query_search = search;
743
744    let uri_str = format!("{}/rbac/permissions/assigned_by_roles/", configuration.base_path);
745    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
746
747    req_builder = req_builder.query(&[("model", &p_query_model.to_string())]);
748    if let Some(ref param_value) = p_query_object_pk {
749        req_builder = req_builder.query(&[("object_pk", &param_value.to_string())]);
750    }
751    if let Some(ref param_value) = p_query_ordering {
752        req_builder = req_builder.query(&[("ordering", &param_value.to_string())]);
753    }
754    if let Some(ref param_value) = p_query_page {
755        req_builder = req_builder.query(&[("page", &param_value.to_string())]);
756    }
757    if let Some(ref param_value) = p_query_page_size {
758        req_builder = req_builder.query(&[("page_size", &param_value.to_string())]);
759    }
760    if let Some(ref param_value) = p_query_search {
761        req_builder = req_builder.query(&[("search", &param_value.to_string())]);
762    }
763    if let Some(ref user_agent) = configuration.user_agent {
764        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
765    }
766    if let Some(ref token) = configuration.bearer_access_token {
767        req_builder = req_builder.bearer_auth(token.to_owned());
768    };
769
770    let req = req_builder.build()?;
771    let resp = configuration.client.execute(req).await?;
772
773    let status = resp.status();
774    let content_type = resp
775        .headers()
776        .get("content-type")
777        .and_then(|v| v.to_str().ok())
778        .unwrap_or("application/octet-stream");
779    let content_type = super::ContentType::from(content_type);
780
781    if !status.is_client_error() && !status.is_server_error() {
782        let content = resp.text().await?;
783        match content_type {
784            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
785            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaginatedRoleAssignedObjectPermissionList`"))),
786            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::PaginatedRoleAssignedObjectPermissionList`")))),
787        }
788    } else {
789        let content = resp.text().await?;
790        let entity: Option<RbacPermissionsAssignedByRolesListError> = serde_json::from_str(&content).ok();
791        Err(Error::ResponseError(ResponseContent {
792            status,
793            content,
794            entity,
795        }))
796    }
797}
798
799/// Unassign permission(s) to role. When `object_pk` is set, the permissions are only assigned to the specific object, otherwise they are assigned globally.
800pub async fn rbac_permissions_assigned_by_roles_unassign_partial_update(
801    configuration: &configuration::Configuration,
802    uuid: &str,
803    patched_permission_assign_request: Option<models::PatchedPermissionAssignRequest>,
804) -> Result<(), Error<RbacPermissionsAssignedByRolesUnassignPartialUpdateError>> {
805    // add a prefix to parameters to efficiently prevent name collisions
806    let p_path_uuid = uuid;
807    let p_body_patched_permission_assign_request = patched_permission_assign_request;
808
809    let uri_str = format!(
810        "{}/rbac/permissions/assigned_by_roles/{uuid}/unassign/",
811        configuration.base_path,
812        uuid = crate::apis::urlencode(p_path_uuid)
813    );
814    let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
815
816    if let Some(ref user_agent) = configuration.user_agent {
817        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
818    }
819    if let Some(ref token) = configuration.bearer_access_token {
820        req_builder = req_builder.bearer_auth(token.to_owned());
821    };
822    req_builder = req_builder.json(&p_body_patched_permission_assign_request);
823
824    let req = req_builder.build()?;
825    let resp = configuration.client.execute(req).await?;
826
827    let status = resp.status();
828
829    if !status.is_client_error() && !status.is_server_error() {
830        Ok(())
831    } else {
832        let content = resp.text().await?;
833        let entity: Option<RbacPermissionsAssignedByRolesUnassignPartialUpdateError> =
834            serde_json::from_str(&content).ok();
835        Err(Error::ResponseError(ResponseContent {
836            status,
837            content,
838            entity,
839        }))
840    }
841}
842
843/// Assign permission(s) to user
844pub async fn rbac_permissions_assigned_by_users_assign(
845    configuration: &configuration::Configuration,
846    id: i32,
847    permission_assign_request: models::PermissionAssignRequest,
848) -> Result<Vec<models::PermissionAssignResult>, Error<RbacPermissionsAssignedByUsersAssignError>> {
849    // add a prefix to parameters to efficiently prevent name collisions
850    let p_path_id = id;
851    let p_body_permission_assign_request = permission_assign_request;
852
853    let uri_str = format!(
854        "{}/rbac/permissions/assigned_by_users/{id}/assign/",
855        configuration.base_path,
856        id = p_path_id
857    );
858    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
859
860    if let Some(ref user_agent) = configuration.user_agent {
861        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
862    }
863    if let Some(ref token) = configuration.bearer_access_token {
864        req_builder = req_builder.bearer_auth(token.to_owned());
865    };
866    req_builder = req_builder.json(&p_body_permission_assign_request);
867
868    let req = req_builder.build()?;
869    let resp = configuration.client.execute(req).await?;
870
871    let status = resp.status();
872    let content_type = resp
873        .headers()
874        .get("content-type")
875        .and_then(|v| v.to_str().ok())
876        .unwrap_or("application/octet-stream");
877    let content_type = super::ContentType::from(content_type);
878
879    if !status.is_client_error() && !status.is_server_error() {
880        let content = resp.text().await?;
881        match content_type {
882            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
883            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::PermissionAssignResult&gt;`"))),
884            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::PermissionAssignResult&gt;`")))),
885        }
886    } else {
887        let content = resp.text().await?;
888        let entity: Option<RbacPermissionsAssignedByUsersAssignError> = serde_json::from_str(&content).ok();
889        Err(Error::ResponseError(ResponseContent {
890            status,
891            content,
892            entity,
893        }))
894    }
895}
896
897/// Get assigned object permissions for a single object
898pub async fn rbac_permissions_assigned_by_users_list(
899    configuration: &configuration::Configuration,
900    model: &str,
901    object_pk: Option<&str>,
902    ordering: Option<&str>,
903    page: Option<i32>,
904    page_size: Option<i32>,
905    search: Option<&str>,
906) -> Result<models::PaginatedUserAssignedObjectPermissionList, Error<RbacPermissionsAssignedByUsersListError>> {
907    // add a prefix to parameters to efficiently prevent name collisions
908    let p_query_model = model;
909    let p_query_object_pk = object_pk;
910    let p_query_ordering = ordering;
911    let p_query_page = page;
912    let p_query_page_size = page_size;
913    let p_query_search = search;
914
915    let uri_str = format!("{}/rbac/permissions/assigned_by_users/", configuration.base_path);
916    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
917
918    req_builder = req_builder.query(&[("model", &p_query_model.to_string())]);
919    if let Some(ref param_value) = p_query_object_pk {
920        req_builder = req_builder.query(&[("object_pk", &param_value.to_string())]);
921    }
922    if let Some(ref param_value) = p_query_ordering {
923        req_builder = req_builder.query(&[("ordering", &param_value.to_string())]);
924    }
925    if let Some(ref param_value) = p_query_page {
926        req_builder = req_builder.query(&[("page", &param_value.to_string())]);
927    }
928    if let Some(ref param_value) = p_query_page_size {
929        req_builder = req_builder.query(&[("page_size", &param_value.to_string())]);
930    }
931    if let Some(ref param_value) = p_query_search {
932        req_builder = req_builder.query(&[("search", &param_value.to_string())]);
933    }
934    if let Some(ref user_agent) = configuration.user_agent {
935        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
936    }
937    if let Some(ref token) = configuration.bearer_access_token {
938        req_builder = req_builder.bearer_auth(token.to_owned());
939    };
940
941    let req = req_builder.build()?;
942    let resp = configuration.client.execute(req).await?;
943
944    let status = resp.status();
945    let content_type = resp
946        .headers()
947        .get("content-type")
948        .and_then(|v| v.to_str().ok())
949        .unwrap_or("application/octet-stream");
950    let content_type = super::ContentType::from(content_type);
951
952    if !status.is_client_error() && !status.is_server_error() {
953        let content = resp.text().await?;
954        match content_type {
955            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
956            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaginatedUserAssignedObjectPermissionList`"))),
957            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::PaginatedUserAssignedObjectPermissionList`")))),
958        }
959    } else {
960        let content = resp.text().await?;
961        let entity: Option<RbacPermissionsAssignedByUsersListError> = serde_json::from_str(&content).ok();
962        Err(Error::ResponseError(ResponseContent {
963            status,
964            content,
965            entity,
966        }))
967    }
968}
969
970/// Unassign permission(s) to user. When `object_pk` is set, the permissions are only assigned to the specific object, otherwise they are assigned globally.
971pub async fn rbac_permissions_assigned_by_users_unassign_partial_update(
972    configuration: &configuration::Configuration,
973    id: i32,
974    patched_permission_assign_request: Option<models::PatchedPermissionAssignRequest>,
975) -> Result<(), Error<RbacPermissionsAssignedByUsersUnassignPartialUpdateError>> {
976    // add a prefix to parameters to efficiently prevent name collisions
977    let p_path_id = id;
978    let p_body_patched_permission_assign_request = patched_permission_assign_request;
979
980    let uri_str = format!(
981        "{}/rbac/permissions/assigned_by_users/{id}/unassign/",
982        configuration.base_path,
983        id = p_path_id
984    );
985    let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
986
987    if let Some(ref user_agent) = configuration.user_agent {
988        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
989    }
990    if let Some(ref token) = configuration.bearer_access_token {
991        req_builder = req_builder.bearer_auth(token.to_owned());
992    };
993    req_builder = req_builder.json(&p_body_patched_permission_assign_request);
994
995    let req = req_builder.build()?;
996    let resp = configuration.client.execute(req).await?;
997
998    let status = resp.status();
999
1000    if !status.is_client_error() && !status.is_server_error() {
1001        Ok(())
1002    } else {
1003        let content = resp.text().await?;
1004        let entity: Option<RbacPermissionsAssignedByUsersUnassignPartialUpdateError> =
1005            serde_json::from_str(&content).ok();
1006        Err(Error::ResponseError(ResponseContent {
1007            status,
1008            content,
1009            entity,
1010        }))
1011    }
1012}
1013
1014/// Read-only list of all permissions, filterable by model and app
1015pub async fn rbac_permissions_list(
1016    configuration: &configuration::Configuration,
1017    codename: Option<&str>,
1018    content_type__app_label: Option<&str>,
1019    content_type__model: Option<&str>,
1020    ordering: Option<&str>,
1021    page: Option<i32>,
1022    page_size: Option<i32>,
1023    role: Option<&str>,
1024    search: Option<&str>,
1025    user: Option<i32>,
1026) -> Result<models::PaginatedPermissionList, Error<RbacPermissionsListError>> {
1027    // add a prefix to parameters to efficiently prevent name collisions
1028    let p_query_codename = codename;
1029    let p_query_content_type__app_label = content_type__app_label;
1030    let p_query_content_type__model = content_type__model;
1031    let p_query_ordering = ordering;
1032    let p_query_page = page;
1033    let p_query_page_size = page_size;
1034    let p_query_role = role;
1035    let p_query_search = search;
1036    let p_query_user = user;
1037
1038    let uri_str = format!("{}/rbac/permissions/", configuration.base_path);
1039    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1040
1041    if let Some(ref param_value) = p_query_codename {
1042        req_builder = req_builder.query(&[("codename", &param_value.to_string())]);
1043    }
1044    if let Some(ref param_value) = p_query_content_type__app_label {
1045        req_builder = req_builder.query(&[("content_type__app_label", &param_value.to_string())]);
1046    }
1047    if let Some(ref param_value) = p_query_content_type__model {
1048        req_builder = req_builder.query(&[("content_type__model", &param_value.to_string())]);
1049    }
1050    if let Some(ref param_value) = p_query_ordering {
1051        req_builder = req_builder.query(&[("ordering", &param_value.to_string())]);
1052    }
1053    if let Some(ref param_value) = p_query_page {
1054        req_builder = req_builder.query(&[("page", &param_value.to_string())]);
1055    }
1056    if let Some(ref param_value) = p_query_page_size {
1057        req_builder = req_builder.query(&[("page_size", &param_value.to_string())]);
1058    }
1059    if let Some(ref param_value) = p_query_role {
1060        req_builder = req_builder.query(&[("role", &param_value.to_string())]);
1061    }
1062    if let Some(ref param_value) = p_query_search {
1063        req_builder = req_builder.query(&[("search", &param_value.to_string())]);
1064    }
1065    if let Some(ref param_value) = p_query_user {
1066        req_builder = req_builder.query(&[("user", &param_value.to_string())]);
1067    }
1068    if let Some(ref user_agent) = configuration.user_agent {
1069        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1070    }
1071    if let Some(ref token) = configuration.bearer_access_token {
1072        req_builder = req_builder.bearer_auth(token.to_owned());
1073    };
1074
1075    let req = req_builder.build()?;
1076    let resp = configuration.client.execute(req).await?;
1077
1078    let status = resp.status();
1079    let content_type = resp
1080        .headers()
1081        .get("content-type")
1082        .and_then(|v| v.to_str().ok())
1083        .unwrap_or("application/octet-stream");
1084    let content_type = super::ContentType::from(content_type);
1085
1086    if !status.is_client_error() && !status.is_server_error() {
1087        let content = resp.text().await?;
1088        match content_type {
1089            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1090            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaginatedPermissionList`"))),
1091            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::PaginatedPermissionList`")))),
1092        }
1093    } else {
1094        let content = resp.text().await?;
1095        let entity: Option<RbacPermissionsListError> = serde_json::from_str(&content).ok();
1096        Err(Error::ResponseError(ResponseContent {
1097            status,
1098            content,
1099            entity,
1100        }))
1101    }
1102}
1103
1104/// Read-only list of all permissions, filterable by model and app
1105pub async fn rbac_permissions_retrieve(
1106    configuration: &configuration::Configuration,
1107    id: i32,
1108) -> Result<models::Permission, Error<RbacPermissionsRetrieveError>> {
1109    // add a prefix to parameters to efficiently prevent name collisions
1110    let p_path_id = id;
1111
1112    let uri_str = format!("{}/rbac/permissions/{id}/", configuration.base_path, id = p_path_id);
1113    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1114
1115    if let Some(ref user_agent) = configuration.user_agent {
1116        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1117    }
1118    if let Some(ref token) = configuration.bearer_access_token {
1119        req_builder = req_builder.bearer_auth(token.to_owned());
1120    };
1121
1122    let req = req_builder.build()?;
1123    let resp = configuration.client.execute(req).await?;
1124
1125    let status = resp.status();
1126    let content_type = resp
1127        .headers()
1128        .get("content-type")
1129        .and_then(|v| v.to_str().ok())
1130        .unwrap_or("application/octet-stream");
1131    let content_type = super::ContentType::from(content_type);
1132
1133    if !status.is_client_error() && !status.is_server_error() {
1134        let content = resp.text().await?;
1135        match content_type {
1136            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1137            ContentType::Text => {
1138                return Err(Error::from(serde_json::Error::custom(
1139                    "Received `text/plain` content type response that cannot be converted to `models::Permission`",
1140                )))
1141            }
1142            ContentType::Unsupported(unknown_type) => {
1143                return Err(Error::from(serde_json::Error::custom(format!(
1144                    "Received `{unknown_type}` content type response that cannot be converted to `models::Permission`"
1145                ))))
1146            }
1147        }
1148    } else {
1149        let content = resp.text().await?;
1150        let entity: Option<RbacPermissionsRetrieveError> = serde_json::from_str(&content).ok();
1151        Err(Error::ResponseError(ResponseContent {
1152            status,
1153            content,
1154            entity,
1155        }))
1156    }
1157}
1158
1159/// Get a role's assigned object permissions
1160pub async fn rbac_permissions_roles_destroy(
1161    configuration: &configuration::Configuration,
1162    id: i32,
1163) -> Result<(), Error<RbacPermissionsRolesDestroyError>> {
1164    // add a prefix to parameters to efficiently prevent name collisions
1165    let p_path_id = id;
1166
1167    let uri_str = format!(
1168        "{}/rbac/permissions/roles/{id}/",
1169        configuration.base_path,
1170        id = p_path_id
1171    );
1172    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
1173
1174    if let Some(ref user_agent) = configuration.user_agent {
1175        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1176    }
1177    if let Some(ref token) = configuration.bearer_access_token {
1178        req_builder = req_builder.bearer_auth(token.to_owned());
1179    };
1180
1181    let req = req_builder.build()?;
1182    let resp = configuration.client.execute(req).await?;
1183
1184    let status = resp.status();
1185
1186    if !status.is_client_error() && !status.is_server_error() {
1187        Ok(())
1188    } else {
1189        let content = resp.text().await?;
1190        let entity: Option<RbacPermissionsRolesDestroyError> = serde_json::from_str(&content).ok();
1191        Err(Error::ResponseError(ResponseContent {
1192            status,
1193            content,
1194            entity,
1195        }))
1196    }
1197}
1198
1199/// Get a role's assigned object permissions
1200pub async fn rbac_permissions_roles_list(
1201    configuration: &configuration::Configuration,
1202    ordering: Option<&str>,
1203    page: Option<i32>,
1204    page_size: Option<i32>,
1205    search: Option<&str>,
1206    uuid: Option<&str>,
1207) -> Result<models::PaginatedExtraRoleObjectPermissionList, Error<RbacPermissionsRolesListError>> {
1208    // add a prefix to parameters to efficiently prevent name collisions
1209    let p_query_ordering = ordering;
1210    let p_query_page = page;
1211    let p_query_page_size = page_size;
1212    let p_query_search = search;
1213    let p_query_uuid = uuid;
1214
1215    let uri_str = format!("{}/rbac/permissions/roles/", configuration.base_path);
1216    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1217
1218    if let Some(ref param_value) = p_query_ordering {
1219        req_builder = req_builder.query(&[("ordering", &param_value.to_string())]);
1220    }
1221    if let Some(ref param_value) = p_query_page {
1222        req_builder = req_builder.query(&[("page", &param_value.to_string())]);
1223    }
1224    if let Some(ref param_value) = p_query_page_size {
1225        req_builder = req_builder.query(&[("page_size", &param_value.to_string())]);
1226    }
1227    if let Some(ref param_value) = p_query_search {
1228        req_builder = req_builder.query(&[("search", &param_value.to_string())]);
1229    }
1230    if let Some(ref param_value) = p_query_uuid {
1231        req_builder = req_builder.query(&[("uuid", &param_value.to_string())]);
1232    }
1233    if let Some(ref user_agent) = configuration.user_agent {
1234        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1235    }
1236    if let Some(ref token) = configuration.bearer_access_token {
1237        req_builder = req_builder.bearer_auth(token.to_owned());
1238    };
1239
1240    let req = req_builder.build()?;
1241    let resp = configuration.client.execute(req).await?;
1242
1243    let status = resp.status();
1244    let content_type = resp
1245        .headers()
1246        .get("content-type")
1247        .and_then(|v| v.to_str().ok())
1248        .unwrap_or("application/octet-stream");
1249    let content_type = super::ContentType::from(content_type);
1250
1251    if !status.is_client_error() && !status.is_server_error() {
1252        let content = resp.text().await?;
1253        match content_type {
1254            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1255            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaginatedExtraRoleObjectPermissionList`"))),
1256            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::PaginatedExtraRoleObjectPermissionList`")))),
1257        }
1258    } else {
1259        let content = resp.text().await?;
1260        let entity: Option<RbacPermissionsRolesListError> = serde_json::from_str(&content).ok();
1261        Err(Error::ResponseError(ResponseContent {
1262            status,
1263            content,
1264            entity,
1265        }))
1266    }
1267}
1268
1269/// Get a role's assigned object permissions
1270pub async fn rbac_permissions_roles_partial_update(
1271    configuration: &configuration::Configuration,
1272    id: i32,
1273    patched_extra_role_object_permission_request: Option<models::PatchedExtraRoleObjectPermissionRequest>,
1274) -> Result<models::ExtraRoleObjectPermission, Error<RbacPermissionsRolesPartialUpdateError>> {
1275    // add a prefix to parameters to efficiently prevent name collisions
1276    let p_path_id = id;
1277    let p_body_patched_extra_role_object_permission_request = patched_extra_role_object_permission_request;
1278
1279    let uri_str = format!(
1280        "{}/rbac/permissions/roles/{id}/",
1281        configuration.base_path,
1282        id = p_path_id
1283    );
1284    let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
1285
1286    if let Some(ref user_agent) = configuration.user_agent {
1287        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1288    }
1289    if let Some(ref token) = configuration.bearer_access_token {
1290        req_builder = req_builder.bearer_auth(token.to_owned());
1291    };
1292    req_builder = req_builder.json(&p_body_patched_extra_role_object_permission_request);
1293
1294    let req = req_builder.build()?;
1295    let resp = configuration.client.execute(req).await?;
1296
1297    let status = resp.status();
1298    let content_type = resp
1299        .headers()
1300        .get("content-type")
1301        .and_then(|v| v.to_str().ok())
1302        .unwrap_or("application/octet-stream");
1303    let content_type = super::ContentType::from(content_type);
1304
1305    if !status.is_client_error() && !status.is_server_error() {
1306        let content = resp.text().await?;
1307        match content_type {
1308            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1309            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ExtraRoleObjectPermission`"))),
1310            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::ExtraRoleObjectPermission`")))),
1311        }
1312    } else {
1313        let content = resp.text().await?;
1314        let entity: Option<RbacPermissionsRolesPartialUpdateError> = serde_json::from_str(&content).ok();
1315        Err(Error::ResponseError(ResponseContent {
1316            status,
1317            content,
1318            entity,
1319        }))
1320    }
1321}
1322
1323/// Get a role's assigned object permissions
1324pub async fn rbac_permissions_roles_retrieve(
1325    configuration: &configuration::Configuration,
1326    id: i32,
1327) -> Result<models::ExtraRoleObjectPermission, Error<RbacPermissionsRolesRetrieveError>> {
1328    // add a prefix to parameters to efficiently prevent name collisions
1329    let p_path_id = id;
1330
1331    let uri_str = format!(
1332        "{}/rbac/permissions/roles/{id}/",
1333        configuration.base_path,
1334        id = p_path_id
1335    );
1336    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1337
1338    if let Some(ref user_agent) = configuration.user_agent {
1339        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1340    }
1341    if let Some(ref token) = configuration.bearer_access_token {
1342        req_builder = req_builder.bearer_auth(token.to_owned());
1343    };
1344
1345    let req = req_builder.build()?;
1346    let resp = configuration.client.execute(req).await?;
1347
1348    let status = resp.status();
1349    let content_type = resp
1350        .headers()
1351        .get("content-type")
1352        .and_then(|v| v.to_str().ok())
1353        .unwrap_or("application/octet-stream");
1354    let content_type = super::ContentType::from(content_type);
1355
1356    if !status.is_client_error() && !status.is_server_error() {
1357        let content = resp.text().await?;
1358        match content_type {
1359            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1360            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ExtraRoleObjectPermission`"))),
1361            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::ExtraRoleObjectPermission`")))),
1362        }
1363    } else {
1364        let content = resp.text().await?;
1365        let entity: Option<RbacPermissionsRolesRetrieveError> = serde_json::from_str(&content).ok();
1366        Err(Error::ResponseError(ResponseContent {
1367            status,
1368            content,
1369            entity,
1370        }))
1371    }
1372}
1373
1374/// Get a role's assigned object permissions
1375pub async fn rbac_permissions_roles_update(
1376    configuration: &configuration::Configuration,
1377    id: i32,
1378    extra_role_object_permission_request: models::ExtraRoleObjectPermissionRequest,
1379) -> Result<models::ExtraRoleObjectPermission, Error<RbacPermissionsRolesUpdateError>> {
1380    // add a prefix to parameters to efficiently prevent name collisions
1381    let p_path_id = id;
1382    let p_body_extra_role_object_permission_request = extra_role_object_permission_request;
1383
1384    let uri_str = format!(
1385        "{}/rbac/permissions/roles/{id}/",
1386        configuration.base_path,
1387        id = p_path_id
1388    );
1389    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
1390
1391    if let Some(ref user_agent) = configuration.user_agent {
1392        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1393    }
1394    if let Some(ref token) = configuration.bearer_access_token {
1395        req_builder = req_builder.bearer_auth(token.to_owned());
1396    };
1397    req_builder = req_builder.json(&p_body_extra_role_object_permission_request);
1398
1399    let req = req_builder.build()?;
1400    let resp = configuration.client.execute(req).await?;
1401
1402    let status = resp.status();
1403    let content_type = resp
1404        .headers()
1405        .get("content-type")
1406        .and_then(|v| v.to_str().ok())
1407        .unwrap_or("application/octet-stream");
1408    let content_type = super::ContentType::from(content_type);
1409
1410    if !status.is_client_error() && !status.is_server_error() {
1411        let content = resp.text().await?;
1412        match content_type {
1413            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1414            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ExtraRoleObjectPermission`"))),
1415            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::ExtraRoleObjectPermission`")))),
1416        }
1417    } else {
1418        let content = resp.text().await?;
1419        let entity: Option<RbacPermissionsRolesUpdateError> = serde_json::from_str(&content).ok();
1420        Err(Error::ResponseError(ResponseContent {
1421            status,
1422            content,
1423            entity,
1424        }))
1425    }
1426}
1427
1428/// Get a users's assigned object permissions
1429pub async fn rbac_permissions_users_destroy(
1430    configuration: &configuration::Configuration,
1431    id: i32,
1432) -> Result<(), Error<RbacPermissionsUsersDestroyError>> {
1433    // add a prefix to parameters to efficiently prevent name collisions
1434    let p_path_id = id;
1435
1436    let uri_str = format!(
1437        "{}/rbac/permissions/users/{id}/",
1438        configuration.base_path,
1439        id = p_path_id
1440    );
1441    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
1442
1443    if let Some(ref user_agent) = configuration.user_agent {
1444        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1445    }
1446    if let Some(ref token) = configuration.bearer_access_token {
1447        req_builder = req_builder.bearer_auth(token.to_owned());
1448    };
1449
1450    let req = req_builder.build()?;
1451    let resp = configuration.client.execute(req).await?;
1452
1453    let status = resp.status();
1454
1455    if !status.is_client_error() && !status.is_server_error() {
1456        Ok(())
1457    } else {
1458        let content = resp.text().await?;
1459        let entity: Option<RbacPermissionsUsersDestroyError> = serde_json::from_str(&content).ok();
1460        Err(Error::ResponseError(ResponseContent {
1461            status,
1462            content,
1463            entity,
1464        }))
1465    }
1466}
1467
1468/// Get a users's assigned object permissions
1469pub async fn rbac_permissions_users_list(
1470    configuration: &configuration::Configuration,
1471    ordering: Option<&str>,
1472    page: Option<i32>,
1473    page_size: Option<i32>,
1474    search: Option<&str>,
1475    user_id: Option<i32>,
1476) -> Result<models::PaginatedExtraUserObjectPermissionList, Error<RbacPermissionsUsersListError>> {
1477    // add a prefix to parameters to efficiently prevent name collisions
1478    let p_query_ordering = ordering;
1479    let p_query_page = page;
1480    let p_query_page_size = page_size;
1481    let p_query_search = search;
1482    let p_query_user_id = user_id;
1483
1484    let uri_str = format!("{}/rbac/permissions/users/", configuration.base_path);
1485    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1486
1487    if let Some(ref param_value) = p_query_ordering {
1488        req_builder = req_builder.query(&[("ordering", &param_value.to_string())]);
1489    }
1490    if let Some(ref param_value) = p_query_page {
1491        req_builder = req_builder.query(&[("page", &param_value.to_string())]);
1492    }
1493    if let Some(ref param_value) = p_query_page_size {
1494        req_builder = req_builder.query(&[("page_size", &param_value.to_string())]);
1495    }
1496    if let Some(ref param_value) = p_query_search {
1497        req_builder = req_builder.query(&[("search", &param_value.to_string())]);
1498    }
1499    if let Some(ref param_value) = p_query_user_id {
1500        req_builder = req_builder.query(&[("user_id", &param_value.to_string())]);
1501    }
1502    if let Some(ref user_agent) = configuration.user_agent {
1503        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1504    }
1505    if let Some(ref token) = configuration.bearer_access_token {
1506        req_builder = req_builder.bearer_auth(token.to_owned());
1507    };
1508
1509    let req = req_builder.build()?;
1510    let resp = configuration.client.execute(req).await?;
1511
1512    let status = resp.status();
1513    let content_type = resp
1514        .headers()
1515        .get("content-type")
1516        .and_then(|v| v.to_str().ok())
1517        .unwrap_or("application/octet-stream");
1518    let content_type = super::ContentType::from(content_type);
1519
1520    if !status.is_client_error() && !status.is_server_error() {
1521        let content = resp.text().await?;
1522        match content_type {
1523            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1524            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaginatedExtraUserObjectPermissionList`"))),
1525            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::PaginatedExtraUserObjectPermissionList`")))),
1526        }
1527    } else {
1528        let content = resp.text().await?;
1529        let entity: Option<RbacPermissionsUsersListError> = serde_json::from_str(&content).ok();
1530        Err(Error::ResponseError(ResponseContent {
1531            status,
1532            content,
1533            entity,
1534        }))
1535    }
1536}
1537
1538/// Get a users's assigned object permissions
1539pub async fn rbac_permissions_users_partial_update(
1540    configuration: &configuration::Configuration,
1541    id: i32,
1542    patched_extra_user_object_permission_request: Option<models::PatchedExtraUserObjectPermissionRequest>,
1543) -> Result<models::ExtraUserObjectPermission, Error<RbacPermissionsUsersPartialUpdateError>> {
1544    // add a prefix to parameters to efficiently prevent name collisions
1545    let p_path_id = id;
1546    let p_body_patched_extra_user_object_permission_request = patched_extra_user_object_permission_request;
1547
1548    let uri_str = format!(
1549        "{}/rbac/permissions/users/{id}/",
1550        configuration.base_path,
1551        id = p_path_id
1552    );
1553    let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
1554
1555    if let Some(ref user_agent) = configuration.user_agent {
1556        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1557    }
1558    if let Some(ref token) = configuration.bearer_access_token {
1559        req_builder = req_builder.bearer_auth(token.to_owned());
1560    };
1561    req_builder = req_builder.json(&p_body_patched_extra_user_object_permission_request);
1562
1563    let req = req_builder.build()?;
1564    let resp = configuration.client.execute(req).await?;
1565
1566    let status = resp.status();
1567    let content_type = resp
1568        .headers()
1569        .get("content-type")
1570        .and_then(|v| v.to_str().ok())
1571        .unwrap_or("application/octet-stream");
1572    let content_type = super::ContentType::from(content_type);
1573
1574    if !status.is_client_error() && !status.is_server_error() {
1575        let content = resp.text().await?;
1576        match content_type {
1577            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1578            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ExtraUserObjectPermission`"))),
1579            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::ExtraUserObjectPermission`")))),
1580        }
1581    } else {
1582        let content = resp.text().await?;
1583        let entity: Option<RbacPermissionsUsersPartialUpdateError> = serde_json::from_str(&content).ok();
1584        Err(Error::ResponseError(ResponseContent {
1585            status,
1586            content,
1587            entity,
1588        }))
1589    }
1590}
1591
1592/// Get a users's assigned object permissions
1593pub async fn rbac_permissions_users_retrieve(
1594    configuration: &configuration::Configuration,
1595    id: i32,
1596) -> Result<models::ExtraUserObjectPermission, Error<RbacPermissionsUsersRetrieveError>> {
1597    // add a prefix to parameters to efficiently prevent name collisions
1598    let p_path_id = id;
1599
1600    let uri_str = format!(
1601        "{}/rbac/permissions/users/{id}/",
1602        configuration.base_path,
1603        id = p_path_id
1604    );
1605    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1606
1607    if let Some(ref user_agent) = configuration.user_agent {
1608        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1609    }
1610    if let Some(ref token) = configuration.bearer_access_token {
1611        req_builder = req_builder.bearer_auth(token.to_owned());
1612    };
1613
1614    let req = req_builder.build()?;
1615    let resp = configuration.client.execute(req).await?;
1616
1617    let status = resp.status();
1618    let content_type = resp
1619        .headers()
1620        .get("content-type")
1621        .and_then(|v| v.to_str().ok())
1622        .unwrap_or("application/octet-stream");
1623    let content_type = super::ContentType::from(content_type);
1624
1625    if !status.is_client_error() && !status.is_server_error() {
1626        let content = resp.text().await?;
1627        match content_type {
1628            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1629            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ExtraUserObjectPermission`"))),
1630            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::ExtraUserObjectPermission`")))),
1631        }
1632    } else {
1633        let content = resp.text().await?;
1634        let entity: Option<RbacPermissionsUsersRetrieveError> = serde_json::from_str(&content).ok();
1635        Err(Error::ResponseError(ResponseContent {
1636            status,
1637            content,
1638            entity,
1639        }))
1640    }
1641}
1642
1643/// Get a users's assigned object permissions
1644pub async fn rbac_permissions_users_update(
1645    configuration: &configuration::Configuration,
1646    id: i32,
1647    extra_user_object_permission_request: models::ExtraUserObjectPermissionRequest,
1648) -> Result<models::ExtraUserObjectPermission, Error<RbacPermissionsUsersUpdateError>> {
1649    // add a prefix to parameters to efficiently prevent name collisions
1650    let p_path_id = id;
1651    let p_body_extra_user_object_permission_request = extra_user_object_permission_request;
1652
1653    let uri_str = format!(
1654        "{}/rbac/permissions/users/{id}/",
1655        configuration.base_path,
1656        id = p_path_id
1657    );
1658    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
1659
1660    if let Some(ref user_agent) = configuration.user_agent {
1661        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1662    }
1663    if let Some(ref token) = configuration.bearer_access_token {
1664        req_builder = req_builder.bearer_auth(token.to_owned());
1665    };
1666    req_builder = req_builder.json(&p_body_extra_user_object_permission_request);
1667
1668    let req = req_builder.build()?;
1669    let resp = configuration.client.execute(req).await?;
1670
1671    let status = resp.status();
1672    let content_type = resp
1673        .headers()
1674        .get("content-type")
1675        .and_then(|v| v.to_str().ok())
1676        .unwrap_or("application/octet-stream");
1677    let content_type = super::ContentType::from(content_type);
1678
1679    if !status.is_client_error() && !status.is_server_error() {
1680        let content = resp.text().await?;
1681        match content_type {
1682            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1683            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ExtraUserObjectPermission`"))),
1684            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::ExtraUserObjectPermission`")))),
1685        }
1686    } else {
1687        let content = resp.text().await?;
1688        let entity: Option<RbacPermissionsUsersUpdateError> = serde_json::from_str(&content).ok();
1689        Err(Error::ResponseError(ResponseContent {
1690            status,
1691            content,
1692            entity,
1693        }))
1694    }
1695}
1696
1697/// Role viewset
1698pub async fn rbac_roles_create(
1699    configuration: &configuration::Configuration,
1700    role_request: models::RoleRequest,
1701) -> Result<models::Role, Error<RbacRolesCreateError>> {
1702    // add a prefix to parameters to efficiently prevent name collisions
1703    let p_body_role_request = role_request;
1704
1705    let uri_str = format!("{}/rbac/roles/", configuration.base_path);
1706    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1707
1708    if let Some(ref user_agent) = configuration.user_agent {
1709        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1710    }
1711    if let Some(ref token) = configuration.bearer_access_token {
1712        req_builder = req_builder.bearer_auth(token.to_owned());
1713    };
1714    req_builder = req_builder.json(&p_body_role_request);
1715
1716    let req = req_builder.build()?;
1717    let resp = configuration.client.execute(req).await?;
1718
1719    let status = resp.status();
1720    let content_type = resp
1721        .headers()
1722        .get("content-type")
1723        .and_then(|v| v.to_str().ok())
1724        .unwrap_or("application/octet-stream");
1725    let content_type = super::ContentType::from(content_type);
1726
1727    if !status.is_client_error() && !status.is_server_error() {
1728        let content = resp.text().await?;
1729        match content_type {
1730            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1731            ContentType::Text => {
1732                return Err(Error::from(serde_json::Error::custom(
1733                    "Received `text/plain` content type response that cannot be converted to `models::Role`",
1734                )))
1735            }
1736            ContentType::Unsupported(unknown_type) => {
1737                return Err(Error::from(serde_json::Error::custom(format!(
1738                    "Received `{unknown_type}` content type response that cannot be converted to `models::Role`"
1739                ))))
1740            }
1741        }
1742    } else {
1743        let content = resp.text().await?;
1744        let entity: Option<RbacRolesCreateError> = serde_json::from_str(&content).ok();
1745        Err(Error::ResponseError(ResponseContent {
1746            status,
1747            content,
1748            entity,
1749        }))
1750    }
1751}
1752
1753/// Role viewset
1754pub async fn rbac_roles_destroy(
1755    configuration: &configuration::Configuration,
1756    uuid: &str,
1757) -> Result<(), Error<RbacRolesDestroyError>> {
1758    // add a prefix to parameters to efficiently prevent name collisions
1759    let p_path_uuid = uuid;
1760
1761    let uri_str = format!(
1762        "{}/rbac/roles/{uuid}/",
1763        configuration.base_path,
1764        uuid = crate::apis::urlencode(p_path_uuid)
1765    );
1766    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
1767
1768    if let Some(ref user_agent) = configuration.user_agent {
1769        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1770    }
1771    if let Some(ref token) = configuration.bearer_access_token {
1772        req_builder = req_builder.bearer_auth(token.to_owned());
1773    };
1774
1775    let req = req_builder.build()?;
1776    let resp = configuration.client.execute(req).await?;
1777
1778    let status = resp.status();
1779
1780    if !status.is_client_error() && !status.is_server_error() {
1781        Ok(())
1782    } else {
1783        let content = resp.text().await?;
1784        let entity: Option<RbacRolesDestroyError> = serde_json::from_str(&content).ok();
1785        Err(Error::ResponseError(ResponseContent {
1786            status,
1787            content,
1788            entity,
1789        }))
1790    }
1791}
1792
1793/// Role viewset
1794pub async fn rbac_roles_list(
1795    configuration: &configuration::Configuration,
1796    name: Option<&str>,
1797    ordering: Option<&str>,
1798    page: Option<i32>,
1799    page_size: Option<i32>,
1800    search: Option<&str>,
1801) -> Result<models::PaginatedRoleList, Error<RbacRolesListError>> {
1802    // add a prefix to parameters to efficiently prevent name collisions
1803    let p_query_name = name;
1804    let p_query_ordering = ordering;
1805    let p_query_page = page;
1806    let p_query_page_size = page_size;
1807    let p_query_search = search;
1808
1809    let uri_str = format!("{}/rbac/roles/", configuration.base_path);
1810    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1811
1812    if let Some(ref param_value) = p_query_name {
1813        req_builder = req_builder.query(&[("name", &param_value.to_string())]);
1814    }
1815    if let Some(ref param_value) = p_query_ordering {
1816        req_builder = req_builder.query(&[("ordering", &param_value.to_string())]);
1817    }
1818    if let Some(ref param_value) = p_query_page {
1819        req_builder = req_builder.query(&[("page", &param_value.to_string())]);
1820    }
1821    if let Some(ref param_value) = p_query_page_size {
1822        req_builder = req_builder.query(&[("page_size", &param_value.to_string())]);
1823    }
1824    if let Some(ref param_value) = p_query_search {
1825        req_builder = req_builder.query(&[("search", &param_value.to_string())]);
1826    }
1827    if let Some(ref user_agent) = configuration.user_agent {
1828        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1829    }
1830    if let Some(ref token) = configuration.bearer_access_token {
1831        req_builder = req_builder.bearer_auth(token.to_owned());
1832    };
1833
1834    let req = req_builder.build()?;
1835    let resp = configuration.client.execute(req).await?;
1836
1837    let status = resp.status();
1838    let content_type = resp
1839        .headers()
1840        .get("content-type")
1841        .and_then(|v| v.to_str().ok())
1842        .unwrap_or("application/octet-stream");
1843    let content_type = super::ContentType::from(content_type);
1844
1845    if !status.is_client_error() && !status.is_server_error() {
1846        let content = resp.text().await?;
1847        match content_type {
1848            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1849            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaginatedRoleList`"))),
1850            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::PaginatedRoleList`")))),
1851        }
1852    } else {
1853        let content = resp.text().await?;
1854        let entity: Option<RbacRolesListError> = serde_json::from_str(&content).ok();
1855        Err(Error::ResponseError(ResponseContent {
1856            status,
1857            content,
1858            entity,
1859        }))
1860    }
1861}
1862
1863/// Role viewset
1864pub async fn rbac_roles_partial_update(
1865    configuration: &configuration::Configuration,
1866    uuid: &str,
1867    patched_role_request: Option<models::PatchedRoleRequest>,
1868) -> Result<models::Role, Error<RbacRolesPartialUpdateError>> {
1869    // add a prefix to parameters to efficiently prevent name collisions
1870    let p_path_uuid = uuid;
1871    let p_body_patched_role_request = patched_role_request;
1872
1873    let uri_str = format!(
1874        "{}/rbac/roles/{uuid}/",
1875        configuration.base_path,
1876        uuid = crate::apis::urlencode(p_path_uuid)
1877    );
1878    let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
1879
1880    if let Some(ref user_agent) = configuration.user_agent {
1881        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1882    }
1883    if let Some(ref token) = configuration.bearer_access_token {
1884        req_builder = req_builder.bearer_auth(token.to_owned());
1885    };
1886    req_builder = req_builder.json(&p_body_patched_role_request);
1887
1888    let req = req_builder.build()?;
1889    let resp = configuration.client.execute(req).await?;
1890
1891    let status = resp.status();
1892    let content_type = resp
1893        .headers()
1894        .get("content-type")
1895        .and_then(|v| v.to_str().ok())
1896        .unwrap_or("application/octet-stream");
1897    let content_type = super::ContentType::from(content_type);
1898
1899    if !status.is_client_error() && !status.is_server_error() {
1900        let content = resp.text().await?;
1901        match content_type {
1902            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1903            ContentType::Text => {
1904                return Err(Error::from(serde_json::Error::custom(
1905                    "Received `text/plain` content type response that cannot be converted to `models::Role`",
1906                )))
1907            }
1908            ContentType::Unsupported(unknown_type) => {
1909                return Err(Error::from(serde_json::Error::custom(format!(
1910                    "Received `{unknown_type}` content type response that cannot be converted to `models::Role`"
1911                ))))
1912            }
1913        }
1914    } else {
1915        let content = resp.text().await?;
1916        let entity: Option<RbacRolesPartialUpdateError> = serde_json::from_str(&content).ok();
1917        Err(Error::ResponseError(ResponseContent {
1918            status,
1919            content,
1920            entity,
1921        }))
1922    }
1923}
1924
1925/// Role viewset
1926pub async fn rbac_roles_retrieve(
1927    configuration: &configuration::Configuration,
1928    uuid: &str,
1929) -> Result<models::Role, Error<RbacRolesRetrieveError>> {
1930    // add a prefix to parameters to efficiently prevent name collisions
1931    let p_path_uuid = uuid;
1932
1933    let uri_str = format!(
1934        "{}/rbac/roles/{uuid}/",
1935        configuration.base_path,
1936        uuid = crate::apis::urlencode(p_path_uuid)
1937    );
1938    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1939
1940    if let Some(ref user_agent) = configuration.user_agent {
1941        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1942    }
1943    if let Some(ref token) = configuration.bearer_access_token {
1944        req_builder = req_builder.bearer_auth(token.to_owned());
1945    };
1946
1947    let req = req_builder.build()?;
1948    let resp = configuration.client.execute(req).await?;
1949
1950    let status = resp.status();
1951    let content_type = resp
1952        .headers()
1953        .get("content-type")
1954        .and_then(|v| v.to_str().ok())
1955        .unwrap_or("application/octet-stream");
1956    let content_type = super::ContentType::from(content_type);
1957
1958    if !status.is_client_error() && !status.is_server_error() {
1959        let content = resp.text().await?;
1960        match content_type {
1961            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1962            ContentType::Text => {
1963                return Err(Error::from(serde_json::Error::custom(
1964                    "Received `text/plain` content type response that cannot be converted to `models::Role`",
1965                )))
1966            }
1967            ContentType::Unsupported(unknown_type) => {
1968                return Err(Error::from(serde_json::Error::custom(format!(
1969                    "Received `{unknown_type}` content type response that cannot be converted to `models::Role`"
1970                ))))
1971            }
1972        }
1973    } else {
1974        let content = resp.text().await?;
1975        let entity: Option<RbacRolesRetrieveError> = serde_json::from_str(&content).ok();
1976        Err(Error::ResponseError(ResponseContent {
1977            status,
1978            content,
1979            entity,
1980        }))
1981    }
1982}
1983
1984/// Role viewset
1985pub async fn rbac_roles_update(
1986    configuration: &configuration::Configuration,
1987    uuid: &str,
1988    role_request: models::RoleRequest,
1989) -> Result<models::Role, Error<RbacRolesUpdateError>> {
1990    // add a prefix to parameters to efficiently prevent name collisions
1991    let p_path_uuid = uuid;
1992    let p_body_role_request = role_request;
1993
1994    let uri_str = format!(
1995        "{}/rbac/roles/{uuid}/",
1996        configuration.base_path,
1997        uuid = crate::apis::urlencode(p_path_uuid)
1998    );
1999    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
2000
2001    if let Some(ref user_agent) = configuration.user_agent {
2002        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2003    }
2004    if let Some(ref token) = configuration.bearer_access_token {
2005        req_builder = req_builder.bearer_auth(token.to_owned());
2006    };
2007    req_builder = req_builder.json(&p_body_role_request);
2008
2009    let req = req_builder.build()?;
2010    let resp = configuration.client.execute(req).await?;
2011
2012    let status = resp.status();
2013    let content_type = resp
2014        .headers()
2015        .get("content-type")
2016        .and_then(|v| v.to_str().ok())
2017        .unwrap_or("application/octet-stream");
2018    let content_type = super::ContentType::from(content_type);
2019
2020    if !status.is_client_error() && !status.is_server_error() {
2021        let content = resp.text().await?;
2022        match content_type {
2023            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2024            ContentType::Text => {
2025                return Err(Error::from(serde_json::Error::custom(
2026                    "Received `text/plain` content type response that cannot be converted to `models::Role`",
2027                )))
2028            }
2029            ContentType::Unsupported(unknown_type) => {
2030                return Err(Error::from(serde_json::Error::custom(format!(
2031                    "Received `{unknown_type}` content type response that cannot be converted to `models::Role`"
2032                ))))
2033            }
2034        }
2035    } else {
2036        let content = resp.text().await?;
2037        let entity: Option<RbacRolesUpdateError> = serde_json::from_str(&content).ok();
2038        Err(Error::ResponseError(ResponseContent {
2039            status,
2040            content,
2041            entity,
2042        }))
2043    }
2044}
2045
2046/// Get a list of all objects that use this object
2047pub async fn rbac_roles_used_by_list(
2048    configuration: &configuration::Configuration,
2049    uuid: &str,
2050) -> Result<Vec<models::UsedBy>, Error<RbacRolesUsedByListError>> {
2051    // add a prefix to parameters to efficiently prevent name collisions
2052    let p_path_uuid = uuid;
2053
2054    let uri_str = format!(
2055        "{}/rbac/roles/{uuid}/used_by/",
2056        configuration.base_path,
2057        uuid = crate::apis::urlencode(p_path_uuid)
2058    );
2059    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
2060
2061    if let Some(ref user_agent) = configuration.user_agent {
2062        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
2063    }
2064    if let Some(ref token) = configuration.bearer_access_token {
2065        req_builder = req_builder.bearer_auth(token.to_owned());
2066    };
2067
2068    let req = req_builder.build()?;
2069    let resp = configuration.client.execute(req).await?;
2070
2071    let status = resp.status();
2072    let content_type = resp
2073        .headers()
2074        .get("content-type")
2075        .and_then(|v| v.to_str().ok())
2076        .unwrap_or("application/octet-stream");
2077    let content_type = super::ContentType::from(content_type);
2078
2079    if !status.is_client_error() && !status.is_server_error() {
2080        let content = resp.text().await?;
2081        match content_type {
2082            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
2083            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::UsedBy&gt;`"))),
2084            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::UsedBy&gt;`")))),
2085        }
2086    } else {
2087        let content = resp.text().await?;
2088        let entity: Option<RbacRolesUsedByListError> = serde_json::from_str(&content).ok();
2089        Err(Error::ResponseError(ResponseContent {
2090            status,
2091            content,
2092            entity,
2093        }))
2094    }
2095}