github.com/treeverse/lakefs@v1.24.1-0.20240520134607-95648127bfb0/clients/rust/src/apis/auth_api.rs (about) 1 /* 2 * lakeFS API 3 * 4 * lakeFS HTTP API 5 * 6 * The version of the OpenAPI document: 1.0.0 7 * Contact: services@treeverse.io 8 * Generated by: https://openapi-generator.tech 9 */ 10 11 12 use reqwest; 13 14 use crate::{apis::ResponseContent, models}; 15 use super::{Error, configuration}; 16 17 18 /// struct for typed errors of method [`add_group_membership`] 19 #[derive(Debug, Clone, Serialize, Deserialize)] 20 #[serde(untagged)] 21 pub enum AddGroupMembershipError { 22 Status401(models::Error), 23 Status404(models::Error), 24 Status420(), 25 DefaultResponse(models::Error), 26 UnknownValue(serde_json::Value), 27 } 28 29 /// struct for typed errors of method [`attach_policy_to_group`] 30 #[derive(Debug, Clone, Serialize, Deserialize)] 31 #[serde(untagged)] 32 pub enum AttachPolicyToGroupError { 33 Status401(models::Error), 34 Status404(models::Error), 35 Status420(), 36 DefaultResponse(models::Error), 37 UnknownValue(serde_json::Value), 38 } 39 40 /// struct for typed errors of method [`attach_policy_to_user`] 41 #[derive(Debug, Clone, Serialize, Deserialize)] 42 #[serde(untagged)] 43 pub enum AttachPolicyToUserError { 44 Status401(models::Error), 45 Status404(models::Error), 46 Status420(), 47 DefaultResponse(models::Error), 48 UnknownValue(serde_json::Value), 49 } 50 51 /// struct for typed errors of method [`create_credentials`] 52 #[derive(Debug, Clone, Serialize, Deserialize)] 53 #[serde(untagged)] 54 pub enum CreateCredentialsError { 55 Status401(models::Error), 56 Status404(models::Error), 57 Status420(), 58 DefaultResponse(models::Error), 59 UnknownValue(serde_json::Value), 60 } 61 62 /// struct for typed errors of method [`create_group`] 63 #[derive(Debug, Clone, Serialize, Deserialize)] 64 #[serde(untagged)] 65 pub enum CreateGroupError { 66 Status401(models::Error), 67 Status404(models::Error), 68 Status420(), 69 DefaultResponse(models::Error), 70 UnknownValue(serde_json::Value), 71 } 72 73 /// struct for typed errors of method [`create_policy`] 74 #[derive(Debug, Clone, Serialize, Deserialize)] 75 #[serde(untagged)] 76 pub enum CreatePolicyError { 77 Status400(models::Error), 78 Status401(models::Error), 79 Status409(models::Error), 80 Status420(), 81 DefaultResponse(models::Error), 82 UnknownValue(serde_json::Value), 83 } 84 85 /// struct for typed errors of method [`create_user`] 86 #[derive(Debug, Clone, Serialize, Deserialize)] 87 #[serde(untagged)] 88 pub enum CreateUserError { 89 Status400(models::Error), 90 Status401(models::Error), 91 Status409(models::Error), 92 Status420(), 93 DefaultResponse(models::Error), 94 UnknownValue(serde_json::Value), 95 } 96 97 /// struct for typed errors of method [`create_user_external_principal`] 98 #[derive(Debug, Clone, Serialize, Deserialize)] 99 #[serde(untagged)] 100 pub enum CreateUserExternalPrincipalError { 101 Status401(models::Error), 102 Status404(models::Error), 103 Status409(models::Error), 104 Status420(), 105 DefaultResponse(models::Error), 106 UnknownValue(serde_json::Value), 107 } 108 109 /// struct for typed errors of method [`delete_credentials`] 110 #[derive(Debug, Clone, Serialize, Deserialize)] 111 #[serde(untagged)] 112 pub enum DeleteCredentialsError { 113 Status401(models::Error), 114 Status404(models::Error), 115 Status420(), 116 DefaultResponse(models::Error), 117 UnknownValue(serde_json::Value), 118 } 119 120 /// struct for typed errors of method [`delete_group`] 121 #[derive(Debug, Clone, Serialize, Deserialize)] 122 #[serde(untagged)] 123 pub enum DeleteGroupError { 124 Status401(models::Error), 125 Status404(models::Error), 126 Status420(), 127 DefaultResponse(models::Error), 128 UnknownValue(serde_json::Value), 129 } 130 131 /// struct for typed errors of method [`delete_group_membership`] 132 #[derive(Debug, Clone, Serialize, Deserialize)] 133 #[serde(untagged)] 134 pub enum DeleteGroupMembershipError { 135 Status401(models::Error), 136 Status404(models::Error), 137 Status420(), 138 DefaultResponse(models::Error), 139 UnknownValue(serde_json::Value), 140 } 141 142 /// struct for typed errors of method [`delete_policy`] 143 #[derive(Debug, Clone, Serialize, Deserialize)] 144 #[serde(untagged)] 145 pub enum DeletePolicyError { 146 Status401(models::Error), 147 Status404(models::Error), 148 Status420(), 149 DefaultResponse(models::Error), 150 UnknownValue(serde_json::Value), 151 } 152 153 /// struct for typed errors of method [`delete_user`] 154 #[derive(Debug, Clone, Serialize, Deserialize)] 155 #[serde(untagged)] 156 pub enum DeleteUserError { 157 Status401(models::Error), 158 Status404(models::Error), 159 Status420(), 160 DefaultResponse(models::Error), 161 UnknownValue(serde_json::Value), 162 } 163 164 /// struct for typed errors of method [`delete_user_external_principal`] 165 #[derive(Debug, Clone, Serialize, Deserialize)] 166 #[serde(untagged)] 167 pub enum DeleteUserExternalPrincipalError { 168 Status401(models::Error), 169 Status404(models::Error), 170 Status420(), 171 DefaultResponse(models::Error), 172 UnknownValue(serde_json::Value), 173 } 174 175 /// struct for typed errors of method [`detach_policy_from_group`] 176 #[derive(Debug, Clone, Serialize, Deserialize)] 177 #[serde(untagged)] 178 pub enum DetachPolicyFromGroupError { 179 Status401(models::Error), 180 Status404(models::Error), 181 Status420(), 182 DefaultResponse(models::Error), 183 UnknownValue(serde_json::Value), 184 } 185 186 /// struct for typed errors of method [`detach_policy_from_user`] 187 #[derive(Debug, Clone, Serialize, Deserialize)] 188 #[serde(untagged)] 189 pub enum DetachPolicyFromUserError { 190 Status401(models::Error), 191 Status404(models::Error), 192 Status420(), 193 DefaultResponse(models::Error), 194 UnknownValue(serde_json::Value), 195 } 196 197 /// struct for typed errors of method [`external_principal_login`] 198 #[derive(Debug, Clone, Serialize, Deserialize)] 199 #[serde(untagged)] 200 pub enum ExternalPrincipalLoginError { 201 Status400(models::Error), 202 Status401(models::Error), 203 Status403(models::Error), 204 Status404(models::Error), 205 Status420(), 206 DefaultResponse(models::Error), 207 UnknownValue(serde_json::Value), 208 } 209 210 /// struct for typed errors of method [`get_credentials`] 211 #[derive(Debug, Clone, Serialize, Deserialize)] 212 #[serde(untagged)] 213 pub enum GetCredentialsError { 214 Status401(models::Error), 215 Status404(models::Error), 216 Status420(), 217 DefaultResponse(models::Error), 218 UnknownValue(serde_json::Value), 219 } 220 221 /// struct for typed errors of method [`get_current_user`] 222 #[derive(Debug, Clone, Serialize, Deserialize)] 223 #[serde(untagged)] 224 pub enum GetCurrentUserError { 225 UnknownValue(serde_json::Value), 226 } 227 228 /// struct for typed errors of method [`get_external_principal`] 229 #[derive(Debug, Clone, Serialize, Deserialize)] 230 #[serde(untagged)] 231 pub enum GetExternalPrincipalError { 232 Status401(models::Error), 233 Status404(models::Error), 234 Status420(), 235 DefaultResponse(models::Error), 236 UnknownValue(serde_json::Value), 237 } 238 239 /// struct for typed errors of method [`get_group`] 240 #[derive(Debug, Clone, Serialize, Deserialize)] 241 #[serde(untagged)] 242 pub enum GetGroupError { 243 Status401(models::Error), 244 Status404(models::Error), 245 Status420(), 246 DefaultResponse(models::Error), 247 UnknownValue(serde_json::Value), 248 } 249 250 /// struct for typed errors of method [`get_group_acl`] 251 #[derive(Debug, Clone, Serialize, Deserialize)] 252 #[serde(untagged)] 253 pub enum GetGroupAclError { 254 Status401(models::Error), 255 Status404(models::ErrorNoAcl), 256 Status420(), 257 DefaultResponse(models::Error), 258 UnknownValue(serde_json::Value), 259 } 260 261 /// struct for typed errors of method [`get_policy`] 262 #[derive(Debug, Clone, Serialize, Deserialize)] 263 #[serde(untagged)] 264 pub enum GetPolicyError { 265 Status401(models::Error), 266 Status404(models::Error), 267 Status420(), 268 DefaultResponse(models::Error), 269 UnknownValue(serde_json::Value), 270 } 271 272 /// struct for typed errors of method [`get_user`] 273 #[derive(Debug, Clone, Serialize, Deserialize)] 274 #[serde(untagged)] 275 pub enum GetUserError { 276 Status401(models::Error), 277 Status404(models::Error), 278 Status420(), 279 DefaultResponse(models::Error), 280 UnknownValue(serde_json::Value), 281 } 282 283 /// struct for typed errors of method [`list_group_members`] 284 #[derive(Debug, Clone, Serialize, Deserialize)] 285 #[serde(untagged)] 286 pub enum ListGroupMembersError { 287 Status401(models::Error), 288 Status420(), 289 DefaultResponse(models::Error), 290 UnknownValue(serde_json::Value), 291 } 292 293 /// struct for typed errors of method [`list_group_policies`] 294 #[derive(Debug, Clone, Serialize, Deserialize)] 295 #[serde(untagged)] 296 pub enum ListGroupPoliciesError { 297 Status401(models::Error), 298 Status404(models::Error), 299 Status420(), 300 DefaultResponse(models::Error), 301 UnknownValue(serde_json::Value), 302 } 303 304 /// struct for typed errors of method [`list_groups`] 305 #[derive(Debug, Clone, Serialize, Deserialize)] 306 #[serde(untagged)] 307 pub enum ListGroupsError { 308 Status401(models::Error), 309 Status420(), 310 DefaultResponse(models::Error), 311 UnknownValue(serde_json::Value), 312 } 313 314 /// struct for typed errors of method [`list_policies`] 315 #[derive(Debug, Clone, Serialize, Deserialize)] 316 #[serde(untagged)] 317 pub enum ListPoliciesError { 318 Status401(models::Error), 319 Status420(), 320 DefaultResponse(models::Error), 321 UnknownValue(serde_json::Value), 322 } 323 324 /// struct for typed errors of method [`list_user_credentials`] 325 #[derive(Debug, Clone, Serialize, Deserialize)] 326 #[serde(untagged)] 327 pub enum ListUserCredentialsError { 328 Status401(models::Error), 329 Status404(models::Error), 330 Status420(), 331 DefaultResponse(models::Error), 332 UnknownValue(serde_json::Value), 333 } 334 335 /// struct for typed errors of method [`list_user_external_principals`] 336 #[derive(Debug, Clone, Serialize, Deserialize)] 337 #[serde(untagged)] 338 pub enum ListUserExternalPrincipalsError { 339 Status401(models::Error), 340 Status404(models::Error), 341 Status420(), 342 DefaultResponse(models::Error), 343 UnknownValue(serde_json::Value), 344 } 345 346 /// struct for typed errors of method [`list_user_groups`] 347 #[derive(Debug, Clone, Serialize, Deserialize)] 348 #[serde(untagged)] 349 pub enum ListUserGroupsError { 350 Status401(models::Error), 351 Status404(models::Error), 352 Status420(), 353 DefaultResponse(models::Error), 354 UnknownValue(serde_json::Value), 355 } 356 357 /// struct for typed errors of method [`list_user_policies`] 358 #[derive(Debug, Clone, Serialize, Deserialize)] 359 #[serde(untagged)] 360 pub enum ListUserPoliciesError { 361 Status401(models::Error), 362 Status404(models::Error), 363 Status420(), 364 DefaultResponse(models::Error), 365 UnknownValue(serde_json::Value), 366 } 367 368 /// struct for typed errors of method [`list_users`] 369 #[derive(Debug, Clone, Serialize, Deserialize)] 370 #[serde(untagged)] 371 pub enum ListUsersError { 372 Status401(models::Error), 373 Status420(), 374 DefaultResponse(models::Error), 375 UnknownValue(serde_json::Value), 376 } 377 378 /// struct for typed errors of method [`login`] 379 #[derive(Debug, Clone, Serialize, Deserialize)] 380 #[serde(untagged)] 381 pub enum LoginError { 382 Status401(models::Error), 383 Status420(), 384 DefaultResponse(models::Error), 385 UnknownValue(serde_json::Value), 386 } 387 388 /// struct for typed errors of method [`set_group_acl`] 389 #[derive(Debug, Clone, Serialize, Deserialize)] 390 #[serde(untagged)] 391 pub enum SetGroupAclError { 392 Status401(models::Error), 393 Status404(models::Error), 394 Status420(), 395 DefaultResponse(models::Error), 396 UnknownValue(serde_json::Value), 397 } 398 399 /// struct for typed errors of method [`update_policy`] 400 #[derive(Debug, Clone, Serialize, Deserialize)] 401 #[serde(untagged)] 402 pub enum UpdatePolicyError { 403 Status400(models::Error), 404 Status401(models::Error), 405 Status404(models::Error), 406 Status420(), 407 DefaultResponse(models::Error), 408 UnknownValue(serde_json::Value), 409 } 410 411 412 pub async fn add_group_membership(configuration: &configuration::Configuration, group_id: &str, user_id: &str) -> Result<(), Error<AddGroupMembershipError>> { 413 let local_var_configuration = configuration; 414 415 let local_var_client = &local_var_configuration.client; 416 417 let local_var_uri_str = format!("{}/auth/groups/{groupId}/members/{userId}", local_var_configuration.base_path, groupId=crate::apis::urlencode(group_id), userId=crate::apis::urlencode(user_id)); 418 let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); 419 420 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { 421 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); 422 } 423 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { 424 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned()); 425 }; 426 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token { 427 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); 428 }; 429 430 let local_var_req = local_var_req_builder.build()?; 431 let local_var_resp = local_var_client.execute(local_var_req).await?; 432 433 let local_var_status = local_var_resp.status(); 434 let local_var_content = local_var_resp.text().await?; 435 436 if !local_var_status.is_client_error() && !local_var_status.is_server_error() { 437 Ok(()) 438 } else { 439 let local_var_entity: Option<AddGroupMembershipError> = serde_json::from_str(&local_var_content).ok(); 440 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; 441 Err(Error::ResponseError(local_var_error)) 442 } 443 } 444 445 pub async fn attach_policy_to_group(configuration: &configuration::Configuration, group_id: &str, policy_id: &str) -> Result<(), Error<AttachPolicyToGroupError>> { 446 let local_var_configuration = configuration; 447 448 let local_var_client = &local_var_configuration.client; 449 450 let local_var_uri_str = format!("{}/auth/groups/{groupId}/policies/{policyId}", local_var_configuration.base_path, groupId=crate::apis::urlencode(group_id), policyId=crate::apis::urlencode(policy_id)); 451 let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); 452 453 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { 454 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); 455 } 456 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { 457 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned()); 458 }; 459 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token { 460 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); 461 }; 462 463 let local_var_req = local_var_req_builder.build()?; 464 let local_var_resp = local_var_client.execute(local_var_req).await?; 465 466 let local_var_status = local_var_resp.status(); 467 let local_var_content = local_var_resp.text().await?; 468 469 if !local_var_status.is_client_error() && !local_var_status.is_server_error() { 470 Ok(()) 471 } else { 472 let local_var_entity: Option<AttachPolicyToGroupError> = serde_json::from_str(&local_var_content).ok(); 473 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; 474 Err(Error::ResponseError(local_var_error)) 475 } 476 } 477 478 pub async fn attach_policy_to_user(configuration: &configuration::Configuration, user_id: &str, policy_id: &str) -> Result<(), Error<AttachPolicyToUserError>> { 479 let local_var_configuration = configuration; 480 481 let local_var_client = &local_var_configuration.client; 482 483 let local_var_uri_str = format!("{}/auth/users/{userId}/policies/{policyId}", local_var_configuration.base_path, userId=crate::apis::urlencode(user_id), policyId=crate::apis::urlencode(policy_id)); 484 let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); 485 486 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { 487 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); 488 } 489 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { 490 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned()); 491 }; 492 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token { 493 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); 494 }; 495 496 let local_var_req = local_var_req_builder.build()?; 497 let local_var_resp = local_var_client.execute(local_var_req).await?; 498 499 let local_var_status = local_var_resp.status(); 500 let local_var_content = local_var_resp.text().await?; 501 502 if !local_var_status.is_client_error() && !local_var_status.is_server_error() { 503 Ok(()) 504 } else { 505 let local_var_entity: Option<AttachPolicyToUserError> = serde_json::from_str(&local_var_content).ok(); 506 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; 507 Err(Error::ResponseError(local_var_error)) 508 } 509 } 510 511 pub async fn create_credentials(configuration: &configuration::Configuration, user_id: &str) -> Result<models::CredentialsWithSecret, Error<CreateCredentialsError>> { 512 let local_var_configuration = configuration; 513 514 let local_var_client = &local_var_configuration.client; 515 516 let local_var_uri_str = format!("{}/auth/users/{userId}/credentials", local_var_configuration.base_path, userId=crate::apis::urlencode(user_id)); 517 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); 518 519 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { 520 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); 521 } 522 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { 523 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned()); 524 }; 525 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token { 526 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); 527 }; 528 529 let local_var_req = local_var_req_builder.build()?; 530 let local_var_resp = local_var_client.execute(local_var_req).await?; 531 532 let local_var_status = local_var_resp.status(); 533 let local_var_content = local_var_resp.text().await?; 534 535 if !local_var_status.is_client_error() && !local_var_status.is_server_error() { 536 serde_json::from_str(&local_var_content).map_err(Error::from) 537 } else { 538 let local_var_entity: Option<CreateCredentialsError> = serde_json::from_str(&local_var_content).ok(); 539 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; 540 Err(Error::ResponseError(local_var_error)) 541 } 542 } 543 544 pub async fn create_group(configuration: &configuration::Configuration, group_creation: Option<models::GroupCreation>) -> Result<models::Group, Error<CreateGroupError>> { 545 let local_var_configuration = configuration; 546 547 let local_var_client = &local_var_configuration.client; 548 549 let local_var_uri_str = format!("{}/auth/groups", local_var_configuration.base_path); 550 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); 551 552 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { 553 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); 554 } 555 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { 556 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned()); 557 }; 558 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token { 559 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); 560 }; 561 local_var_req_builder = local_var_req_builder.json(&group_creation); 562 563 let local_var_req = local_var_req_builder.build()?; 564 let local_var_resp = local_var_client.execute(local_var_req).await?; 565 566 let local_var_status = local_var_resp.status(); 567 let local_var_content = local_var_resp.text().await?; 568 569 if !local_var_status.is_client_error() && !local_var_status.is_server_error() { 570 serde_json::from_str(&local_var_content).map_err(Error::from) 571 } else { 572 let local_var_entity: Option<CreateGroupError> = serde_json::from_str(&local_var_content).ok(); 573 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; 574 Err(Error::ResponseError(local_var_error)) 575 } 576 } 577 578 pub async fn create_policy(configuration: &configuration::Configuration, policy: models::Policy) -> Result<models::Policy, Error<CreatePolicyError>> { 579 let local_var_configuration = configuration; 580 581 let local_var_client = &local_var_configuration.client; 582 583 let local_var_uri_str = format!("{}/auth/policies", local_var_configuration.base_path); 584 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); 585 586 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { 587 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); 588 } 589 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { 590 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned()); 591 }; 592 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token { 593 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); 594 }; 595 local_var_req_builder = local_var_req_builder.json(&policy); 596 597 let local_var_req = local_var_req_builder.build()?; 598 let local_var_resp = local_var_client.execute(local_var_req).await?; 599 600 let local_var_status = local_var_resp.status(); 601 let local_var_content = local_var_resp.text().await?; 602 603 if !local_var_status.is_client_error() && !local_var_status.is_server_error() { 604 serde_json::from_str(&local_var_content).map_err(Error::from) 605 } else { 606 let local_var_entity: Option<CreatePolicyError> = serde_json::from_str(&local_var_content).ok(); 607 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; 608 Err(Error::ResponseError(local_var_error)) 609 } 610 } 611 612 pub async fn create_user(configuration: &configuration::Configuration, user_creation: Option<models::UserCreation>) -> Result<models::User, Error<CreateUserError>> { 613 let local_var_configuration = configuration; 614 615 let local_var_client = &local_var_configuration.client; 616 617 let local_var_uri_str = format!("{}/auth/users", local_var_configuration.base_path); 618 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); 619 620 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { 621 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); 622 } 623 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { 624 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned()); 625 }; 626 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token { 627 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); 628 }; 629 local_var_req_builder = local_var_req_builder.json(&user_creation); 630 631 let local_var_req = local_var_req_builder.build()?; 632 let local_var_resp = local_var_client.execute(local_var_req).await?; 633 634 let local_var_status = local_var_resp.status(); 635 let local_var_content = local_var_resp.text().await?; 636 637 if !local_var_status.is_client_error() && !local_var_status.is_server_error() { 638 serde_json::from_str(&local_var_content).map_err(Error::from) 639 } else { 640 let local_var_entity: Option<CreateUserError> = serde_json::from_str(&local_var_content).ok(); 641 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; 642 Err(Error::ResponseError(local_var_error)) 643 } 644 } 645 646 pub async fn create_user_external_principal(configuration: &configuration::Configuration, user_id: &str, principal_id: &str, external_principal_creation: Option<models::ExternalPrincipalCreation>) -> Result<(), Error<CreateUserExternalPrincipalError>> { 647 let local_var_configuration = configuration; 648 649 let local_var_client = &local_var_configuration.client; 650 651 let local_var_uri_str = format!("{}/auth/users/{userId}/external/principals", local_var_configuration.base_path, userId=crate::apis::urlencode(user_id)); 652 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); 653 654 local_var_req_builder = local_var_req_builder.query(&[("principalId", &principal_id.to_string())]); 655 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { 656 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); 657 } 658 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { 659 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned()); 660 }; 661 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token { 662 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); 663 }; 664 local_var_req_builder = local_var_req_builder.json(&external_principal_creation); 665 666 let local_var_req = local_var_req_builder.build()?; 667 let local_var_resp = local_var_client.execute(local_var_req).await?; 668 669 let local_var_status = local_var_resp.status(); 670 let local_var_content = local_var_resp.text().await?; 671 672 if !local_var_status.is_client_error() && !local_var_status.is_server_error() { 673 Ok(()) 674 } else { 675 let local_var_entity: Option<CreateUserExternalPrincipalError> = serde_json::from_str(&local_var_content).ok(); 676 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; 677 Err(Error::ResponseError(local_var_error)) 678 } 679 } 680 681 pub async fn delete_credentials(configuration: &configuration::Configuration, user_id: &str, access_key_id: &str) -> Result<(), Error<DeleteCredentialsError>> { 682 let local_var_configuration = configuration; 683 684 let local_var_client = &local_var_configuration.client; 685 686 let local_var_uri_str = format!("{}/auth/users/{userId}/credentials/{accessKeyId}", local_var_configuration.base_path, userId=crate::apis::urlencode(user_id), accessKeyId=crate::apis::urlencode(access_key_id)); 687 let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); 688 689 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { 690 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); 691 } 692 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { 693 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned()); 694 }; 695 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token { 696 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); 697 }; 698 699 let local_var_req = local_var_req_builder.build()?; 700 let local_var_resp = local_var_client.execute(local_var_req).await?; 701 702 let local_var_status = local_var_resp.status(); 703 let local_var_content = local_var_resp.text().await?; 704 705 if !local_var_status.is_client_error() && !local_var_status.is_server_error() { 706 Ok(()) 707 } else { 708 let local_var_entity: Option<DeleteCredentialsError> = serde_json::from_str(&local_var_content).ok(); 709 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; 710 Err(Error::ResponseError(local_var_error)) 711 } 712 } 713 714 pub async fn delete_group(configuration: &configuration::Configuration, group_id: &str) -> Result<(), Error<DeleteGroupError>> { 715 let local_var_configuration = configuration; 716 717 let local_var_client = &local_var_configuration.client; 718 719 let local_var_uri_str = format!("{}/auth/groups/{groupId}", local_var_configuration.base_path, groupId=crate::apis::urlencode(group_id)); 720 let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); 721 722 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { 723 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); 724 } 725 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { 726 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned()); 727 }; 728 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token { 729 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); 730 }; 731 732 let local_var_req = local_var_req_builder.build()?; 733 let local_var_resp = local_var_client.execute(local_var_req).await?; 734 735 let local_var_status = local_var_resp.status(); 736 let local_var_content = local_var_resp.text().await?; 737 738 if !local_var_status.is_client_error() && !local_var_status.is_server_error() { 739 Ok(()) 740 } else { 741 let local_var_entity: Option<DeleteGroupError> = serde_json::from_str(&local_var_content).ok(); 742 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; 743 Err(Error::ResponseError(local_var_error)) 744 } 745 } 746 747 pub async fn delete_group_membership(configuration: &configuration::Configuration, group_id: &str, user_id: &str) -> Result<(), Error<DeleteGroupMembershipError>> { 748 let local_var_configuration = configuration; 749 750 let local_var_client = &local_var_configuration.client; 751 752 let local_var_uri_str = format!("{}/auth/groups/{groupId}/members/{userId}", local_var_configuration.base_path, groupId=crate::apis::urlencode(group_id), userId=crate::apis::urlencode(user_id)); 753 let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); 754 755 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { 756 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); 757 } 758 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { 759 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned()); 760 }; 761 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token { 762 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); 763 }; 764 765 let local_var_req = local_var_req_builder.build()?; 766 let local_var_resp = local_var_client.execute(local_var_req).await?; 767 768 let local_var_status = local_var_resp.status(); 769 let local_var_content = local_var_resp.text().await?; 770 771 if !local_var_status.is_client_error() && !local_var_status.is_server_error() { 772 Ok(()) 773 } else { 774 let local_var_entity: Option<DeleteGroupMembershipError> = serde_json::from_str(&local_var_content).ok(); 775 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; 776 Err(Error::ResponseError(local_var_error)) 777 } 778 } 779 780 pub async fn delete_policy(configuration: &configuration::Configuration, policy_id: &str) -> Result<(), Error<DeletePolicyError>> { 781 let local_var_configuration = configuration; 782 783 let local_var_client = &local_var_configuration.client; 784 785 let local_var_uri_str = format!("{}/auth/policies/{policyId}", local_var_configuration.base_path, policyId=crate::apis::urlencode(policy_id)); 786 let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); 787 788 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { 789 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); 790 } 791 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { 792 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned()); 793 }; 794 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token { 795 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); 796 }; 797 798 let local_var_req = local_var_req_builder.build()?; 799 let local_var_resp = local_var_client.execute(local_var_req).await?; 800 801 let local_var_status = local_var_resp.status(); 802 let local_var_content = local_var_resp.text().await?; 803 804 if !local_var_status.is_client_error() && !local_var_status.is_server_error() { 805 Ok(()) 806 } else { 807 let local_var_entity: Option<DeletePolicyError> = serde_json::from_str(&local_var_content).ok(); 808 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; 809 Err(Error::ResponseError(local_var_error)) 810 } 811 } 812 813 pub async fn delete_user(configuration: &configuration::Configuration, user_id: &str) -> Result<(), Error<DeleteUserError>> { 814 let local_var_configuration = configuration; 815 816 let local_var_client = &local_var_configuration.client; 817 818 let local_var_uri_str = format!("{}/auth/users/{userId}", local_var_configuration.base_path, userId=crate::apis::urlencode(user_id)); 819 let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); 820 821 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { 822 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); 823 } 824 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { 825 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned()); 826 }; 827 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token { 828 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); 829 }; 830 831 let local_var_req = local_var_req_builder.build()?; 832 let local_var_resp = local_var_client.execute(local_var_req).await?; 833 834 let local_var_status = local_var_resp.status(); 835 let local_var_content = local_var_resp.text().await?; 836 837 if !local_var_status.is_client_error() && !local_var_status.is_server_error() { 838 Ok(()) 839 } else { 840 let local_var_entity: Option<DeleteUserError> = serde_json::from_str(&local_var_content).ok(); 841 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; 842 Err(Error::ResponseError(local_var_error)) 843 } 844 } 845 846 pub async fn delete_user_external_principal(configuration: &configuration::Configuration, user_id: &str, principal_id: &str) -> Result<(), Error<DeleteUserExternalPrincipalError>> { 847 let local_var_configuration = configuration; 848 849 let local_var_client = &local_var_configuration.client; 850 851 let local_var_uri_str = format!("{}/auth/users/{userId}/external/principals", local_var_configuration.base_path, userId=crate::apis::urlencode(user_id)); 852 let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); 853 854 local_var_req_builder = local_var_req_builder.query(&[("principalId", &principal_id.to_string())]); 855 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { 856 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); 857 } 858 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { 859 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned()); 860 }; 861 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token { 862 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); 863 }; 864 865 let local_var_req = local_var_req_builder.build()?; 866 let local_var_resp = local_var_client.execute(local_var_req).await?; 867 868 let local_var_status = local_var_resp.status(); 869 let local_var_content = local_var_resp.text().await?; 870 871 if !local_var_status.is_client_error() && !local_var_status.is_server_error() { 872 Ok(()) 873 } else { 874 let local_var_entity: Option<DeleteUserExternalPrincipalError> = serde_json::from_str(&local_var_content).ok(); 875 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; 876 Err(Error::ResponseError(local_var_error)) 877 } 878 } 879 880 pub async fn detach_policy_from_group(configuration: &configuration::Configuration, group_id: &str, policy_id: &str) -> Result<(), Error<DetachPolicyFromGroupError>> { 881 let local_var_configuration = configuration; 882 883 let local_var_client = &local_var_configuration.client; 884 885 let local_var_uri_str = format!("{}/auth/groups/{groupId}/policies/{policyId}", local_var_configuration.base_path, groupId=crate::apis::urlencode(group_id), policyId=crate::apis::urlencode(policy_id)); 886 let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); 887 888 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { 889 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); 890 } 891 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { 892 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned()); 893 }; 894 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token { 895 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); 896 }; 897 898 let local_var_req = local_var_req_builder.build()?; 899 let local_var_resp = local_var_client.execute(local_var_req).await?; 900 901 let local_var_status = local_var_resp.status(); 902 let local_var_content = local_var_resp.text().await?; 903 904 if !local_var_status.is_client_error() && !local_var_status.is_server_error() { 905 Ok(()) 906 } else { 907 let local_var_entity: Option<DetachPolicyFromGroupError> = serde_json::from_str(&local_var_content).ok(); 908 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; 909 Err(Error::ResponseError(local_var_error)) 910 } 911 } 912 913 pub async fn detach_policy_from_user(configuration: &configuration::Configuration, user_id: &str, policy_id: &str) -> Result<(), Error<DetachPolicyFromUserError>> { 914 let local_var_configuration = configuration; 915 916 let local_var_client = &local_var_configuration.client; 917 918 let local_var_uri_str = format!("{}/auth/users/{userId}/policies/{policyId}", local_var_configuration.base_path, userId=crate::apis::urlencode(user_id), policyId=crate::apis::urlencode(policy_id)); 919 let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); 920 921 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { 922 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); 923 } 924 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { 925 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned()); 926 }; 927 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token { 928 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); 929 }; 930 931 let local_var_req = local_var_req_builder.build()?; 932 let local_var_resp = local_var_client.execute(local_var_req).await?; 933 934 let local_var_status = local_var_resp.status(); 935 let local_var_content = local_var_resp.text().await?; 936 937 if !local_var_status.is_client_error() && !local_var_status.is_server_error() { 938 Ok(()) 939 } else { 940 let local_var_entity: Option<DetachPolicyFromUserError> = serde_json::from_str(&local_var_content).ok(); 941 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; 942 Err(Error::ResponseError(local_var_error)) 943 } 944 } 945 946 pub async fn external_principal_login(configuration: &configuration::Configuration, external_login_information: Option<models::ExternalLoginInformation>) -> Result<models::AuthenticationToken, Error<ExternalPrincipalLoginError>> { 947 let local_var_configuration = configuration; 948 949 let local_var_client = &local_var_configuration.client; 950 951 let local_var_uri_str = format!("{}/auth/external/principal/login", local_var_configuration.base_path); 952 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); 953 954 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { 955 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); 956 } 957 local_var_req_builder = local_var_req_builder.json(&external_login_information); 958 959 let local_var_req = local_var_req_builder.build()?; 960 let local_var_resp = local_var_client.execute(local_var_req).await?; 961 962 let local_var_status = local_var_resp.status(); 963 let local_var_content = local_var_resp.text().await?; 964 965 if !local_var_status.is_client_error() && !local_var_status.is_server_error() { 966 serde_json::from_str(&local_var_content).map_err(Error::from) 967 } else { 968 let local_var_entity: Option<ExternalPrincipalLoginError> = serde_json::from_str(&local_var_content).ok(); 969 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; 970 Err(Error::ResponseError(local_var_error)) 971 } 972 } 973 974 pub async fn get_credentials(configuration: &configuration::Configuration, user_id: &str, access_key_id: &str) -> Result<models::Credentials, Error<GetCredentialsError>> { 975 let local_var_configuration = configuration; 976 977 let local_var_client = &local_var_configuration.client; 978 979 let local_var_uri_str = format!("{}/auth/users/{userId}/credentials/{accessKeyId}", local_var_configuration.base_path, userId=crate::apis::urlencode(user_id), accessKeyId=crate::apis::urlencode(access_key_id)); 980 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); 981 982 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { 983 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); 984 } 985 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { 986 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned()); 987 }; 988 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token { 989 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); 990 }; 991 992 let local_var_req = local_var_req_builder.build()?; 993 let local_var_resp = local_var_client.execute(local_var_req).await?; 994 995 let local_var_status = local_var_resp.status(); 996 let local_var_content = local_var_resp.text().await?; 997 998 if !local_var_status.is_client_error() && !local_var_status.is_server_error() { 999 serde_json::from_str(&local_var_content).map_err(Error::from) 1000 } else { 1001 let local_var_entity: Option<GetCredentialsError> = serde_json::from_str(&local_var_content).ok(); 1002 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; 1003 Err(Error::ResponseError(local_var_error)) 1004 } 1005 } 1006 1007 pub async fn get_current_user(configuration: &configuration::Configuration, ) -> Result<models::CurrentUser, Error<GetCurrentUserError>> { 1008 let local_var_configuration = configuration; 1009 1010 let local_var_client = &local_var_configuration.client; 1011 1012 let local_var_uri_str = format!("{}/user", local_var_configuration.base_path); 1013 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); 1014 1015 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { 1016 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); 1017 } 1018 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { 1019 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned()); 1020 }; 1021 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token { 1022 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); 1023 }; 1024 1025 let local_var_req = local_var_req_builder.build()?; 1026 let local_var_resp = local_var_client.execute(local_var_req).await?; 1027 1028 let local_var_status = local_var_resp.status(); 1029 let local_var_content = local_var_resp.text().await?; 1030 1031 if !local_var_status.is_client_error() && !local_var_status.is_server_error() { 1032 serde_json::from_str(&local_var_content).map_err(Error::from) 1033 } else { 1034 let local_var_entity: Option<GetCurrentUserError> = serde_json::from_str(&local_var_content).ok(); 1035 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; 1036 Err(Error::ResponseError(local_var_error)) 1037 } 1038 } 1039 1040 pub async fn get_external_principal(configuration: &configuration::Configuration, principal_id: &str) -> Result<models::ExternalPrincipal, Error<GetExternalPrincipalError>> { 1041 let local_var_configuration = configuration; 1042 1043 let local_var_client = &local_var_configuration.client; 1044 1045 let local_var_uri_str = format!("{}/auth/external/principals", local_var_configuration.base_path); 1046 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); 1047 1048 local_var_req_builder = local_var_req_builder.query(&[("principalId", &principal_id.to_string())]); 1049 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { 1050 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); 1051 } 1052 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { 1053 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned()); 1054 }; 1055 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token { 1056 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); 1057 }; 1058 1059 let local_var_req = local_var_req_builder.build()?; 1060 let local_var_resp = local_var_client.execute(local_var_req).await?; 1061 1062 let local_var_status = local_var_resp.status(); 1063 let local_var_content = local_var_resp.text().await?; 1064 1065 if !local_var_status.is_client_error() && !local_var_status.is_server_error() { 1066 serde_json::from_str(&local_var_content).map_err(Error::from) 1067 } else { 1068 let local_var_entity: Option<GetExternalPrincipalError> = serde_json::from_str(&local_var_content).ok(); 1069 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; 1070 Err(Error::ResponseError(local_var_error)) 1071 } 1072 } 1073 1074 pub async fn get_group(configuration: &configuration::Configuration, group_id: &str) -> Result<models::Group, Error<GetGroupError>> { 1075 let local_var_configuration = configuration; 1076 1077 let local_var_client = &local_var_configuration.client; 1078 1079 let local_var_uri_str = format!("{}/auth/groups/{groupId}", local_var_configuration.base_path, groupId=crate::apis::urlencode(group_id)); 1080 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); 1081 1082 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { 1083 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); 1084 } 1085 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { 1086 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned()); 1087 }; 1088 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token { 1089 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); 1090 }; 1091 1092 let local_var_req = local_var_req_builder.build()?; 1093 let local_var_resp = local_var_client.execute(local_var_req).await?; 1094 1095 let local_var_status = local_var_resp.status(); 1096 let local_var_content = local_var_resp.text().await?; 1097 1098 if !local_var_status.is_client_error() && !local_var_status.is_server_error() { 1099 serde_json::from_str(&local_var_content).map_err(Error::from) 1100 } else { 1101 let local_var_entity: Option<GetGroupError> = serde_json::from_str(&local_var_content).ok(); 1102 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; 1103 Err(Error::ResponseError(local_var_error)) 1104 } 1105 } 1106 1107 pub async fn get_group_acl(configuration: &configuration::Configuration, group_id: &str) -> Result<models::Acl, Error<GetGroupAclError>> { 1108 let local_var_configuration = configuration; 1109 1110 let local_var_client = &local_var_configuration.client; 1111 1112 let local_var_uri_str = format!("{}/auth/groups/{groupId}/acl", local_var_configuration.base_path, groupId=crate::apis::urlencode(group_id)); 1113 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); 1114 1115 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { 1116 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); 1117 } 1118 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { 1119 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned()); 1120 }; 1121 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token { 1122 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); 1123 }; 1124 1125 let local_var_req = local_var_req_builder.build()?; 1126 let local_var_resp = local_var_client.execute(local_var_req).await?; 1127 1128 let local_var_status = local_var_resp.status(); 1129 let local_var_content = local_var_resp.text().await?; 1130 1131 if !local_var_status.is_client_error() && !local_var_status.is_server_error() { 1132 serde_json::from_str(&local_var_content).map_err(Error::from) 1133 } else { 1134 let local_var_entity: Option<GetGroupAclError> = serde_json::from_str(&local_var_content).ok(); 1135 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; 1136 Err(Error::ResponseError(local_var_error)) 1137 } 1138 } 1139 1140 pub async fn get_policy(configuration: &configuration::Configuration, policy_id: &str) -> Result<models::Policy, Error<GetPolicyError>> { 1141 let local_var_configuration = configuration; 1142 1143 let local_var_client = &local_var_configuration.client; 1144 1145 let local_var_uri_str = format!("{}/auth/policies/{policyId}", local_var_configuration.base_path, policyId=crate::apis::urlencode(policy_id)); 1146 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); 1147 1148 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { 1149 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); 1150 } 1151 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { 1152 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned()); 1153 }; 1154 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token { 1155 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); 1156 }; 1157 1158 let local_var_req = local_var_req_builder.build()?; 1159 let local_var_resp = local_var_client.execute(local_var_req).await?; 1160 1161 let local_var_status = local_var_resp.status(); 1162 let local_var_content = local_var_resp.text().await?; 1163 1164 if !local_var_status.is_client_error() && !local_var_status.is_server_error() { 1165 serde_json::from_str(&local_var_content).map_err(Error::from) 1166 } else { 1167 let local_var_entity: Option<GetPolicyError> = serde_json::from_str(&local_var_content).ok(); 1168 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; 1169 Err(Error::ResponseError(local_var_error)) 1170 } 1171 } 1172 1173 pub async fn get_user(configuration: &configuration::Configuration, user_id: &str) -> Result<models::User, Error<GetUserError>> { 1174 let local_var_configuration = configuration; 1175 1176 let local_var_client = &local_var_configuration.client; 1177 1178 let local_var_uri_str = format!("{}/auth/users/{userId}", local_var_configuration.base_path, userId=crate::apis::urlencode(user_id)); 1179 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); 1180 1181 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { 1182 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); 1183 } 1184 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { 1185 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned()); 1186 }; 1187 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token { 1188 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); 1189 }; 1190 1191 let local_var_req = local_var_req_builder.build()?; 1192 let local_var_resp = local_var_client.execute(local_var_req).await?; 1193 1194 let local_var_status = local_var_resp.status(); 1195 let local_var_content = local_var_resp.text().await?; 1196 1197 if !local_var_status.is_client_error() && !local_var_status.is_server_error() { 1198 serde_json::from_str(&local_var_content).map_err(Error::from) 1199 } else { 1200 let local_var_entity: Option<GetUserError> = serde_json::from_str(&local_var_content).ok(); 1201 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; 1202 Err(Error::ResponseError(local_var_error)) 1203 } 1204 } 1205 1206 pub async fn list_group_members(configuration: &configuration::Configuration, group_id: &str, prefix: Option<&str>, after: Option<&str>, amount: Option<i32>) -> Result<models::UserList, Error<ListGroupMembersError>> { 1207 let local_var_configuration = configuration; 1208 1209 let local_var_client = &local_var_configuration.client; 1210 1211 let local_var_uri_str = format!("{}/auth/groups/{groupId}/members", local_var_configuration.base_path, groupId=crate::apis::urlencode(group_id)); 1212 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); 1213 1214 if let Some(ref local_var_str) = prefix { 1215 local_var_req_builder = local_var_req_builder.query(&[("prefix", &local_var_str.to_string())]); 1216 } 1217 if let Some(ref local_var_str) = after { 1218 local_var_req_builder = local_var_req_builder.query(&[("after", &local_var_str.to_string())]); 1219 } 1220 if let Some(ref local_var_str) = amount { 1221 local_var_req_builder = local_var_req_builder.query(&[("amount", &local_var_str.to_string())]); 1222 } 1223 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { 1224 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); 1225 } 1226 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { 1227 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned()); 1228 }; 1229 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token { 1230 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); 1231 }; 1232 1233 let local_var_req = local_var_req_builder.build()?; 1234 let local_var_resp = local_var_client.execute(local_var_req).await?; 1235 1236 let local_var_status = local_var_resp.status(); 1237 let local_var_content = local_var_resp.text().await?; 1238 1239 if !local_var_status.is_client_error() && !local_var_status.is_server_error() { 1240 serde_json::from_str(&local_var_content).map_err(Error::from) 1241 } else { 1242 let local_var_entity: Option<ListGroupMembersError> = serde_json::from_str(&local_var_content).ok(); 1243 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; 1244 Err(Error::ResponseError(local_var_error)) 1245 } 1246 } 1247 1248 pub async fn list_group_policies(configuration: &configuration::Configuration, group_id: &str, prefix: Option<&str>, after: Option<&str>, amount: Option<i32>) -> Result<models::PolicyList, Error<ListGroupPoliciesError>> { 1249 let local_var_configuration = configuration; 1250 1251 let local_var_client = &local_var_configuration.client; 1252 1253 let local_var_uri_str = format!("{}/auth/groups/{groupId}/policies", local_var_configuration.base_path, groupId=crate::apis::urlencode(group_id)); 1254 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); 1255 1256 if let Some(ref local_var_str) = prefix { 1257 local_var_req_builder = local_var_req_builder.query(&[("prefix", &local_var_str.to_string())]); 1258 } 1259 if let Some(ref local_var_str) = after { 1260 local_var_req_builder = local_var_req_builder.query(&[("after", &local_var_str.to_string())]); 1261 } 1262 if let Some(ref local_var_str) = amount { 1263 local_var_req_builder = local_var_req_builder.query(&[("amount", &local_var_str.to_string())]); 1264 } 1265 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { 1266 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); 1267 } 1268 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { 1269 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned()); 1270 }; 1271 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token { 1272 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); 1273 }; 1274 1275 let local_var_req = local_var_req_builder.build()?; 1276 let local_var_resp = local_var_client.execute(local_var_req).await?; 1277 1278 let local_var_status = local_var_resp.status(); 1279 let local_var_content = local_var_resp.text().await?; 1280 1281 if !local_var_status.is_client_error() && !local_var_status.is_server_error() { 1282 serde_json::from_str(&local_var_content).map_err(Error::from) 1283 } else { 1284 let local_var_entity: Option<ListGroupPoliciesError> = serde_json::from_str(&local_var_content).ok(); 1285 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; 1286 Err(Error::ResponseError(local_var_error)) 1287 } 1288 } 1289 1290 pub async fn list_groups(configuration: &configuration::Configuration, prefix: Option<&str>, after: Option<&str>, amount: Option<i32>) -> Result<models::GroupList, Error<ListGroupsError>> { 1291 let local_var_configuration = configuration; 1292 1293 let local_var_client = &local_var_configuration.client; 1294 1295 let local_var_uri_str = format!("{}/auth/groups", local_var_configuration.base_path); 1296 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); 1297 1298 if let Some(ref local_var_str) = prefix { 1299 local_var_req_builder = local_var_req_builder.query(&[("prefix", &local_var_str.to_string())]); 1300 } 1301 if let Some(ref local_var_str) = after { 1302 local_var_req_builder = local_var_req_builder.query(&[("after", &local_var_str.to_string())]); 1303 } 1304 if let Some(ref local_var_str) = amount { 1305 local_var_req_builder = local_var_req_builder.query(&[("amount", &local_var_str.to_string())]); 1306 } 1307 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { 1308 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); 1309 } 1310 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { 1311 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned()); 1312 }; 1313 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token { 1314 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); 1315 }; 1316 1317 let local_var_req = local_var_req_builder.build()?; 1318 let local_var_resp = local_var_client.execute(local_var_req).await?; 1319 1320 let local_var_status = local_var_resp.status(); 1321 let local_var_content = local_var_resp.text().await?; 1322 1323 if !local_var_status.is_client_error() && !local_var_status.is_server_error() { 1324 serde_json::from_str(&local_var_content).map_err(Error::from) 1325 } else { 1326 let local_var_entity: Option<ListGroupsError> = serde_json::from_str(&local_var_content).ok(); 1327 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; 1328 Err(Error::ResponseError(local_var_error)) 1329 } 1330 } 1331 1332 pub async fn list_policies(configuration: &configuration::Configuration, prefix: Option<&str>, after: Option<&str>, amount: Option<i32>) -> Result<models::PolicyList, Error<ListPoliciesError>> { 1333 let local_var_configuration = configuration; 1334 1335 let local_var_client = &local_var_configuration.client; 1336 1337 let local_var_uri_str = format!("{}/auth/policies", local_var_configuration.base_path); 1338 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); 1339 1340 if let Some(ref local_var_str) = prefix { 1341 local_var_req_builder = local_var_req_builder.query(&[("prefix", &local_var_str.to_string())]); 1342 } 1343 if let Some(ref local_var_str) = after { 1344 local_var_req_builder = local_var_req_builder.query(&[("after", &local_var_str.to_string())]); 1345 } 1346 if let Some(ref local_var_str) = amount { 1347 local_var_req_builder = local_var_req_builder.query(&[("amount", &local_var_str.to_string())]); 1348 } 1349 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { 1350 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); 1351 } 1352 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { 1353 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned()); 1354 }; 1355 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token { 1356 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); 1357 }; 1358 1359 let local_var_req = local_var_req_builder.build()?; 1360 let local_var_resp = local_var_client.execute(local_var_req).await?; 1361 1362 let local_var_status = local_var_resp.status(); 1363 let local_var_content = local_var_resp.text().await?; 1364 1365 if !local_var_status.is_client_error() && !local_var_status.is_server_error() { 1366 serde_json::from_str(&local_var_content).map_err(Error::from) 1367 } else { 1368 let local_var_entity: Option<ListPoliciesError> = serde_json::from_str(&local_var_content).ok(); 1369 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; 1370 Err(Error::ResponseError(local_var_error)) 1371 } 1372 } 1373 1374 pub async fn list_user_credentials(configuration: &configuration::Configuration, user_id: &str, prefix: Option<&str>, after: Option<&str>, amount: Option<i32>) -> Result<models::CredentialsList, Error<ListUserCredentialsError>> { 1375 let local_var_configuration = configuration; 1376 1377 let local_var_client = &local_var_configuration.client; 1378 1379 let local_var_uri_str = format!("{}/auth/users/{userId}/credentials", local_var_configuration.base_path, userId=crate::apis::urlencode(user_id)); 1380 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); 1381 1382 if let Some(ref local_var_str) = prefix { 1383 local_var_req_builder = local_var_req_builder.query(&[("prefix", &local_var_str.to_string())]); 1384 } 1385 if let Some(ref local_var_str) = after { 1386 local_var_req_builder = local_var_req_builder.query(&[("after", &local_var_str.to_string())]); 1387 } 1388 if let Some(ref local_var_str) = amount { 1389 local_var_req_builder = local_var_req_builder.query(&[("amount", &local_var_str.to_string())]); 1390 } 1391 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { 1392 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); 1393 } 1394 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { 1395 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned()); 1396 }; 1397 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token { 1398 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); 1399 }; 1400 1401 let local_var_req = local_var_req_builder.build()?; 1402 let local_var_resp = local_var_client.execute(local_var_req).await?; 1403 1404 let local_var_status = local_var_resp.status(); 1405 let local_var_content = local_var_resp.text().await?; 1406 1407 if !local_var_status.is_client_error() && !local_var_status.is_server_error() { 1408 serde_json::from_str(&local_var_content).map_err(Error::from) 1409 } else { 1410 let local_var_entity: Option<ListUserCredentialsError> = serde_json::from_str(&local_var_content).ok(); 1411 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; 1412 Err(Error::ResponseError(local_var_error)) 1413 } 1414 } 1415 1416 pub async fn list_user_external_principals(configuration: &configuration::Configuration, user_id: &str, prefix: Option<&str>, after: Option<&str>, amount: Option<i32>) -> Result<models::ExternalPrincipalList, Error<ListUserExternalPrincipalsError>> { 1417 let local_var_configuration = configuration; 1418 1419 let local_var_client = &local_var_configuration.client; 1420 1421 let local_var_uri_str = format!("{}/auth/users/{userId}/external/principals/ls", local_var_configuration.base_path, userId=crate::apis::urlencode(user_id)); 1422 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); 1423 1424 if let Some(ref local_var_str) = prefix { 1425 local_var_req_builder = local_var_req_builder.query(&[("prefix", &local_var_str.to_string())]); 1426 } 1427 if let Some(ref local_var_str) = after { 1428 local_var_req_builder = local_var_req_builder.query(&[("after", &local_var_str.to_string())]); 1429 } 1430 if let Some(ref local_var_str) = amount { 1431 local_var_req_builder = local_var_req_builder.query(&[("amount", &local_var_str.to_string())]); 1432 } 1433 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { 1434 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); 1435 } 1436 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { 1437 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned()); 1438 }; 1439 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token { 1440 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); 1441 }; 1442 1443 let local_var_req = local_var_req_builder.build()?; 1444 let local_var_resp = local_var_client.execute(local_var_req).await?; 1445 1446 let local_var_status = local_var_resp.status(); 1447 let local_var_content = local_var_resp.text().await?; 1448 1449 if !local_var_status.is_client_error() && !local_var_status.is_server_error() { 1450 serde_json::from_str(&local_var_content).map_err(Error::from) 1451 } else { 1452 let local_var_entity: Option<ListUserExternalPrincipalsError> = serde_json::from_str(&local_var_content).ok(); 1453 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; 1454 Err(Error::ResponseError(local_var_error)) 1455 } 1456 } 1457 1458 pub async fn list_user_groups(configuration: &configuration::Configuration, user_id: &str, prefix: Option<&str>, after: Option<&str>, amount: Option<i32>) -> Result<models::GroupList, Error<ListUserGroupsError>> { 1459 let local_var_configuration = configuration; 1460 1461 let local_var_client = &local_var_configuration.client; 1462 1463 let local_var_uri_str = format!("{}/auth/users/{userId}/groups", local_var_configuration.base_path, userId=crate::apis::urlencode(user_id)); 1464 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); 1465 1466 if let Some(ref local_var_str) = prefix { 1467 local_var_req_builder = local_var_req_builder.query(&[("prefix", &local_var_str.to_string())]); 1468 } 1469 if let Some(ref local_var_str) = after { 1470 local_var_req_builder = local_var_req_builder.query(&[("after", &local_var_str.to_string())]); 1471 } 1472 if let Some(ref local_var_str) = amount { 1473 local_var_req_builder = local_var_req_builder.query(&[("amount", &local_var_str.to_string())]); 1474 } 1475 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { 1476 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); 1477 } 1478 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { 1479 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned()); 1480 }; 1481 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token { 1482 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); 1483 }; 1484 1485 let local_var_req = local_var_req_builder.build()?; 1486 let local_var_resp = local_var_client.execute(local_var_req).await?; 1487 1488 let local_var_status = local_var_resp.status(); 1489 let local_var_content = local_var_resp.text().await?; 1490 1491 if !local_var_status.is_client_error() && !local_var_status.is_server_error() { 1492 serde_json::from_str(&local_var_content).map_err(Error::from) 1493 } else { 1494 let local_var_entity: Option<ListUserGroupsError> = serde_json::from_str(&local_var_content).ok(); 1495 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; 1496 Err(Error::ResponseError(local_var_error)) 1497 } 1498 } 1499 1500 pub async fn list_user_policies(configuration: &configuration::Configuration, user_id: &str, prefix: Option<&str>, after: Option<&str>, amount: Option<i32>, effective: Option<bool>) -> Result<models::PolicyList, Error<ListUserPoliciesError>> { 1501 let local_var_configuration = configuration; 1502 1503 let local_var_client = &local_var_configuration.client; 1504 1505 let local_var_uri_str = format!("{}/auth/users/{userId}/policies", local_var_configuration.base_path, userId=crate::apis::urlencode(user_id)); 1506 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); 1507 1508 if let Some(ref local_var_str) = prefix { 1509 local_var_req_builder = local_var_req_builder.query(&[("prefix", &local_var_str.to_string())]); 1510 } 1511 if let Some(ref local_var_str) = after { 1512 local_var_req_builder = local_var_req_builder.query(&[("after", &local_var_str.to_string())]); 1513 } 1514 if let Some(ref local_var_str) = amount { 1515 local_var_req_builder = local_var_req_builder.query(&[("amount", &local_var_str.to_string())]); 1516 } 1517 if let Some(ref local_var_str) = effective { 1518 local_var_req_builder = local_var_req_builder.query(&[("effective", &local_var_str.to_string())]); 1519 } 1520 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { 1521 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); 1522 } 1523 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { 1524 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned()); 1525 }; 1526 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token { 1527 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); 1528 }; 1529 1530 let local_var_req = local_var_req_builder.build()?; 1531 let local_var_resp = local_var_client.execute(local_var_req).await?; 1532 1533 let local_var_status = local_var_resp.status(); 1534 let local_var_content = local_var_resp.text().await?; 1535 1536 if !local_var_status.is_client_error() && !local_var_status.is_server_error() { 1537 serde_json::from_str(&local_var_content).map_err(Error::from) 1538 } else { 1539 let local_var_entity: Option<ListUserPoliciesError> = serde_json::from_str(&local_var_content).ok(); 1540 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; 1541 Err(Error::ResponseError(local_var_error)) 1542 } 1543 } 1544 1545 pub async fn list_users(configuration: &configuration::Configuration, prefix: Option<&str>, after: Option<&str>, amount: Option<i32>) -> Result<models::UserList, Error<ListUsersError>> { 1546 let local_var_configuration = configuration; 1547 1548 let local_var_client = &local_var_configuration.client; 1549 1550 let local_var_uri_str = format!("{}/auth/users", local_var_configuration.base_path); 1551 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); 1552 1553 if let Some(ref local_var_str) = prefix { 1554 local_var_req_builder = local_var_req_builder.query(&[("prefix", &local_var_str.to_string())]); 1555 } 1556 if let Some(ref local_var_str) = after { 1557 local_var_req_builder = local_var_req_builder.query(&[("after", &local_var_str.to_string())]); 1558 } 1559 if let Some(ref local_var_str) = amount { 1560 local_var_req_builder = local_var_req_builder.query(&[("amount", &local_var_str.to_string())]); 1561 } 1562 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { 1563 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); 1564 } 1565 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { 1566 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned()); 1567 }; 1568 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token { 1569 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); 1570 }; 1571 1572 let local_var_req = local_var_req_builder.build()?; 1573 let local_var_resp = local_var_client.execute(local_var_req).await?; 1574 1575 let local_var_status = local_var_resp.status(); 1576 let local_var_content = local_var_resp.text().await?; 1577 1578 if !local_var_status.is_client_error() && !local_var_status.is_server_error() { 1579 serde_json::from_str(&local_var_content).map_err(Error::from) 1580 } else { 1581 let local_var_entity: Option<ListUsersError> = serde_json::from_str(&local_var_content).ok(); 1582 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; 1583 Err(Error::ResponseError(local_var_error)) 1584 } 1585 } 1586 1587 pub async fn login(configuration: &configuration::Configuration, login_information: Option<models::LoginInformation>) -> Result<models::AuthenticationToken, Error<LoginError>> { 1588 let local_var_configuration = configuration; 1589 1590 let local_var_client = &local_var_configuration.client; 1591 1592 let local_var_uri_str = format!("{}/auth/login", local_var_configuration.base_path); 1593 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); 1594 1595 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { 1596 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); 1597 } 1598 local_var_req_builder = local_var_req_builder.json(&login_information); 1599 1600 let local_var_req = local_var_req_builder.build()?; 1601 let local_var_resp = local_var_client.execute(local_var_req).await?; 1602 1603 let local_var_status = local_var_resp.status(); 1604 let local_var_content = local_var_resp.text().await?; 1605 1606 if !local_var_status.is_client_error() && !local_var_status.is_server_error() { 1607 serde_json::from_str(&local_var_content).map_err(Error::from) 1608 } else { 1609 let local_var_entity: Option<LoginError> = serde_json::from_str(&local_var_content).ok(); 1610 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; 1611 Err(Error::ResponseError(local_var_error)) 1612 } 1613 } 1614 1615 pub async fn set_group_acl(configuration: &configuration::Configuration, group_id: &str, acl: models::Acl) -> Result<(), Error<SetGroupAclError>> { 1616 let local_var_configuration = configuration; 1617 1618 let local_var_client = &local_var_configuration.client; 1619 1620 let local_var_uri_str = format!("{}/auth/groups/{groupId}/acl", local_var_configuration.base_path, groupId=crate::apis::urlencode(group_id)); 1621 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); 1622 1623 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { 1624 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); 1625 } 1626 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { 1627 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned()); 1628 }; 1629 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token { 1630 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); 1631 }; 1632 local_var_req_builder = local_var_req_builder.json(&acl); 1633 1634 let local_var_req = local_var_req_builder.build()?; 1635 let local_var_resp = local_var_client.execute(local_var_req).await?; 1636 1637 let local_var_status = local_var_resp.status(); 1638 let local_var_content = local_var_resp.text().await?; 1639 1640 if !local_var_status.is_client_error() && !local_var_status.is_server_error() { 1641 Ok(()) 1642 } else { 1643 let local_var_entity: Option<SetGroupAclError> = serde_json::from_str(&local_var_content).ok(); 1644 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; 1645 Err(Error::ResponseError(local_var_error)) 1646 } 1647 } 1648 1649 pub async fn update_policy(configuration: &configuration::Configuration, policy_id: &str, policy: models::Policy) -> Result<models::Policy, Error<UpdatePolicyError>> { 1650 let local_var_configuration = configuration; 1651 1652 let local_var_client = &local_var_configuration.client; 1653 1654 let local_var_uri_str = format!("{}/auth/policies/{policyId}", local_var_configuration.base_path, policyId=crate::apis::urlencode(policy_id)); 1655 let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); 1656 1657 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { 1658 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); 1659 } 1660 if let Some(ref local_var_auth_conf) = local_var_configuration.basic_auth { 1661 local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned()); 1662 }; 1663 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token { 1664 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); 1665 }; 1666 local_var_req_builder = local_var_req_builder.json(&policy); 1667 1668 let local_var_req = local_var_req_builder.build()?; 1669 let local_var_resp = local_var_client.execute(local_var_req).await?; 1670 1671 let local_var_status = local_var_resp.status(); 1672 let local_var_content = local_var_resp.text().await?; 1673 1674 if !local_var_status.is_client_error() && !local_var_status.is_server_error() { 1675 serde_json::from_str(&local_var_content).map_err(Error::from) 1676 } else { 1677 let local_var_entity: Option<UpdatePolicyError> = serde_json::from_str(&local_var_content).ok(); 1678 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; 1679 Err(Error::ResponseError(local_var_error)) 1680 } 1681 } 1682