1use super::{configuration, ContentType, Error};
12use crate::{apis::ResponseContent, models};
13use reqwest;
14use serde::{de::Error as _, Deserialize, Serialize};
15
16#[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#[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#[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#[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#[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#[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#[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#[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#[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#[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#[derive(Debug, Clone, Serialize, Deserialize)]
108#[serde(untagged)]
109pub enum RbacPermissionsListError {
110 Status400(models::ValidationError),
111 Status403(models::GenericError),
112 UnknownValue(serde_json::Value),
113}
114
115#[derive(Debug, Clone, Serialize, Deserialize)]
117#[serde(untagged)]
118pub enum RbacPermissionsRetrieveError {
119 Status400(models::ValidationError),
120 Status403(models::GenericError),
121 UnknownValue(serde_json::Value),
122}
123
124#[derive(Debug, Clone, Serialize, Deserialize)]
126#[serde(untagged)]
127pub enum RbacPermissionsRolesListError {
128 Status400(models::ValidationError),
129 Status403(models::GenericError),
130 UnknownValue(serde_json::Value),
131}
132
133#[derive(Debug, Clone, Serialize, Deserialize)]
135#[serde(untagged)]
136pub enum RbacRolesAddUserCreateError {
137 Status404(),
138 Status400(models::ValidationError),
139 Status403(models::GenericError),
140 UnknownValue(serde_json::Value),
141}
142
143#[derive(Debug, Clone, Serialize, Deserialize)]
145#[serde(untagged)]
146pub enum RbacRolesCreateError {
147 Status400(models::ValidationError),
148 Status403(models::GenericError),
149 UnknownValue(serde_json::Value),
150}
151
152#[derive(Debug, Clone, Serialize, Deserialize)]
154#[serde(untagged)]
155pub enum RbacRolesDestroyError {
156 Status400(models::ValidationError),
157 Status403(models::GenericError),
158 UnknownValue(serde_json::Value),
159}
160
161#[derive(Debug, Clone, Serialize, Deserialize)]
163#[serde(untagged)]
164pub enum RbacRolesListError {
165 Status400(models::ValidationError),
166 Status403(models::GenericError),
167 UnknownValue(serde_json::Value),
168}
169
170#[derive(Debug, Clone, Serialize, Deserialize)]
172#[serde(untagged)]
173pub enum RbacRolesPartialUpdateError {
174 Status400(models::ValidationError),
175 Status403(models::GenericError),
176 UnknownValue(serde_json::Value),
177}
178
179#[derive(Debug, Clone, Serialize, Deserialize)]
181#[serde(untagged)]
182pub enum RbacRolesRemoveUserCreateError {
183 Status404(),
184 Status400(models::ValidationError),
185 Status403(models::GenericError),
186 UnknownValue(serde_json::Value),
187}
188
189#[derive(Debug, Clone, Serialize, Deserialize)]
191#[serde(untagged)]
192pub enum RbacRolesRetrieveError {
193 Status400(models::ValidationError),
194 Status403(models::GenericError),
195 UnknownValue(serde_json::Value),
196}
197
198#[derive(Debug, Clone, Serialize, Deserialize)]
200#[serde(untagged)]
201pub enum RbacRolesUpdateError {
202 Status400(models::ValidationError),
203 Status403(models::GenericError),
204 UnknownValue(serde_json::Value),
205}
206
207#[derive(Debug, Clone, Serialize, Deserialize)]
209#[serde(untagged)]
210pub enum RbacRolesUsedByListError {
211 Status400(models::ValidationError),
212 Status403(models::GenericError),
213 UnknownValue(serde_json::Value),
214}
215
216pub async fn rbac_initial_permissions_create(
218 configuration: &configuration::Configuration,
219 initial_permissions_request: models::InitialPermissionsRequest,
220) -> Result<models::InitialPermissions, Error<RbacInitialPermissionsCreateError>> {
221 let p_body_initial_permissions_request = initial_permissions_request;
223
224 let uri_str = format!("{}/rbac/initial_permissions/", configuration.base_path);
225 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
226
227 if let Some(ref user_agent) = configuration.user_agent {
228 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
229 }
230 if let Some(ref token) = configuration.bearer_access_token {
231 req_builder = req_builder.bearer_auth(token.to_owned());
232 };
233 req_builder = req_builder.json(&p_body_initial_permissions_request);
234
235 let req = req_builder.build()?;
236 let resp = configuration.client.execute(req).await?;
237
238 let status = resp.status();
239 let content_type = resp
240 .headers()
241 .get("content-type")
242 .and_then(|v| v.to_str().ok())
243 .unwrap_or("application/octet-stream");
244 let content_type = super::ContentType::from(content_type);
245
246 if !status.is_client_error() && !status.is_server_error() {
247 let content = resp.text().await?;
248 match content_type {
249 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
250 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::InitialPermissions`"))),
251 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`")))),
252 }
253 } else {
254 let content = resp.text().await?;
255 let entity: Option<RbacInitialPermissionsCreateError> = serde_json::from_str(&content).ok();
256 Err(Error::ResponseError(ResponseContent {
257 status,
258 content,
259 entity,
260 }))
261 }
262}
263
264pub async fn rbac_initial_permissions_destroy(
266 configuration: &configuration::Configuration,
267 id: i32,
268) -> Result<(), Error<RbacInitialPermissionsDestroyError>> {
269 let p_path_id = id;
271
272 let uri_str = format!(
273 "{}/rbac/initial_permissions/{id}/",
274 configuration.base_path,
275 id = p_path_id
276 );
277 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
278
279 if let Some(ref user_agent) = configuration.user_agent {
280 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
281 }
282 if let Some(ref token) = configuration.bearer_access_token {
283 req_builder = req_builder.bearer_auth(token.to_owned());
284 };
285
286 let req = req_builder.build()?;
287 let resp = configuration.client.execute(req).await?;
288
289 let status = resp.status();
290
291 if !status.is_client_error() && !status.is_server_error() {
292 Ok(())
293 } else {
294 let content = resp.text().await?;
295 let entity: Option<RbacInitialPermissionsDestroyError> = serde_json::from_str(&content).ok();
296 Err(Error::ResponseError(ResponseContent {
297 status,
298 content,
299 entity,
300 }))
301 }
302}
303
304pub async fn rbac_initial_permissions_list(
306 configuration: &configuration::Configuration,
307 name: Option<&str>,
308 ordering: Option<&str>,
309 page: Option<i32>,
310 page_size: Option<i32>,
311 search: Option<&str>,
312) -> Result<models::PaginatedInitialPermissionsList, Error<RbacInitialPermissionsListError>> {
313 let p_query_name = name;
315 let p_query_ordering = ordering;
316 let p_query_page = page;
317 let p_query_page_size = page_size;
318 let p_query_search = search;
319
320 let uri_str = format!("{}/rbac/initial_permissions/", configuration.base_path);
321 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
322
323 if let Some(ref param_value) = p_query_name {
324 req_builder = req_builder.query(&[("name", ¶m_value.to_string())]);
325 }
326 if let Some(ref param_value) = p_query_ordering {
327 req_builder = req_builder.query(&[("ordering", ¶m_value.to_string())]);
328 }
329 if let Some(ref param_value) = p_query_page {
330 req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
331 }
332 if let Some(ref param_value) = p_query_page_size {
333 req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
334 }
335 if let Some(ref param_value) = p_query_search {
336 req_builder = req_builder.query(&[("search", ¶m_value.to_string())]);
337 }
338 if let Some(ref user_agent) = configuration.user_agent {
339 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
340 }
341 if let Some(ref token) = configuration.bearer_access_token {
342 req_builder = req_builder.bearer_auth(token.to_owned());
343 };
344
345 let req = req_builder.build()?;
346 let resp = configuration.client.execute(req).await?;
347
348 let status = resp.status();
349 let content_type = resp
350 .headers()
351 .get("content-type")
352 .and_then(|v| v.to_str().ok())
353 .unwrap_or("application/octet-stream");
354 let content_type = super::ContentType::from(content_type);
355
356 if !status.is_client_error() && !status.is_server_error() {
357 let content = resp.text().await?;
358 match content_type {
359 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
360 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaginatedInitialPermissionsList`"))),
361 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`")))),
362 }
363 } else {
364 let content = resp.text().await?;
365 let entity: Option<RbacInitialPermissionsListError> = serde_json::from_str(&content).ok();
366 Err(Error::ResponseError(ResponseContent {
367 status,
368 content,
369 entity,
370 }))
371 }
372}
373
374pub async fn rbac_initial_permissions_partial_update(
376 configuration: &configuration::Configuration,
377 id: i32,
378 patched_initial_permissions_request: Option<models::PatchedInitialPermissionsRequest>,
379) -> Result<models::InitialPermissions, Error<RbacInitialPermissionsPartialUpdateError>> {
380 let p_path_id = id;
382 let p_body_patched_initial_permissions_request = patched_initial_permissions_request;
383
384 let uri_str = format!(
385 "{}/rbac/initial_permissions/{id}/",
386 configuration.base_path,
387 id = p_path_id
388 );
389 let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
390
391 if let Some(ref user_agent) = configuration.user_agent {
392 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
393 }
394 if let Some(ref token) = configuration.bearer_access_token {
395 req_builder = req_builder.bearer_auth(token.to_owned());
396 };
397 req_builder = req_builder.json(&p_body_patched_initial_permissions_request);
398
399 let req = req_builder.build()?;
400 let resp = configuration.client.execute(req).await?;
401
402 let status = resp.status();
403 let content_type = resp
404 .headers()
405 .get("content-type")
406 .and_then(|v| v.to_str().ok())
407 .unwrap_or("application/octet-stream");
408 let content_type = super::ContentType::from(content_type);
409
410 if !status.is_client_error() && !status.is_server_error() {
411 let content = resp.text().await?;
412 match content_type {
413 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
414 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::InitialPermissions`"))),
415 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`")))),
416 }
417 } else {
418 let content = resp.text().await?;
419 let entity: Option<RbacInitialPermissionsPartialUpdateError> = serde_json::from_str(&content).ok();
420 Err(Error::ResponseError(ResponseContent {
421 status,
422 content,
423 entity,
424 }))
425 }
426}
427
428pub async fn rbac_initial_permissions_retrieve(
430 configuration: &configuration::Configuration,
431 id: i32,
432) -> Result<models::InitialPermissions, Error<RbacInitialPermissionsRetrieveError>> {
433 let p_path_id = id;
435
436 let uri_str = format!(
437 "{}/rbac/initial_permissions/{id}/",
438 configuration.base_path,
439 id = p_path_id
440 );
441 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
442
443 if let Some(ref user_agent) = configuration.user_agent {
444 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
445 }
446 if let Some(ref token) = configuration.bearer_access_token {
447 req_builder = req_builder.bearer_auth(token.to_owned());
448 };
449
450 let req = req_builder.build()?;
451 let resp = configuration.client.execute(req).await?;
452
453 let status = resp.status();
454 let content_type = resp
455 .headers()
456 .get("content-type")
457 .and_then(|v| v.to_str().ok())
458 .unwrap_or("application/octet-stream");
459 let content_type = super::ContentType::from(content_type);
460
461 if !status.is_client_error() && !status.is_server_error() {
462 let content = resp.text().await?;
463 match content_type {
464 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
465 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::InitialPermissions`"))),
466 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`")))),
467 }
468 } else {
469 let content = resp.text().await?;
470 let entity: Option<RbacInitialPermissionsRetrieveError> = serde_json::from_str(&content).ok();
471 Err(Error::ResponseError(ResponseContent {
472 status,
473 content,
474 entity,
475 }))
476 }
477}
478
479pub async fn rbac_initial_permissions_update(
481 configuration: &configuration::Configuration,
482 id: i32,
483 initial_permissions_request: models::InitialPermissionsRequest,
484) -> Result<models::InitialPermissions, Error<RbacInitialPermissionsUpdateError>> {
485 let p_path_id = id;
487 let p_body_initial_permissions_request = initial_permissions_request;
488
489 let uri_str = format!(
490 "{}/rbac/initial_permissions/{id}/",
491 configuration.base_path,
492 id = p_path_id
493 );
494 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
495
496 if let Some(ref user_agent) = configuration.user_agent {
497 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
498 }
499 if let Some(ref token) = configuration.bearer_access_token {
500 req_builder = req_builder.bearer_auth(token.to_owned());
501 };
502 req_builder = req_builder.json(&p_body_initial_permissions_request);
503
504 let req = req_builder.build()?;
505 let resp = configuration.client.execute(req).await?;
506
507 let status = resp.status();
508 let content_type = resp
509 .headers()
510 .get("content-type")
511 .and_then(|v| v.to_str().ok())
512 .unwrap_or("application/octet-stream");
513 let content_type = super::ContentType::from(content_type);
514
515 if !status.is_client_error() && !status.is_server_error() {
516 let content = resp.text().await?;
517 match content_type {
518 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
519 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::InitialPermissions`"))),
520 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`")))),
521 }
522 } else {
523 let content = resp.text().await?;
524 let entity: Option<RbacInitialPermissionsUpdateError> = serde_json::from_str(&content).ok();
525 Err(Error::ResponseError(ResponseContent {
526 status,
527 content,
528 entity,
529 }))
530 }
531}
532
533pub async fn rbac_initial_permissions_used_by_list(
535 configuration: &configuration::Configuration,
536 id: i32,
537) -> Result<Vec<models::UsedBy>, Error<RbacInitialPermissionsUsedByListError>> {
538 let p_path_id = id;
540
541 let uri_str = format!(
542 "{}/rbac/initial_permissions/{id}/used_by/",
543 configuration.base_path,
544 id = p_path_id
545 );
546 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
547
548 if let Some(ref user_agent) = configuration.user_agent {
549 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
550 }
551 if let Some(ref token) = configuration.bearer_access_token {
552 req_builder = req_builder.bearer_auth(token.to_owned());
553 };
554
555 let req = req_builder.build()?;
556 let resp = configuration.client.execute(req).await?;
557
558 let status = resp.status();
559 let content_type = resp
560 .headers()
561 .get("content-type")
562 .and_then(|v| v.to_str().ok())
563 .unwrap_or("application/octet-stream");
564 let content_type = super::ContentType::from(content_type);
565
566 if !status.is_client_error() && !status.is_server_error() {
567 let content = resp.text().await?;
568 match content_type {
569 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
570 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::UsedBy>`"))),
571 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<models::UsedBy>`")))),
572 }
573 } else {
574 let content = resp.text().await?;
575 let entity: Option<RbacInitialPermissionsUsedByListError> = serde_json::from_str(&content).ok();
576 Err(Error::ResponseError(ResponseContent {
577 status,
578 content,
579 entity,
580 }))
581 }
582}
583
584pub async fn rbac_permissions_assigned_by_roles_assign(
586 configuration: &configuration::Configuration,
587 uuid: &str,
588 permission_assign_request: models::PermissionAssignRequest,
589) -> Result<Vec<models::PermissionAssignResult>, Error<RbacPermissionsAssignedByRolesAssignError>> {
590 let p_path_uuid = uuid;
592 let p_body_permission_assign_request = permission_assign_request;
593
594 let uri_str = format!(
595 "{}/rbac/permissions/assigned_by_roles/{uuid}/assign/",
596 configuration.base_path,
597 uuid = crate::apis::urlencode(p_path_uuid)
598 );
599 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
600
601 if let Some(ref user_agent) = configuration.user_agent {
602 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
603 }
604 if let Some(ref token) = configuration.bearer_access_token {
605 req_builder = req_builder.bearer_auth(token.to_owned());
606 };
607 req_builder = req_builder.json(&p_body_permission_assign_request);
608
609 let req = req_builder.build()?;
610 let resp = configuration.client.execute(req).await?;
611
612 let status = resp.status();
613 let content_type = resp
614 .headers()
615 .get("content-type")
616 .and_then(|v| v.to_str().ok())
617 .unwrap_or("application/octet-stream");
618 let content_type = super::ContentType::from(content_type);
619
620 if !status.is_client_error() && !status.is_server_error() {
621 let content = resp.text().await?;
622 match content_type {
623 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
624 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::PermissionAssignResult>`"))),
625 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<models::PermissionAssignResult>`")))),
626 }
627 } else {
628 let content = resp.text().await?;
629 let entity: Option<RbacPermissionsAssignedByRolesAssignError> = serde_json::from_str(&content).ok();
630 Err(Error::ResponseError(ResponseContent {
631 status,
632 content,
633 entity,
634 }))
635 }
636}
637
638pub async fn rbac_permissions_assigned_by_roles_list(
640 configuration: &configuration::Configuration,
641 model: &str,
642 object_pk: Option<&str>,
643 ordering: Option<&str>,
644 page: Option<i32>,
645 page_size: Option<i32>,
646 search: Option<&str>,
647) -> Result<models::PaginatedRoleAssignedObjectPermissionList, Error<RbacPermissionsAssignedByRolesListError>> {
648 let p_query_model = model;
650 let p_query_object_pk = object_pk;
651 let p_query_ordering = ordering;
652 let p_query_page = page;
653 let p_query_page_size = page_size;
654 let p_query_search = search;
655
656 let uri_str = format!("{}/rbac/permissions/assigned_by_roles/", configuration.base_path);
657 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
658
659 req_builder = req_builder.query(&[("model", &p_query_model.to_string())]);
660 if let Some(ref param_value) = p_query_object_pk {
661 req_builder = req_builder.query(&[("object_pk", ¶m_value.to_string())]);
662 }
663 if let Some(ref param_value) = p_query_ordering {
664 req_builder = req_builder.query(&[("ordering", ¶m_value.to_string())]);
665 }
666 if let Some(ref param_value) = p_query_page {
667 req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
668 }
669 if let Some(ref param_value) = p_query_page_size {
670 req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
671 }
672 if let Some(ref param_value) = p_query_search {
673 req_builder = req_builder.query(&[("search", ¶m_value.to_string())]);
674 }
675 if let Some(ref user_agent) = configuration.user_agent {
676 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
677 }
678 if let Some(ref token) = configuration.bearer_access_token {
679 req_builder = req_builder.bearer_auth(token.to_owned());
680 };
681
682 let req = req_builder.build()?;
683 let resp = configuration.client.execute(req).await?;
684
685 let status = resp.status();
686 let content_type = resp
687 .headers()
688 .get("content-type")
689 .and_then(|v| v.to_str().ok())
690 .unwrap_or("application/octet-stream");
691 let content_type = super::ContentType::from(content_type);
692
693 if !status.is_client_error() && !status.is_server_error() {
694 let content = resp.text().await?;
695 match content_type {
696 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
697 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaginatedRoleAssignedObjectPermissionList`"))),
698 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`")))),
699 }
700 } else {
701 let content = resp.text().await?;
702 let entity: Option<RbacPermissionsAssignedByRolesListError> = serde_json::from_str(&content).ok();
703 Err(Error::ResponseError(ResponseContent {
704 status,
705 content,
706 entity,
707 }))
708 }
709}
710
711pub async fn rbac_permissions_assigned_by_roles_unassign_partial_update(
713 configuration: &configuration::Configuration,
714 uuid: &str,
715 patched_permission_assign_request: Option<models::PatchedPermissionAssignRequest>,
716) -> Result<(), Error<RbacPermissionsAssignedByRolesUnassignPartialUpdateError>> {
717 let p_path_uuid = uuid;
719 let p_body_patched_permission_assign_request = patched_permission_assign_request;
720
721 let uri_str = format!(
722 "{}/rbac/permissions/assigned_by_roles/{uuid}/unassign/",
723 configuration.base_path,
724 uuid = crate::apis::urlencode(p_path_uuid)
725 );
726 let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
727
728 if let Some(ref user_agent) = configuration.user_agent {
729 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
730 }
731 if let Some(ref token) = configuration.bearer_access_token {
732 req_builder = req_builder.bearer_auth(token.to_owned());
733 };
734 req_builder = req_builder.json(&p_body_patched_permission_assign_request);
735
736 let req = req_builder.build()?;
737 let resp = configuration.client.execute(req).await?;
738
739 let status = resp.status();
740
741 if !status.is_client_error() && !status.is_server_error() {
742 Ok(())
743 } else {
744 let content = resp.text().await?;
745 let entity: Option<RbacPermissionsAssignedByRolesUnassignPartialUpdateError> =
746 serde_json::from_str(&content).ok();
747 Err(Error::ResponseError(ResponseContent {
748 status,
749 content,
750 entity,
751 }))
752 }
753}
754
755pub async fn rbac_permissions_list(
757 configuration: &configuration::Configuration,
758 codename: Option<&str>,
759 content_type__app_label: Option<&str>,
760 content_type__model: Option<&str>,
761 ordering: Option<&str>,
762 page: Option<i32>,
763 page_size: Option<i32>,
764 role: Option<&str>,
765 search: Option<&str>,
766 user: Option<i32>,
767) -> Result<models::PaginatedPermissionList, Error<RbacPermissionsListError>> {
768 let p_query_codename = codename;
770 let p_query_content_type__app_label = content_type__app_label;
771 let p_query_content_type__model = content_type__model;
772 let p_query_ordering = ordering;
773 let p_query_page = page;
774 let p_query_page_size = page_size;
775 let p_query_role = role;
776 let p_query_search = search;
777 let p_query_user = user;
778
779 let uri_str = format!("{}/rbac/permissions/", configuration.base_path);
780 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
781
782 if let Some(ref param_value) = p_query_codename {
783 req_builder = req_builder.query(&[("codename", ¶m_value.to_string())]);
784 }
785 if let Some(ref param_value) = p_query_content_type__app_label {
786 req_builder = req_builder.query(&[("content_type__app_label", ¶m_value.to_string())]);
787 }
788 if let Some(ref param_value) = p_query_content_type__model {
789 req_builder = req_builder.query(&[("content_type__model", ¶m_value.to_string())]);
790 }
791 if let Some(ref param_value) = p_query_ordering {
792 req_builder = req_builder.query(&[("ordering", ¶m_value.to_string())]);
793 }
794 if let Some(ref param_value) = p_query_page {
795 req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
796 }
797 if let Some(ref param_value) = p_query_page_size {
798 req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
799 }
800 if let Some(ref param_value) = p_query_role {
801 req_builder = req_builder.query(&[("role", ¶m_value.to_string())]);
802 }
803 if let Some(ref param_value) = p_query_search {
804 req_builder = req_builder.query(&[("search", ¶m_value.to_string())]);
805 }
806 if let Some(ref param_value) = p_query_user {
807 req_builder = req_builder.query(&[("user", ¶m_value.to_string())]);
808 }
809 if let Some(ref user_agent) = configuration.user_agent {
810 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
811 }
812 if let Some(ref token) = configuration.bearer_access_token {
813 req_builder = req_builder.bearer_auth(token.to_owned());
814 };
815
816 let req = req_builder.build()?;
817 let resp = configuration.client.execute(req).await?;
818
819 let status = resp.status();
820 let content_type = resp
821 .headers()
822 .get("content-type")
823 .and_then(|v| v.to_str().ok())
824 .unwrap_or("application/octet-stream");
825 let content_type = super::ContentType::from(content_type);
826
827 if !status.is_client_error() && !status.is_server_error() {
828 let content = resp.text().await?;
829 match content_type {
830 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
831 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaginatedPermissionList`"))),
832 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`")))),
833 }
834 } else {
835 let content = resp.text().await?;
836 let entity: Option<RbacPermissionsListError> = serde_json::from_str(&content).ok();
837 Err(Error::ResponseError(ResponseContent {
838 status,
839 content,
840 entity,
841 }))
842 }
843}
844
845pub async fn rbac_permissions_retrieve(
847 configuration: &configuration::Configuration,
848 id: i32,
849) -> Result<models::Permission, Error<RbacPermissionsRetrieveError>> {
850 let p_path_id = id;
852
853 let uri_str = format!("{}/rbac/permissions/{id}/", configuration.base_path, id = p_path_id);
854 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
855
856 if let Some(ref user_agent) = configuration.user_agent {
857 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
858 }
859 if let Some(ref token) = configuration.bearer_access_token {
860 req_builder = req_builder.bearer_auth(token.to_owned());
861 };
862
863 let req = req_builder.build()?;
864 let resp = configuration.client.execute(req).await?;
865
866 let status = resp.status();
867 let content_type = resp
868 .headers()
869 .get("content-type")
870 .and_then(|v| v.to_str().ok())
871 .unwrap_or("application/octet-stream");
872 let content_type = super::ContentType::from(content_type);
873
874 if !status.is_client_error() && !status.is_server_error() {
875 let content = resp.text().await?;
876 match content_type {
877 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
878 ContentType::Text => {
879 return Err(Error::from(serde_json::Error::custom(
880 "Received `text/plain` content type response that cannot be converted to `models::Permission`",
881 )))
882 }
883 ContentType::Unsupported(unknown_type) => {
884 return Err(Error::from(serde_json::Error::custom(format!(
885 "Received `{unknown_type}` content type response that cannot be converted to `models::Permission`"
886 ))))
887 }
888 }
889 } else {
890 let content = resp.text().await?;
891 let entity: Option<RbacPermissionsRetrieveError> = serde_json::from_str(&content).ok();
892 Err(Error::ResponseError(ResponseContent {
893 status,
894 content,
895 entity,
896 }))
897 }
898}
899
900pub async fn rbac_permissions_roles_list(
902 configuration: &configuration::Configuration,
903 ordering: Option<&str>,
904 page: Option<i32>,
905 page_size: Option<i32>,
906 search: Option<&str>,
907 uuid: Option<&str>,
908) -> Result<models::PaginatedExtraRoleObjectPermissionList, Error<RbacPermissionsRolesListError>> {
909 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 let p_query_uuid = uuid;
915
916 let uri_str = format!("{}/rbac/permissions/roles/", configuration.base_path);
917 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
918
919 if let Some(ref param_value) = p_query_ordering {
920 req_builder = req_builder.query(&[("ordering", ¶m_value.to_string())]);
921 }
922 if let Some(ref param_value) = p_query_page {
923 req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
924 }
925 if let Some(ref param_value) = p_query_page_size {
926 req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
927 }
928 if let Some(ref param_value) = p_query_search {
929 req_builder = req_builder.query(&[("search", ¶m_value.to_string())]);
930 }
931 if let Some(ref param_value) = p_query_uuid {
932 req_builder = req_builder.query(&[("uuid", ¶m_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::PaginatedExtraRoleObjectPermissionList`"))),
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::PaginatedExtraRoleObjectPermissionList`")))),
958 }
959 } else {
960 let content = resp.text().await?;
961 let entity: Option<RbacPermissionsRolesListError> = serde_json::from_str(&content).ok();
962 Err(Error::ResponseError(ResponseContent {
963 status,
964 content,
965 entity,
966 }))
967 }
968}
969
970pub async fn rbac_roles_add_user_create(
972 configuration: &configuration::Configuration,
973 uuid: &str,
974 user_account_serializer_for_role_request: models::UserAccountSerializerForRoleRequest,
975) -> Result<(), Error<RbacRolesAddUserCreateError>> {
976 let p_path_uuid = uuid;
978 let p_body_user_account_serializer_for_role_request = user_account_serializer_for_role_request;
979
980 let uri_str = format!(
981 "{}/rbac/roles/{uuid}/add_user/",
982 configuration.base_path,
983 uuid = crate::apis::urlencode(p_path_uuid)
984 );
985 let mut req_builder = configuration.client.request(reqwest::Method::POST, &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_user_account_serializer_for_role_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<RbacRolesAddUserCreateError> = serde_json::from_str(&content).ok();
1005 Err(Error::ResponseError(ResponseContent {
1006 status,
1007 content,
1008 entity,
1009 }))
1010 }
1011}
1012
1013pub async fn rbac_roles_create(
1015 configuration: &configuration::Configuration,
1016 role_request: models::RoleRequest,
1017) -> Result<models::Role, Error<RbacRolesCreateError>> {
1018 let p_body_role_request = role_request;
1020
1021 let uri_str = format!("{}/rbac/roles/", configuration.base_path);
1022 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1023
1024 if let Some(ref user_agent) = configuration.user_agent {
1025 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1026 }
1027 if let Some(ref token) = configuration.bearer_access_token {
1028 req_builder = req_builder.bearer_auth(token.to_owned());
1029 };
1030 req_builder = req_builder.json(&p_body_role_request);
1031
1032 let req = req_builder.build()?;
1033 let resp = configuration.client.execute(req).await?;
1034
1035 let status = resp.status();
1036 let content_type = resp
1037 .headers()
1038 .get("content-type")
1039 .and_then(|v| v.to_str().ok())
1040 .unwrap_or("application/octet-stream");
1041 let content_type = super::ContentType::from(content_type);
1042
1043 if !status.is_client_error() && !status.is_server_error() {
1044 let content = resp.text().await?;
1045 match content_type {
1046 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1047 ContentType::Text => {
1048 return Err(Error::from(serde_json::Error::custom(
1049 "Received `text/plain` content type response that cannot be converted to `models::Role`",
1050 )))
1051 }
1052 ContentType::Unsupported(unknown_type) => {
1053 return Err(Error::from(serde_json::Error::custom(format!(
1054 "Received `{unknown_type}` content type response that cannot be converted to `models::Role`"
1055 ))))
1056 }
1057 }
1058 } else {
1059 let content = resp.text().await?;
1060 let entity: Option<RbacRolesCreateError> = serde_json::from_str(&content).ok();
1061 Err(Error::ResponseError(ResponseContent {
1062 status,
1063 content,
1064 entity,
1065 }))
1066 }
1067}
1068
1069pub async fn rbac_roles_destroy(
1071 configuration: &configuration::Configuration,
1072 uuid: &str,
1073) -> Result<(), Error<RbacRolesDestroyError>> {
1074 let p_path_uuid = uuid;
1076
1077 let uri_str = format!(
1078 "{}/rbac/roles/{uuid}/",
1079 configuration.base_path,
1080 uuid = crate::apis::urlencode(p_path_uuid)
1081 );
1082 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
1083
1084 if let Some(ref user_agent) = configuration.user_agent {
1085 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1086 }
1087 if let Some(ref token) = configuration.bearer_access_token {
1088 req_builder = req_builder.bearer_auth(token.to_owned());
1089 };
1090
1091 let req = req_builder.build()?;
1092 let resp = configuration.client.execute(req).await?;
1093
1094 let status = resp.status();
1095
1096 if !status.is_client_error() && !status.is_server_error() {
1097 Ok(())
1098 } else {
1099 let content = resp.text().await?;
1100 let entity: Option<RbacRolesDestroyError> = serde_json::from_str(&content).ok();
1101 Err(Error::ResponseError(ResponseContent {
1102 status,
1103 content,
1104 entity,
1105 }))
1106 }
1107}
1108
1109pub async fn rbac_roles_list(
1111 configuration: &configuration::Configuration,
1112 ak_groups: Option<&str>,
1113 inherited: Option<bool>,
1114 managed: Option<Vec<String>>,
1115 managed__isnull: Option<bool>,
1116 name: Option<&str>,
1117 ordering: Option<&str>,
1118 page: Option<i32>,
1119 page_size: Option<i32>,
1120 search: Option<&str>,
1121 users: Option<i32>,
1122) -> Result<models::PaginatedRoleList, Error<RbacRolesListError>> {
1123 let p_query_ak_groups = ak_groups;
1125 let p_query_inherited = inherited;
1126 let p_query_managed = managed;
1127 let p_query_managed__isnull = managed__isnull;
1128 let p_query_name = name;
1129 let p_query_ordering = ordering;
1130 let p_query_page = page;
1131 let p_query_page_size = page_size;
1132 let p_query_search = search;
1133 let p_query_users = users;
1134
1135 let uri_str = format!("{}/rbac/roles/", configuration.base_path);
1136 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1137
1138 if let Some(ref param_value) = p_query_ak_groups {
1139 req_builder = req_builder.query(&[("ak_groups", ¶m_value.to_string())]);
1140 }
1141 if let Some(ref param_value) = p_query_inherited {
1142 req_builder = req_builder.query(&[("inherited", ¶m_value.to_string())]);
1143 }
1144 if let Some(ref param_value) = p_query_managed {
1145 req_builder = match "multi" {
1146 "multi" => req_builder.query(
1147 ¶m_value
1148 .into_iter()
1149 .map(|p| ("managed".to_owned(), p.to_string()))
1150 .collect::<Vec<(std::string::String, std::string::String)>>(),
1151 ),
1152 _ => req_builder.query(&[(
1153 "managed",
1154 ¶m_value
1155 .into_iter()
1156 .map(|p| p.to_string())
1157 .collect::<Vec<String>>()
1158 .join(",")
1159 .to_string(),
1160 )]),
1161 };
1162 }
1163 if let Some(ref param_value) = p_query_managed__isnull {
1164 req_builder = req_builder.query(&[("managed__isnull", ¶m_value.to_string())]);
1165 }
1166 if let Some(ref param_value) = p_query_name {
1167 req_builder = req_builder.query(&[("name", ¶m_value.to_string())]);
1168 }
1169 if let Some(ref param_value) = p_query_ordering {
1170 req_builder = req_builder.query(&[("ordering", ¶m_value.to_string())]);
1171 }
1172 if let Some(ref param_value) = p_query_page {
1173 req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
1174 }
1175 if let Some(ref param_value) = p_query_page_size {
1176 req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
1177 }
1178 if let Some(ref param_value) = p_query_search {
1179 req_builder = req_builder.query(&[("search", ¶m_value.to_string())]);
1180 }
1181 if let Some(ref param_value) = p_query_users {
1182 req_builder = req_builder.query(&[("users", ¶m_value.to_string())]);
1183 }
1184 if let Some(ref user_agent) = configuration.user_agent {
1185 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1186 }
1187 if let Some(ref token) = configuration.bearer_access_token {
1188 req_builder = req_builder.bearer_auth(token.to_owned());
1189 };
1190
1191 let req = req_builder.build()?;
1192 let resp = configuration.client.execute(req).await?;
1193
1194 let status = resp.status();
1195 let content_type = resp
1196 .headers()
1197 .get("content-type")
1198 .and_then(|v| v.to_str().ok())
1199 .unwrap_or("application/octet-stream");
1200 let content_type = super::ContentType::from(content_type);
1201
1202 if !status.is_client_error() && !status.is_server_error() {
1203 let content = resp.text().await?;
1204 match content_type {
1205 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1206 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaginatedRoleList`"))),
1207 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`")))),
1208 }
1209 } else {
1210 let content = resp.text().await?;
1211 let entity: Option<RbacRolesListError> = serde_json::from_str(&content).ok();
1212 Err(Error::ResponseError(ResponseContent {
1213 status,
1214 content,
1215 entity,
1216 }))
1217 }
1218}
1219
1220pub async fn rbac_roles_partial_update(
1222 configuration: &configuration::Configuration,
1223 uuid: &str,
1224 patched_role_request: Option<models::PatchedRoleRequest>,
1225) -> Result<models::Role, Error<RbacRolesPartialUpdateError>> {
1226 let p_path_uuid = uuid;
1228 let p_body_patched_role_request = patched_role_request;
1229
1230 let uri_str = format!(
1231 "{}/rbac/roles/{uuid}/",
1232 configuration.base_path,
1233 uuid = crate::apis::urlencode(p_path_uuid)
1234 );
1235 let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
1236
1237 if let Some(ref user_agent) = configuration.user_agent {
1238 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1239 }
1240 if let Some(ref token) = configuration.bearer_access_token {
1241 req_builder = req_builder.bearer_auth(token.to_owned());
1242 };
1243 req_builder = req_builder.json(&p_body_patched_role_request);
1244
1245 let req = req_builder.build()?;
1246 let resp = configuration.client.execute(req).await?;
1247
1248 let status = resp.status();
1249 let content_type = resp
1250 .headers()
1251 .get("content-type")
1252 .and_then(|v| v.to_str().ok())
1253 .unwrap_or("application/octet-stream");
1254 let content_type = super::ContentType::from(content_type);
1255
1256 if !status.is_client_error() && !status.is_server_error() {
1257 let content = resp.text().await?;
1258 match content_type {
1259 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1260 ContentType::Text => {
1261 return Err(Error::from(serde_json::Error::custom(
1262 "Received `text/plain` content type response that cannot be converted to `models::Role`",
1263 )))
1264 }
1265 ContentType::Unsupported(unknown_type) => {
1266 return Err(Error::from(serde_json::Error::custom(format!(
1267 "Received `{unknown_type}` content type response that cannot be converted to `models::Role`"
1268 ))))
1269 }
1270 }
1271 } else {
1272 let content = resp.text().await?;
1273 let entity: Option<RbacRolesPartialUpdateError> = serde_json::from_str(&content).ok();
1274 Err(Error::ResponseError(ResponseContent {
1275 status,
1276 content,
1277 entity,
1278 }))
1279 }
1280}
1281
1282pub async fn rbac_roles_remove_user_create(
1284 configuration: &configuration::Configuration,
1285 uuid: &str,
1286 user_account_serializer_for_role_request: models::UserAccountSerializerForRoleRequest,
1287) -> Result<(), Error<RbacRolesRemoveUserCreateError>> {
1288 let p_path_uuid = uuid;
1290 let p_body_user_account_serializer_for_role_request = user_account_serializer_for_role_request;
1291
1292 let uri_str = format!(
1293 "{}/rbac/roles/{uuid}/remove_user/",
1294 configuration.base_path,
1295 uuid = crate::apis::urlencode(p_path_uuid)
1296 );
1297 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1298
1299 if let Some(ref user_agent) = configuration.user_agent {
1300 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1301 }
1302 if let Some(ref token) = configuration.bearer_access_token {
1303 req_builder = req_builder.bearer_auth(token.to_owned());
1304 };
1305 req_builder = req_builder.json(&p_body_user_account_serializer_for_role_request);
1306
1307 let req = req_builder.build()?;
1308 let resp = configuration.client.execute(req).await?;
1309
1310 let status = resp.status();
1311
1312 if !status.is_client_error() && !status.is_server_error() {
1313 Ok(())
1314 } else {
1315 let content = resp.text().await?;
1316 let entity: Option<RbacRolesRemoveUserCreateError> = serde_json::from_str(&content).ok();
1317 Err(Error::ResponseError(ResponseContent {
1318 status,
1319 content,
1320 entity,
1321 }))
1322 }
1323}
1324
1325pub async fn rbac_roles_retrieve(
1327 configuration: &configuration::Configuration,
1328 uuid: &str,
1329) -> Result<models::Role, Error<RbacRolesRetrieveError>> {
1330 let p_path_uuid = uuid;
1332
1333 let uri_str = format!(
1334 "{}/rbac/roles/{uuid}/",
1335 configuration.base_path,
1336 uuid = crate::apis::urlencode(p_path_uuid)
1337 );
1338 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1339
1340 if let Some(ref user_agent) = configuration.user_agent {
1341 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1342 }
1343 if let Some(ref token) = configuration.bearer_access_token {
1344 req_builder = req_builder.bearer_auth(token.to_owned());
1345 };
1346
1347 let req = req_builder.build()?;
1348 let resp = configuration.client.execute(req).await?;
1349
1350 let status = resp.status();
1351 let content_type = resp
1352 .headers()
1353 .get("content-type")
1354 .and_then(|v| v.to_str().ok())
1355 .unwrap_or("application/octet-stream");
1356 let content_type = super::ContentType::from(content_type);
1357
1358 if !status.is_client_error() && !status.is_server_error() {
1359 let content = resp.text().await?;
1360 match content_type {
1361 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1362 ContentType::Text => {
1363 return Err(Error::from(serde_json::Error::custom(
1364 "Received `text/plain` content type response that cannot be converted to `models::Role`",
1365 )))
1366 }
1367 ContentType::Unsupported(unknown_type) => {
1368 return Err(Error::from(serde_json::Error::custom(format!(
1369 "Received `{unknown_type}` content type response that cannot be converted to `models::Role`"
1370 ))))
1371 }
1372 }
1373 } else {
1374 let content = resp.text().await?;
1375 let entity: Option<RbacRolesRetrieveError> = serde_json::from_str(&content).ok();
1376 Err(Error::ResponseError(ResponseContent {
1377 status,
1378 content,
1379 entity,
1380 }))
1381 }
1382}
1383
1384pub async fn rbac_roles_update(
1386 configuration: &configuration::Configuration,
1387 uuid: &str,
1388 role_request: models::RoleRequest,
1389) -> Result<models::Role, Error<RbacRolesUpdateError>> {
1390 let p_path_uuid = uuid;
1392 let p_body_role_request = role_request;
1393
1394 let uri_str = format!(
1395 "{}/rbac/roles/{uuid}/",
1396 configuration.base_path,
1397 uuid = crate::apis::urlencode(p_path_uuid)
1398 );
1399 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
1400
1401 if let Some(ref user_agent) = configuration.user_agent {
1402 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1403 }
1404 if let Some(ref token) = configuration.bearer_access_token {
1405 req_builder = req_builder.bearer_auth(token.to_owned());
1406 };
1407 req_builder = req_builder.json(&p_body_role_request);
1408
1409 let req = req_builder.build()?;
1410 let resp = configuration.client.execute(req).await?;
1411
1412 let status = resp.status();
1413 let content_type = resp
1414 .headers()
1415 .get("content-type")
1416 .and_then(|v| v.to_str().ok())
1417 .unwrap_or("application/octet-stream");
1418 let content_type = super::ContentType::from(content_type);
1419
1420 if !status.is_client_error() && !status.is_server_error() {
1421 let content = resp.text().await?;
1422 match content_type {
1423 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1424 ContentType::Text => {
1425 return Err(Error::from(serde_json::Error::custom(
1426 "Received `text/plain` content type response that cannot be converted to `models::Role`",
1427 )))
1428 }
1429 ContentType::Unsupported(unknown_type) => {
1430 return Err(Error::from(serde_json::Error::custom(format!(
1431 "Received `{unknown_type}` content type response that cannot be converted to `models::Role`"
1432 ))))
1433 }
1434 }
1435 } else {
1436 let content = resp.text().await?;
1437 let entity: Option<RbacRolesUpdateError> = serde_json::from_str(&content).ok();
1438 Err(Error::ResponseError(ResponseContent {
1439 status,
1440 content,
1441 entity,
1442 }))
1443 }
1444}
1445
1446pub async fn rbac_roles_used_by_list(
1448 configuration: &configuration::Configuration,
1449 uuid: &str,
1450) -> Result<Vec<models::UsedBy>, Error<RbacRolesUsedByListError>> {
1451 let p_path_uuid = uuid;
1453
1454 let uri_str = format!(
1455 "{}/rbac/roles/{uuid}/used_by/",
1456 configuration.base_path,
1457 uuid = crate::apis::urlencode(p_path_uuid)
1458 );
1459 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1460
1461 if let Some(ref user_agent) = configuration.user_agent {
1462 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1463 }
1464 if let Some(ref token) = configuration.bearer_access_token {
1465 req_builder = req_builder.bearer_auth(token.to_owned());
1466 };
1467
1468 let req = req_builder.build()?;
1469 let resp = configuration.client.execute(req).await?;
1470
1471 let status = resp.status();
1472 let content_type = resp
1473 .headers()
1474 .get("content-type")
1475 .and_then(|v| v.to_str().ok())
1476 .unwrap_or("application/octet-stream");
1477 let content_type = super::ContentType::from(content_type);
1478
1479 if !status.is_client_error() && !status.is_server_error() {
1480 let content = resp.text().await?;
1481 match content_type {
1482 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1483 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::UsedBy>`"))),
1484 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<models::UsedBy>`")))),
1485 }
1486 } else {
1487 let content = resp.text().await?;
1488 let entity: Option<RbacRolesUsedByListError> = serde_json::from_str(&content).ok();
1489 Err(Error::ResponseError(ResponseContent {
1490 status,
1491 content,
1492 entity,
1493 }))
1494 }
1495}