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) -> Result<models::PaginatedPermissionList, Error<RbacPermissionsListError>> {
767 let p_query_codename = codename;
769 let p_query_content_type__app_label = content_type__app_label;
770 let p_query_content_type__model = content_type__model;
771 let p_query_ordering = ordering;
772 let p_query_page = page;
773 let p_query_page_size = page_size;
774 let p_query_role = role;
775 let p_query_search = search;
776
777 let uri_str = format!("{}/rbac/permissions/", configuration.base_path);
778 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
779
780 if let Some(ref param_value) = p_query_codename {
781 req_builder = req_builder.query(&[("codename", ¶m_value.to_string())]);
782 }
783 if let Some(ref param_value) = p_query_content_type__app_label {
784 req_builder = req_builder.query(&[("content_type__app_label", ¶m_value.to_string())]);
785 }
786 if let Some(ref param_value) = p_query_content_type__model {
787 req_builder = req_builder.query(&[("content_type__model", ¶m_value.to_string())]);
788 }
789 if let Some(ref param_value) = p_query_ordering {
790 req_builder = req_builder.query(&[("ordering", ¶m_value.to_string())]);
791 }
792 if let Some(ref param_value) = p_query_page {
793 req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
794 }
795 if let Some(ref param_value) = p_query_page_size {
796 req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
797 }
798 if let Some(ref param_value) = p_query_role {
799 req_builder = req_builder.query(&[("role", ¶m_value.to_string())]);
800 }
801 if let Some(ref param_value) = p_query_search {
802 req_builder = req_builder.query(&[("search", ¶m_value.to_string())]);
803 }
804 if let Some(ref user_agent) = configuration.user_agent {
805 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
806 }
807 if let Some(ref token) = configuration.bearer_access_token {
808 req_builder = req_builder.bearer_auth(token.to_owned());
809 };
810
811 let req = req_builder.build()?;
812 let resp = configuration.client.execute(req).await?;
813
814 let status = resp.status();
815 let content_type = resp
816 .headers()
817 .get("content-type")
818 .and_then(|v| v.to_str().ok())
819 .unwrap_or("application/octet-stream");
820 let content_type = super::ContentType::from(content_type);
821
822 if !status.is_client_error() && !status.is_server_error() {
823 let content = resp.text().await?;
824 match content_type {
825 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
826 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaginatedPermissionList`"))),
827 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`")))),
828 }
829 } else {
830 let content = resp.text().await?;
831 let entity: Option<RbacPermissionsListError> = serde_json::from_str(&content).ok();
832 Err(Error::ResponseError(ResponseContent {
833 status,
834 content,
835 entity,
836 }))
837 }
838}
839
840pub async fn rbac_permissions_retrieve(
842 configuration: &configuration::Configuration,
843 id: i32,
844) -> Result<models::Permission, Error<RbacPermissionsRetrieveError>> {
845 let p_path_id = id;
847
848 let uri_str = format!("{}/rbac/permissions/{id}/", configuration.base_path, id = p_path_id);
849 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
850
851 if let Some(ref user_agent) = configuration.user_agent {
852 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
853 }
854 if let Some(ref token) = configuration.bearer_access_token {
855 req_builder = req_builder.bearer_auth(token.to_owned());
856 };
857
858 let req = req_builder.build()?;
859 let resp = configuration.client.execute(req).await?;
860
861 let status = resp.status();
862 let content_type = resp
863 .headers()
864 .get("content-type")
865 .and_then(|v| v.to_str().ok())
866 .unwrap_or("application/octet-stream");
867 let content_type = super::ContentType::from(content_type);
868
869 if !status.is_client_error() && !status.is_server_error() {
870 let content = resp.text().await?;
871 match content_type {
872 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
873 ContentType::Text => {
874 return Err(Error::from(serde_json::Error::custom(
875 "Received `text/plain` content type response that cannot be converted to `models::Permission`",
876 )))
877 }
878 ContentType::Unsupported(unknown_type) => {
879 return Err(Error::from(serde_json::Error::custom(format!(
880 "Received `{unknown_type}` content type response that cannot be converted to `models::Permission`"
881 ))))
882 }
883 }
884 } else {
885 let content = resp.text().await?;
886 let entity: Option<RbacPermissionsRetrieveError> = serde_json::from_str(&content).ok();
887 Err(Error::ResponseError(ResponseContent {
888 status,
889 content,
890 entity,
891 }))
892 }
893}
894
895pub async fn rbac_permissions_roles_list(
897 configuration: &configuration::Configuration,
898 ordering: Option<&str>,
899 page: Option<i32>,
900 page_size: Option<i32>,
901 search: Option<&str>,
902 uuid: Option<&str>,
903) -> Result<models::PaginatedExtraRoleObjectPermissionList, Error<RbacPermissionsRolesListError>> {
904 let p_query_ordering = ordering;
906 let p_query_page = page;
907 let p_query_page_size = page_size;
908 let p_query_search = search;
909 let p_query_uuid = uuid;
910
911 let uri_str = format!("{}/rbac/permissions/roles/", configuration.base_path);
912 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
913
914 if let Some(ref param_value) = p_query_ordering {
915 req_builder = req_builder.query(&[("ordering", ¶m_value.to_string())]);
916 }
917 if let Some(ref param_value) = p_query_page {
918 req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
919 }
920 if let Some(ref param_value) = p_query_page_size {
921 req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
922 }
923 if let Some(ref param_value) = p_query_search {
924 req_builder = req_builder.query(&[("search", ¶m_value.to_string())]);
925 }
926 if let Some(ref param_value) = p_query_uuid {
927 req_builder = req_builder.query(&[("uuid", ¶m_value.to_string())]);
928 }
929 if let Some(ref user_agent) = configuration.user_agent {
930 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
931 }
932 if let Some(ref token) = configuration.bearer_access_token {
933 req_builder = req_builder.bearer_auth(token.to_owned());
934 };
935
936 let req = req_builder.build()?;
937 let resp = configuration.client.execute(req).await?;
938
939 let status = resp.status();
940 let content_type = resp
941 .headers()
942 .get("content-type")
943 .and_then(|v| v.to_str().ok())
944 .unwrap_or("application/octet-stream");
945 let content_type = super::ContentType::from(content_type);
946
947 if !status.is_client_error() && !status.is_server_error() {
948 let content = resp.text().await?;
949 match content_type {
950 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
951 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaginatedExtraRoleObjectPermissionList`"))),
952 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`")))),
953 }
954 } else {
955 let content = resp.text().await?;
956 let entity: Option<RbacPermissionsRolesListError> = serde_json::from_str(&content).ok();
957 Err(Error::ResponseError(ResponseContent {
958 status,
959 content,
960 entity,
961 }))
962 }
963}
964
965pub async fn rbac_roles_add_user_create(
967 configuration: &configuration::Configuration,
968 uuid: &str,
969 user_account_serializer_for_role_request: models::UserAccountSerializerForRoleRequest,
970) -> Result<(), Error<RbacRolesAddUserCreateError>> {
971 let p_path_uuid = uuid;
973 let p_body_user_account_serializer_for_role_request = user_account_serializer_for_role_request;
974
975 let uri_str = format!(
976 "{}/rbac/roles/{uuid}/add_user/",
977 configuration.base_path,
978 uuid = crate::apis::urlencode(p_path_uuid)
979 );
980 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
981
982 if let Some(ref user_agent) = configuration.user_agent {
983 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
984 }
985 if let Some(ref token) = configuration.bearer_access_token {
986 req_builder = req_builder.bearer_auth(token.to_owned());
987 };
988 req_builder = req_builder.json(&p_body_user_account_serializer_for_role_request);
989
990 let req = req_builder.build()?;
991 let resp = configuration.client.execute(req).await?;
992
993 let status = resp.status();
994
995 if !status.is_client_error() && !status.is_server_error() {
996 Ok(())
997 } else {
998 let content = resp.text().await?;
999 let entity: Option<RbacRolesAddUserCreateError> = serde_json::from_str(&content).ok();
1000 Err(Error::ResponseError(ResponseContent {
1001 status,
1002 content,
1003 entity,
1004 }))
1005 }
1006}
1007
1008pub async fn rbac_roles_create(
1010 configuration: &configuration::Configuration,
1011 role_request: models::RoleRequest,
1012) -> Result<models::Role, Error<RbacRolesCreateError>> {
1013 let p_body_role_request = role_request;
1015
1016 let uri_str = format!("{}/rbac/roles/", configuration.base_path);
1017 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1018
1019 if let Some(ref user_agent) = configuration.user_agent {
1020 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1021 }
1022 if let Some(ref token) = configuration.bearer_access_token {
1023 req_builder = req_builder.bearer_auth(token.to_owned());
1024 };
1025 req_builder = req_builder.json(&p_body_role_request);
1026
1027 let req = req_builder.build()?;
1028 let resp = configuration.client.execute(req).await?;
1029
1030 let status = resp.status();
1031 let content_type = resp
1032 .headers()
1033 .get("content-type")
1034 .and_then(|v| v.to_str().ok())
1035 .unwrap_or("application/octet-stream");
1036 let content_type = super::ContentType::from(content_type);
1037
1038 if !status.is_client_error() && !status.is_server_error() {
1039 let content = resp.text().await?;
1040 match content_type {
1041 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1042 ContentType::Text => {
1043 return Err(Error::from(serde_json::Error::custom(
1044 "Received `text/plain` content type response that cannot be converted to `models::Role`",
1045 )))
1046 }
1047 ContentType::Unsupported(unknown_type) => {
1048 return Err(Error::from(serde_json::Error::custom(format!(
1049 "Received `{unknown_type}` content type response that cannot be converted to `models::Role`"
1050 ))))
1051 }
1052 }
1053 } else {
1054 let content = resp.text().await?;
1055 let entity: Option<RbacRolesCreateError> = serde_json::from_str(&content).ok();
1056 Err(Error::ResponseError(ResponseContent {
1057 status,
1058 content,
1059 entity,
1060 }))
1061 }
1062}
1063
1064pub async fn rbac_roles_destroy(
1066 configuration: &configuration::Configuration,
1067 uuid: &str,
1068) -> Result<(), Error<RbacRolesDestroyError>> {
1069 let p_path_uuid = uuid;
1071
1072 let uri_str = format!(
1073 "{}/rbac/roles/{uuid}/",
1074 configuration.base_path,
1075 uuid = crate::apis::urlencode(p_path_uuid)
1076 );
1077 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
1078
1079 if let Some(ref user_agent) = configuration.user_agent {
1080 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1081 }
1082 if let Some(ref token) = configuration.bearer_access_token {
1083 req_builder = req_builder.bearer_auth(token.to_owned());
1084 };
1085
1086 let req = req_builder.build()?;
1087 let resp = configuration.client.execute(req).await?;
1088
1089 let status = resp.status();
1090
1091 if !status.is_client_error() && !status.is_server_error() {
1092 Ok(())
1093 } else {
1094 let content = resp.text().await?;
1095 let entity: Option<RbacRolesDestroyError> = serde_json::from_str(&content).ok();
1096 Err(Error::ResponseError(ResponseContent {
1097 status,
1098 content,
1099 entity,
1100 }))
1101 }
1102}
1103
1104pub async fn rbac_roles_list(
1106 configuration: &configuration::Configuration,
1107 groups: Option<&str>,
1108 inherited: Option<bool>,
1109 managed: Option<Vec<String>>,
1110 managed__isnull: Option<bool>,
1111 name: Option<&str>,
1112 ordering: Option<&str>,
1113 page: Option<i32>,
1114 page_size: Option<i32>,
1115 search: Option<&str>,
1116 users: Option<i32>,
1117) -> Result<models::PaginatedRoleList, Error<RbacRolesListError>> {
1118 let p_query_groups = groups;
1120 let p_query_inherited = inherited;
1121 let p_query_managed = managed;
1122 let p_query_managed__isnull = managed__isnull;
1123 let p_query_name = name;
1124 let p_query_ordering = ordering;
1125 let p_query_page = page;
1126 let p_query_page_size = page_size;
1127 let p_query_search = search;
1128 let p_query_users = users;
1129
1130 let uri_str = format!("{}/rbac/roles/", configuration.base_path);
1131 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1132
1133 if let Some(ref param_value) = p_query_groups {
1134 req_builder = req_builder.query(&[("groups", ¶m_value.to_string())]);
1135 }
1136 if let Some(ref param_value) = p_query_inherited {
1137 req_builder = req_builder.query(&[("inherited", ¶m_value.to_string())]);
1138 }
1139 if let Some(ref param_value) = p_query_managed {
1140 req_builder = match "multi" {
1141 "multi" => req_builder.query(
1142 ¶m_value
1143 .into_iter()
1144 .map(|p| ("managed".to_owned(), p.to_string()))
1145 .collect::<Vec<(std::string::String, std::string::String)>>(),
1146 ),
1147 _ => req_builder.query(&[(
1148 "managed",
1149 ¶m_value
1150 .into_iter()
1151 .map(|p| p.to_string())
1152 .collect::<Vec<String>>()
1153 .join(",")
1154 .to_string(),
1155 )]),
1156 };
1157 }
1158 if let Some(ref param_value) = p_query_managed__isnull {
1159 req_builder = req_builder.query(&[("managed__isnull", ¶m_value.to_string())]);
1160 }
1161 if let Some(ref param_value) = p_query_name {
1162 req_builder = req_builder.query(&[("name", ¶m_value.to_string())]);
1163 }
1164 if let Some(ref param_value) = p_query_ordering {
1165 req_builder = req_builder.query(&[("ordering", ¶m_value.to_string())]);
1166 }
1167 if let Some(ref param_value) = p_query_page {
1168 req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
1169 }
1170 if let Some(ref param_value) = p_query_page_size {
1171 req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
1172 }
1173 if let Some(ref param_value) = p_query_search {
1174 req_builder = req_builder.query(&[("search", ¶m_value.to_string())]);
1175 }
1176 if let Some(ref param_value) = p_query_users {
1177 req_builder = req_builder.query(&[("users", ¶m_value.to_string())]);
1178 }
1179 if let Some(ref user_agent) = configuration.user_agent {
1180 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1181 }
1182 if let Some(ref token) = configuration.bearer_access_token {
1183 req_builder = req_builder.bearer_auth(token.to_owned());
1184 };
1185
1186 let req = req_builder.build()?;
1187 let resp = configuration.client.execute(req).await?;
1188
1189 let status = resp.status();
1190 let content_type = resp
1191 .headers()
1192 .get("content-type")
1193 .and_then(|v| v.to_str().ok())
1194 .unwrap_or("application/octet-stream");
1195 let content_type = super::ContentType::from(content_type);
1196
1197 if !status.is_client_error() && !status.is_server_error() {
1198 let content = resp.text().await?;
1199 match content_type {
1200 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1201 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaginatedRoleList`"))),
1202 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`")))),
1203 }
1204 } else {
1205 let content = resp.text().await?;
1206 let entity: Option<RbacRolesListError> = serde_json::from_str(&content).ok();
1207 Err(Error::ResponseError(ResponseContent {
1208 status,
1209 content,
1210 entity,
1211 }))
1212 }
1213}
1214
1215pub async fn rbac_roles_partial_update(
1217 configuration: &configuration::Configuration,
1218 uuid: &str,
1219 patched_role_request: Option<models::PatchedRoleRequest>,
1220) -> Result<models::Role, Error<RbacRolesPartialUpdateError>> {
1221 let p_path_uuid = uuid;
1223 let p_body_patched_role_request = patched_role_request;
1224
1225 let uri_str = format!(
1226 "{}/rbac/roles/{uuid}/",
1227 configuration.base_path,
1228 uuid = crate::apis::urlencode(p_path_uuid)
1229 );
1230 let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
1231
1232 if let Some(ref user_agent) = configuration.user_agent {
1233 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1234 }
1235 if let Some(ref token) = configuration.bearer_access_token {
1236 req_builder = req_builder.bearer_auth(token.to_owned());
1237 };
1238 req_builder = req_builder.json(&p_body_patched_role_request);
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 => {
1256 return Err(Error::from(serde_json::Error::custom(
1257 "Received `text/plain` content type response that cannot be converted to `models::Role`",
1258 )))
1259 }
1260 ContentType::Unsupported(unknown_type) => {
1261 return Err(Error::from(serde_json::Error::custom(format!(
1262 "Received `{unknown_type}` content type response that cannot be converted to `models::Role`"
1263 ))))
1264 }
1265 }
1266 } else {
1267 let content = resp.text().await?;
1268 let entity: Option<RbacRolesPartialUpdateError> = serde_json::from_str(&content).ok();
1269 Err(Error::ResponseError(ResponseContent {
1270 status,
1271 content,
1272 entity,
1273 }))
1274 }
1275}
1276
1277pub async fn rbac_roles_remove_user_create(
1279 configuration: &configuration::Configuration,
1280 uuid: &str,
1281 user_account_serializer_for_role_request: models::UserAccountSerializerForRoleRequest,
1282) -> Result<(), Error<RbacRolesRemoveUserCreateError>> {
1283 let p_path_uuid = uuid;
1285 let p_body_user_account_serializer_for_role_request = user_account_serializer_for_role_request;
1286
1287 let uri_str = format!(
1288 "{}/rbac/roles/{uuid}/remove_user/",
1289 configuration.base_path,
1290 uuid = crate::apis::urlencode(p_path_uuid)
1291 );
1292 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1293
1294 if let Some(ref user_agent) = configuration.user_agent {
1295 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1296 }
1297 if let Some(ref token) = configuration.bearer_access_token {
1298 req_builder = req_builder.bearer_auth(token.to_owned());
1299 };
1300 req_builder = req_builder.json(&p_body_user_account_serializer_for_role_request);
1301
1302 let req = req_builder.build()?;
1303 let resp = configuration.client.execute(req).await?;
1304
1305 let status = resp.status();
1306
1307 if !status.is_client_error() && !status.is_server_error() {
1308 Ok(())
1309 } else {
1310 let content = resp.text().await?;
1311 let entity: Option<RbacRolesRemoveUserCreateError> = serde_json::from_str(&content).ok();
1312 Err(Error::ResponseError(ResponseContent {
1313 status,
1314 content,
1315 entity,
1316 }))
1317 }
1318}
1319
1320pub async fn rbac_roles_retrieve(
1322 configuration: &configuration::Configuration,
1323 uuid: &str,
1324) -> Result<models::Role, Error<RbacRolesRetrieveError>> {
1325 let p_path_uuid = uuid;
1327
1328 let uri_str = format!(
1329 "{}/rbac/roles/{uuid}/",
1330 configuration.base_path,
1331 uuid = crate::apis::urlencode(p_path_uuid)
1332 );
1333 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1334
1335 if let Some(ref user_agent) = configuration.user_agent {
1336 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1337 }
1338 if let Some(ref token) = configuration.bearer_access_token {
1339 req_builder = req_builder.bearer_auth(token.to_owned());
1340 };
1341
1342 let req = req_builder.build()?;
1343 let resp = configuration.client.execute(req).await?;
1344
1345 let status = resp.status();
1346 let content_type = resp
1347 .headers()
1348 .get("content-type")
1349 .and_then(|v| v.to_str().ok())
1350 .unwrap_or("application/octet-stream");
1351 let content_type = super::ContentType::from(content_type);
1352
1353 if !status.is_client_error() && !status.is_server_error() {
1354 let content = resp.text().await?;
1355 match content_type {
1356 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1357 ContentType::Text => {
1358 return Err(Error::from(serde_json::Error::custom(
1359 "Received `text/plain` content type response that cannot be converted to `models::Role`",
1360 )))
1361 }
1362 ContentType::Unsupported(unknown_type) => {
1363 return Err(Error::from(serde_json::Error::custom(format!(
1364 "Received `{unknown_type}` content type response that cannot be converted to `models::Role`"
1365 ))))
1366 }
1367 }
1368 } else {
1369 let content = resp.text().await?;
1370 let entity: Option<RbacRolesRetrieveError> = serde_json::from_str(&content).ok();
1371 Err(Error::ResponseError(ResponseContent {
1372 status,
1373 content,
1374 entity,
1375 }))
1376 }
1377}
1378
1379pub async fn rbac_roles_update(
1381 configuration: &configuration::Configuration,
1382 uuid: &str,
1383 role_request: models::RoleRequest,
1384) -> Result<models::Role, Error<RbacRolesUpdateError>> {
1385 let p_path_uuid = uuid;
1387 let p_body_role_request = role_request;
1388
1389 let uri_str = format!(
1390 "{}/rbac/roles/{uuid}/",
1391 configuration.base_path,
1392 uuid = crate::apis::urlencode(p_path_uuid)
1393 );
1394 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
1395
1396 if let Some(ref user_agent) = configuration.user_agent {
1397 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1398 }
1399 if let Some(ref token) = configuration.bearer_access_token {
1400 req_builder = req_builder.bearer_auth(token.to_owned());
1401 };
1402 req_builder = req_builder.json(&p_body_role_request);
1403
1404 let req = req_builder.build()?;
1405 let resp = configuration.client.execute(req).await?;
1406
1407 let status = resp.status();
1408 let content_type = resp
1409 .headers()
1410 .get("content-type")
1411 .and_then(|v| v.to_str().ok())
1412 .unwrap_or("application/octet-stream");
1413 let content_type = super::ContentType::from(content_type);
1414
1415 if !status.is_client_error() && !status.is_server_error() {
1416 let content = resp.text().await?;
1417 match content_type {
1418 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1419 ContentType::Text => {
1420 return Err(Error::from(serde_json::Error::custom(
1421 "Received `text/plain` content type response that cannot be converted to `models::Role`",
1422 )))
1423 }
1424 ContentType::Unsupported(unknown_type) => {
1425 return Err(Error::from(serde_json::Error::custom(format!(
1426 "Received `{unknown_type}` content type response that cannot be converted to `models::Role`"
1427 ))))
1428 }
1429 }
1430 } else {
1431 let content = resp.text().await?;
1432 let entity: Option<RbacRolesUpdateError> = serde_json::from_str(&content).ok();
1433 Err(Error::ResponseError(ResponseContent {
1434 status,
1435 content,
1436 entity,
1437 }))
1438 }
1439}
1440
1441pub async fn rbac_roles_used_by_list(
1443 configuration: &configuration::Configuration,
1444 uuid: &str,
1445) -> Result<Vec<models::UsedBy>, Error<RbacRolesUsedByListError>> {
1446 let p_path_uuid = uuid;
1448
1449 let uri_str = format!(
1450 "{}/rbac/roles/{uuid}/used_by/",
1451 configuration.base_path,
1452 uuid = crate::apis::urlencode(p_path_uuid)
1453 );
1454 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1455
1456 if let Some(ref user_agent) = configuration.user_agent {
1457 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1458 }
1459 if let Some(ref token) = configuration.bearer_access_token {
1460 req_builder = req_builder.bearer_auth(token.to_owned());
1461 };
1462
1463 let req = req_builder.build()?;
1464 let resp = configuration.client.execute(req).await?;
1465
1466 let status = resp.status();
1467 let content_type = resp
1468 .headers()
1469 .get("content-type")
1470 .and_then(|v| v.to_str().ok())
1471 .unwrap_or("application/octet-stream");
1472 let content_type = super::ContentType::from(content_type);
1473
1474 if !status.is_client_error() && !status.is_server_error() {
1475 let content = resp.text().await?;
1476 match content_type {
1477 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1478 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::UsedBy>`"))),
1479 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>`")))),
1480 }
1481 } else {
1482 let content = resp.text().await?;
1483 let entity: Option<RbacRolesUsedByListError> = serde_json::from_str(&content).ok();
1484 Err(Error::ResponseError(ResponseContent {
1485 status,
1486 content,
1487 entity,
1488 }))
1489 }
1490}