use std::error::Error;
use std::fmt;
use std::io;
#[allow(warnings)]
use futures::future;
use futures::Future;
use rusoto_core::region;
use rusoto_core::request::{BufferedHttpResponse, DispatchSignedRequest};
use rusoto_core::{Client, RusotoFuture};
use rusoto_core::credential::{CredentialsError, ProvideAwsCredentials};
use rusoto_core::request::HttpDispatchError;
use rusoto_core::param::{Params, ServiceParams};
use rusoto_core::signature::SignedRequest;
use serde_json;
use serde_json::from_slice;
use serde_json::Value as SerdeJsonValue;
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct CreateUserRequest {
#[serde(rename = "DirectoryUserId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub directory_user_id: Option<String>,
#[serde(rename = "HierarchyGroupId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub hierarchy_group_id: Option<String>,
#[serde(rename = "IdentityInfo")]
#[serde(skip_serializing_if = "Option::is_none")]
pub identity_info: Option<UserIdentityInfo>,
#[serde(rename = "InstanceId")]
pub instance_id: String,
#[serde(rename = "Password")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password: Option<String>,
#[serde(rename = "PhoneConfig")]
pub phone_config: UserPhoneConfig,
#[serde(rename = "RoutingProfileId")]
pub routing_profile_id: String,
#[serde(rename = "SecurityProfileIds")]
pub security_profile_ids: Vec<String>,
#[serde(rename = "Username")]
pub username: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct CreateUserResponse {
#[serde(rename = "UserArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_arn: Option<String>,
#[serde(rename = "UserId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_id: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct Credentials {
#[serde(rename = "AccessToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub access_token: Option<String>,
#[serde(rename = "AccessTokenExpiration")]
#[serde(skip_serializing_if = "Option::is_none")]
pub access_token_expiration: Option<f64>,
#[serde(rename = "RefreshToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub refresh_token: Option<String>,
#[serde(rename = "RefreshTokenExpiration")]
#[serde(skip_serializing_if = "Option::is_none")]
pub refresh_token_expiration: Option<f64>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DeleteUserRequest {
#[serde(rename = "InstanceId")]
pub instance_id: String,
#[serde(rename = "UserId")]
pub user_id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DescribeUserHierarchyGroupRequest {
#[serde(rename = "HierarchyGroupId")]
pub hierarchy_group_id: String,
#[serde(rename = "InstanceId")]
pub instance_id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DescribeUserHierarchyGroupResponse {
#[serde(rename = "HierarchyGroup")]
#[serde(skip_serializing_if = "Option::is_none")]
pub hierarchy_group: Option<HierarchyGroup>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DescribeUserHierarchyStructureRequest {
#[serde(rename = "InstanceId")]
pub instance_id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DescribeUserHierarchyStructureResponse {
#[serde(rename = "HierarchyStructure")]
#[serde(skip_serializing_if = "Option::is_none")]
pub hierarchy_structure: Option<HierarchyStructure>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DescribeUserRequest {
#[serde(rename = "InstanceId")]
pub instance_id: String,
#[serde(rename = "UserId")]
pub user_id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DescribeUserResponse {
#[serde(rename = "User")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user: Option<User>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct GetFederationTokenRequest {
#[serde(rename = "InstanceId")]
pub instance_id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct GetFederationTokenResponse {
#[serde(rename = "Credentials")]
#[serde(skip_serializing_if = "Option::is_none")]
pub credentials: Option<Credentials>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct HierarchyGroup {
#[serde(rename = "Arn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub arn: Option<String>,
#[serde(rename = "HierarchyPath")]
#[serde(skip_serializing_if = "Option::is_none")]
pub hierarchy_path: Option<HierarchyPath>,
#[serde(rename = "Id")]
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
#[serde(rename = "LevelId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub level_id: Option<String>,
#[serde(rename = "Name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct HierarchyGroupSummary {
#[serde(rename = "Arn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub arn: Option<String>,
#[serde(rename = "Id")]
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
#[serde(rename = "Name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct HierarchyLevel {
#[serde(rename = "Arn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub arn: Option<String>,
#[serde(rename = "Id")]
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
#[serde(rename = "Name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct HierarchyPath {
#[serde(rename = "LevelFive")]
#[serde(skip_serializing_if = "Option::is_none")]
pub level_five: Option<HierarchyGroupSummary>,
#[serde(rename = "LevelFour")]
#[serde(skip_serializing_if = "Option::is_none")]
pub level_four: Option<HierarchyGroupSummary>,
#[serde(rename = "LevelOne")]
#[serde(skip_serializing_if = "Option::is_none")]
pub level_one: Option<HierarchyGroupSummary>,
#[serde(rename = "LevelThree")]
#[serde(skip_serializing_if = "Option::is_none")]
pub level_three: Option<HierarchyGroupSummary>,
#[serde(rename = "LevelTwo")]
#[serde(skip_serializing_if = "Option::is_none")]
pub level_two: Option<HierarchyGroupSummary>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct HierarchyStructure {
#[serde(rename = "LevelFive")]
#[serde(skip_serializing_if = "Option::is_none")]
pub level_five: Option<HierarchyLevel>,
#[serde(rename = "LevelFour")]
#[serde(skip_serializing_if = "Option::is_none")]
pub level_four: Option<HierarchyLevel>,
#[serde(rename = "LevelOne")]
#[serde(skip_serializing_if = "Option::is_none")]
pub level_one: Option<HierarchyLevel>,
#[serde(rename = "LevelThree")]
#[serde(skip_serializing_if = "Option::is_none")]
pub level_three: Option<HierarchyLevel>,
#[serde(rename = "LevelTwo")]
#[serde(skip_serializing_if = "Option::is_none")]
pub level_two: Option<HierarchyLevel>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct ListRoutingProfilesRequest {
#[serde(rename = "InstanceId")]
pub instance_id: String,
#[serde(rename = "MaxResults")]
#[serde(skip_serializing_if = "Option::is_none")]
pub max_results: Option<i64>,
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct ListRoutingProfilesResponse {
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
#[serde(rename = "RoutingProfileSummaryList")]
#[serde(skip_serializing_if = "Option::is_none")]
pub routing_profile_summary_list: Option<Vec<RoutingProfileSummary>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct ListSecurityProfilesRequest {
#[serde(rename = "InstanceId")]
pub instance_id: String,
#[serde(rename = "MaxResults")]
#[serde(skip_serializing_if = "Option::is_none")]
pub max_results: Option<i64>,
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct ListSecurityProfilesResponse {
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
#[serde(rename = "SecurityProfileSummaryList")]
#[serde(skip_serializing_if = "Option::is_none")]
pub security_profile_summary_list: Option<Vec<SecurityProfileSummary>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct ListUserHierarchyGroupsRequest {
#[serde(rename = "InstanceId")]
pub instance_id: String,
#[serde(rename = "MaxResults")]
#[serde(skip_serializing_if = "Option::is_none")]
pub max_results: Option<i64>,
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct ListUserHierarchyGroupsResponse {
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
#[serde(rename = "UserHierarchyGroupSummaryList")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_hierarchy_group_summary_list: Option<Vec<HierarchyGroupSummary>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct ListUsersRequest {
#[serde(rename = "InstanceId")]
pub instance_id: String,
#[serde(rename = "MaxResults")]
#[serde(skip_serializing_if = "Option::is_none")]
pub max_results: Option<i64>,
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct ListUsersResponse {
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
#[serde(rename = "UserSummaryList")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_summary_list: Option<Vec<UserSummary>>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct RoutingProfileSummary {
#[serde(rename = "Arn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub arn: Option<String>,
#[serde(rename = "Id")]
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
#[serde(rename = "Name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct SecurityProfileSummary {
#[serde(rename = "Arn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub arn: Option<String>,
#[serde(rename = "Id")]
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
#[serde(rename = "Name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct StartOutboundVoiceContactRequest {
#[serde(rename = "Attributes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub attributes: Option<::std::collections::HashMap<String, String>>,
#[serde(rename = "ClientToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub client_token: Option<String>,
#[serde(rename = "ContactFlowId")]
pub contact_flow_id: String,
#[serde(rename = "DestinationPhoneNumber")]
pub destination_phone_number: String,
#[serde(rename = "InstanceId")]
pub instance_id: String,
#[serde(rename = "QueueId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub queue_id: Option<String>,
#[serde(rename = "SourcePhoneNumber")]
#[serde(skip_serializing_if = "Option::is_none")]
pub source_phone_number: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct StartOutboundVoiceContactResponse {
#[serde(rename = "ContactId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub contact_id: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct StopContactRequest {
#[serde(rename = "ContactId")]
pub contact_id: String,
#[serde(rename = "InstanceId")]
pub instance_id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct StopContactResponse {}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct UpdateUserHierarchyRequest {
#[serde(rename = "HierarchyGroupId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub hierarchy_group_id: Option<String>,
#[serde(rename = "InstanceId")]
pub instance_id: String,
#[serde(rename = "UserId")]
pub user_id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct UpdateUserIdentityInfoRequest {
#[serde(rename = "IdentityInfo")]
pub identity_info: UserIdentityInfo,
#[serde(rename = "InstanceId")]
pub instance_id: String,
#[serde(rename = "UserId")]
pub user_id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct UpdateUserPhoneConfigRequest {
#[serde(rename = "InstanceId")]
pub instance_id: String,
#[serde(rename = "PhoneConfig")]
pub phone_config: UserPhoneConfig,
#[serde(rename = "UserId")]
pub user_id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct UpdateUserRoutingProfileRequest {
#[serde(rename = "InstanceId")]
pub instance_id: String,
#[serde(rename = "RoutingProfileId")]
pub routing_profile_id: String,
#[serde(rename = "UserId")]
pub user_id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct UpdateUserSecurityProfilesRequest {
#[serde(rename = "InstanceId")]
pub instance_id: String,
#[serde(rename = "SecurityProfileIds")]
pub security_profile_ids: Vec<String>,
#[serde(rename = "UserId")]
pub user_id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct User {
#[serde(rename = "Arn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub arn: Option<String>,
#[serde(rename = "DirectoryUserId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub directory_user_id: Option<String>,
#[serde(rename = "HierarchyGroupId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub hierarchy_group_id: Option<String>,
#[serde(rename = "Id")]
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
#[serde(rename = "IdentityInfo")]
#[serde(skip_serializing_if = "Option::is_none")]
pub identity_info: Option<UserIdentityInfo>,
#[serde(rename = "PhoneConfig")]
#[serde(skip_serializing_if = "Option::is_none")]
pub phone_config: Option<UserPhoneConfig>,
#[serde(rename = "RoutingProfileId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub routing_profile_id: Option<String>,
#[serde(rename = "SecurityProfileIds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub security_profile_ids: Option<Vec<String>>,
#[serde(rename = "Username")]
#[serde(skip_serializing_if = "Option::is_none")]
pub username: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct UserIdentityInfo {
#[serde(rename = "Email")]
#[serde(skip_serializing_if = "Option::is_none")]
pub email: Option<String>,
#[serde(rename = "FirstName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub first_name: Option<String>,
#[serde(rename = "LastName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_name: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct UserPhoneConfig {
#[serde(rename = "AfterContactWorkTimeLimit")]
#[serde(skip_serializing_if = "Option::is_none")]
pub after_contact_work_time_limit: Option<i64>,
#[serde(rename = "AutoAccept")]
#[serde(skip_serializing_if = "Option::is_none")]
pub auto_accept: Option<bool>,
#[serde(rename = "DeskPhoneNumber")]
#[serde(skip_serializing_if = "Option::is_none")]
pub desk_phone_number: Option<String>,
#[serde(rename = "PhoneType")]
pub phone_type: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct UserSummary {
#[serde(rename = "Arn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub arn: Option<String>,
#[serde(rename = "Id")]
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
#[serde(rename = "Username")]
#[serde(skip_serializing_if = "Option::is_none")]
pub username: Option<String>,
}
#[derive(Debug, PartialEq)]
pub enum CreateUserError {
DuplicateResource(String),
InternalService(String),
InvalidParameter(String),
InvalidRequest(String),
LimitExceeded(String),
ResourceNotFound(String),
Throttling(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl CreateUserError {
pub fn from_response(res: BufferedHttpResponse) -> CreateUserError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"DuplicateResourceException" => {
return CreateUserError::DuplicateResource(String::from(error_message))
}
"InternalServiceException" => {
return CreateUserError::InternalService(String::from(error_message))
}
"InvalidParameterException" => {
return CreateUserError::InvalidParameter(String::from(error_message))
}
"InvalidRequestException" => {
return CreateUserError::InvalidRequest(String::from(error_message))
}
"LimitExceededException" => {
return CreateUserError::LimitExceeded(String::from(error_message))
}
"ResourceNotFoundException" => {
return CreateUserError::ResourceNotFound(String::from(error_message))
}
"ThrottlingException" => {
return CreateUserError::Throttling(String::from(error_message))
}
"ValidationException" => {
return CreateUserError::Validation(error_message.to_string())
}
_ => {}
}
}
return CreateUserError::Unknown(res);
}
}
impl From<serde_json::error::Error> for CreateUserError {
fn from(err: serde_json::error::Error) -> CreateUserError {
CreateUserError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for CreateUserError {
fn from(err: CredentialsError) -> CreateUserError {
CreateUserError::Credentials(err)
}
}
impl From<HttpDispatchError> for CreateUserError {
fn from(err: HttpDispatchError) -> CreateUserError {
CreateUserError::HttpDispatch(err)
}
}
impl From<io::Error> for CreateUserError {
fn from(err: io::Error) -> CreateUserError {
CreateUserError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for CreateUserError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for CreateUserError {
fn description(&self) -> &str {
match *self {
CreateUserError::DuplicateResource(ref cause) => cause,
CreateUserError::InternalService(ref cause) => cause,
CreateUserError::InvalidParameter(ref cause) => cause,
CreateUserError::InvalidRequest(ref cause) => cause,
CreateUserError::LimitExceeded(ref cause) => cause,
CreateUserError::ResourceNotFound(ref cause) => cause,
CreateUserError::Throttling(ref cause) => cause,
CreateUserError::Validation(ref cause) => cause,
CreateUserError::Credentials(ref err) => err.description(),
CreateUserError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
CreateUserError::ParseError(ref cause) => cause,
CreateUserError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DeleteUserError {
InternalService(String),
InvalidParameter(String),
InvalidRequest(String),
ResourceNotFound(String),
Throttling(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DeleteUserError {
pub fn from_response(res: BufferedHttpResponse) -> DeleteUserError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InternalServiceException" => {
return DeleteUserError::InternalService(String::from(error_message))
}
"InvalidParameterException" => {
return DeleteUserError::InvalidParameter(String::from(error_message))
}
"InvalidRequestException" => {
return DeleteUserError::InvalidRequest(String::from(error_message))
}
"ResourceNotFoundException" => {
return DeleteUserError::ResourceNotFound(String::from(error_message))
}
"ThrottlingException" => {
return DeleteUserError::Throttling(String::from(error_message))
}
"ValidationException" => {
return DeleteUserError::Validation(error_message.to_string())
}
_ => {}
}
}
return DeleteUserError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DeleteUserError {
fn from(err: serde_json::error::Error) -> DeleteUserError {
DeleteUserError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DeleteUserError {
fn from(err: CredentialsError) -> DeleteUserError {
DeleteUserError::Credentials(err)
}
}
impl From<HttpDispatchError> for DeleteUserError {
fn from(err: HttpDispatchError) -> DeleteUserError {
DeleteUserError::HttpDispatch(err)
}
}
impl From<io::Error> for DeleteUserError {
fn from(err: io::Error) -> DeleteUserError {
DeleteUserError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DeleteUserError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DeleteUserError {
fn description(&self) -> &str {
match *self {
DeleteUserError::InternalService(ref cause) => cause,
DeleteUserError::InvalidParameter(ref cause) => cause,
DeleteUserError::InvalidRequest(ref cause) => cause,
DeleteUserError::ResourceNotFound(ref cause) => cause,
DeleteUserError::Throttling(ref cause) => cause,
DeleteUserError::Validation(ref cause) => cause,
DeleteUserError::Credentials(ref err) => err.description(),
DeleteUserError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
DeleteUserError::ParseError(ref cause) => cause,
DeleteUserError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DescribeUserError {
InternalService(String),
InvalidParameter(String),
InvalidRequest(String),
ResourceNotFound(String),
Throttling(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DescribeUserError {
pub fn from_response(res: BufferedHttpResponse) -> DescribeUserError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InternalServiceException" => {
return DescribeUserError::InternalService(String::from(error_message))
}
"InvalidParameterException" => {
return DescribeUserError::InvalidParameter(String::from(error_message))
}
"InvalidRequestException" => {
return DescribeUserError::InvalidRequest(String::from(error_message))
}
"ResourceNotFoundException" => {
return DescribeUserError::ResourceNotFound(String::from(error_message))
}
"ThrottlingException" => {
return DescribeUserError::Throttling(String::from(error_message))
}
"ValidationException" => {
return DescribeUserError::Validation(error_message.to_string())
}
_ => {}
}
}
return DescribeUserError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DescribeUserError {
fn from(err: serde_json::error::Error) -> DescribeUserError {
DescribeUserError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DescribeUserError {
fn from(err: CredentialsError) -> DescribeUserError {
DescribeUserError::Credentials(err)
}
}
impl From<HttpDispatchError> for DescribeUserError {
fn from(err: HttpDispatchError) -> DescribeUserError {
DescribeUserError::HttpDispatch(err)
}
}
impl From<io::Error> for DescribeUserError {
fn from(err: io::Error) -> DescribeUserError {
DescribeUserError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DescribeUserError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DescribeUserError {
fn description(&self) -> &str {
match *self {
DescribeUserError::InternalService(ref cause) => cause,
DescribeUserError::InvalidParameter(ref cause) => cause,
DescribeUserError::InvalidRequest(ref cause) => cause,
DescribeUserError::ResourceNotFound(ref cause) => cause,
DescribeUserError::Throttling(ref cause) => cause,
DescribeUserError::Validation(ref cause) => cause,
DescribeUserError::Credentials(ref err) => err.description(),
DescribeUserError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
DescribeUserError::ParseError(ref cause) => cause,
DescribeUserError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DescribeUserHierarchyGroupError {
InternalService(String),
InvalidParameter(String),
InvalidRequest(String),
ResourceNotFound(String),
Throttling(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DescribeUserHierarchyGroupError {
pub fn from_response(res: BufferedHttpResponse) -> DescribeUserHierarchyGroupError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InternalServiceException" => {
return DescribeUserHierarchyGroupError::InternalService(String::from(
error_message,
))
}
"InvalidParameterException" => {
return DescribeUserHierarchyGroupError::InvalidParameter(String::from(
error_message,
))
}
"InvalidRequestException" => {
return DescribeUserHierarchyGroupError::InvalidRequest(String::from(
error_message,
))
}
"ResourceNotFoundException" => {
return DescribeUserHierarchyGroupError::ResourceNotFound(String::from(
error_message,
))
}
"ThrottlingException" => {
return DescribeUserHierarchyGroupError::Throttling(String::from(error_message))
}
"ValidationException" => {
return DescribeUserHierarchyGroupError::Validation(error_message.to_string())
}
_ => {}
}
}
return DescribeUserHierarchyGroupError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DescribeUserHierarchyGroupError {
fn from(err: serde_json::error::Error) -> DescribeUserHierarchyGroupError {
DescribeUserHierarchyGroupError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DescribeUserHierarchyGroupError {
fn from(err: CredentialsError) -> DescribeUserHierarchyGroupError {
DescribeUserHierarchyGroupError::Credentials(err)
}
}
impl From<HttpDispatchError> for DescribeUserHierarchyGroupError {
fn from(err: HttpDispatchError) -> DescribeUserHierarchyGroupError {
DescribeUserHierarchyGroupError::HttpDispatch(err)
}
}
impl From<io::Error> for DescribeUserHierarchyGroupError {
fn from(err: io::Error) -> DescribeUserHierarchyGroupError {
DescribeUserHierarchyGroupError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DescribeUserHierarchyGroupError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DescribeUserHierarchyGroupError {
fn description(&self) -> &str {
match *self {
DescribeUserHierarchyGroupError::InternalService(ref cause) => cause,
DescribeUserHierarchyGroupError::InvalidParameter(ref cause) => cause,
DescribeUserHierarchyGroupError::InvalidRequest(ref cause) => cause,
DescribeUserHierarchyGroupError::ResourceNotFound(ref cause) => cause,
DescribeUserHierarchyGroupError::Throttling(ref cause) => cause,
DescribeUserHierarchyGroupError::Validation(ref cause) => cause,
DescribeUserHierarchyGroupError::Credentials(ref err) => err.description(),
DescribeUserHierarchyGroupError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
DescribeUserHierarchyGroupError::ParseError(ref cause) => cause,
DescribeUserHierarchyGroupError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DescribeUserHierarchyStructureError {
InternalService(String),
InvalidParameter(String),
InvalidRequest(String),
ResourceNotFound(String),
Throttling(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DescribeUserHierarchyStructureError {
pub fn from_response(res: BufferedHttpResponse) -> DescribeUserHierarchyStructureError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InternalServiceException" => {
return DescribeUserHierarchyStructureError::InternalService(String::from(
error_message,
))
}
"InvalidParameterException" => {
return DescribeUserHierarchyStructureError::InvalidParameter(String::from(
error_message,
))
}
"InvalidRequestException" => {
return DescribeUserHierarchyStructureError::InvalidRequest(String::from(
error_message,
))
}
"ResourceNotFoundException" => {
return DescribeUserHierarchyStructureError::ResourceNotFound(String::from(
error_message,
))
}
"ThrottlingException" => {
return DescribeUserHierarchyStructureError::Throttling(String::from(
error_message,
))
}
"ValidationException" => {
return DescribeUserHierarchyStructureError::Validation(
error_message.to_string(),
)
}
_ => {}
}
}
return DescribeUserHierarchyStructureError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DescribeUserHierarchyStructureError {
fn from(err: serde_json::error::Error) -> DescribeUserHierarchyStructureError {
DescribeUserHierarchyStructureError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DescribeUserHierarchyStructureError {
fn from(err: CredentialsError) -> DescribeUserHierarchyStructureError {
DescribeUserHierarchyStructureError::Credentials(err)
}
}
impl From<HttpDispatchError> for DescribeUserHierarchyStructureError {
fn from(err: HttpDispatchError) -> DescribeUserHierarchyStructureError {
DescribeUserHierarchyStructureError::HttpDispatch(err)
}
}
impl From<io::Error> for DescribeUserHierarchyStructureError {
fn from(err: io::Error) -> DescribeUserHierarchyStructureError {
DescribeUserHierarchyStructureError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DescribeUserHierarchyStructureError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DescribeUserHierarchyStructureError {
fn description(&self) -> &str {
match *self {
DescribeUserHierarchyStructureError::InternalService(ref cause) => cause,
DescribeUserHierarchyStructureError::InvalidParameter(ref cause) => cause,
DescribeUserHierarchyStructureError::InvalidRequest(ref cause) => cause,
DescribeUserHierarchyStructureError::ResourceNotFound(ref cause) => cause,
DescribeUserHierarchyStructureError::Throttling(ref cause) => cause,
DescribeUserHierarchyStructureError::Validation(ref cause) => cause,
DescribeUserHierarchyStructureError::Credentials(ref err) => err.description(),
DescribeUserHierarchyStructureError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
DescribeUserHierarchyStructureError::ParseError(ref cause) => cause,
DescribeUserHierarchyStructureError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum GetFederationTokenError {
DuplicateResource(String),
InternalService(String),
InvalidParameter(String),
InvalidRequest(String),
ResourceNotFound(String),
UserNotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl GetFederationTokenError {
pub fn from_response(res: BufferedHttpResponse) -> GetFederationTokenError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"DuplicateResourceException" => {
return GetFederationTokenError::DuplicateResource(String::from(error_message))
}
"InternalServiceException" => {
return GetFederationTokenError::InternalService(String::from(error_message))
}
"InvalidParameterException" => {
return GetFederationTokenError::InvalidParameter(String::from(error_message))
}
"InvalidRequestException" => {
return GetFederationTokenError::InvalidRequest(String::from(error_message))
}
"ResourceNotFoundException" => {
return GetFederationTokenError::ResourceNotFound(String::from(error_message))
}
"UserNotFoundException" => {
return GetFederationTokenError::UserNotFound(String::from(error_message))
}
"ValidationException" => {
return GetFederationTokenError::Validation(error_message.to_string())
}
_ => {}
}
}
return GetFederationTokenError::Unknown(res);
}
}
impl From<serde_json::error::Error> for GetFederationTokenError {
fn from(err: serde_json::error::Error) -> GetFederationTokenError {
GetFederationTokenError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for GetFederationTokenError {
fn from(err: CredentialsError) -> GetFederationTokenError {
GetFederationTokenError::Credentials(err)
}
}
impl From<HttpDispatchError> for GetFederationTokenError {
fn from(err: HttpDispatchError) -> GetFederationTokenError {
GetFederationTokenError::HttpDispatch(err)
}
}
impl From<io::Error> for GetFederationTokenError {
fn from(err: io::Error) -> GetFederationTokenError {
GetFederationTokenError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for GetFederationTokenError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for GetFederationTokenError {
fn description(&self) -> &str {
match *self {
GetFederationTokenError::DuplicateResource(ref cause) => cause,
GetFederationTokenError::InternalService(ref cause) => cause,
GetFederationTokenError::InvalidParameter(ref cause) => cause,
GetFederationTokenError::InvalidRequest(ref cause) => cause,
GetFederationTokenError::ResourceNotFound(ref cause) => cause,
GetFederationTokenError::UserNotFound(ref cause) => cause,
GetFederationTokenError::Validation(ref cause) => cause,
GetFederationTokenError::Credentials(ref err) => err.description(),
GetFederationTokenError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
GetFederationTokenError::ParseError(ref cause) => cause,
GetFederationTokenError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum ListRoutingProfilesError {
InternalService(String),
InvalidParameter(String),
InvalidRequest(String),
ResourceNotFound(String),
Throttling(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl ListRoutingProfilesError {
pub fn from_response(res: BufferedHttpResponse) -> ListRoutingProfilesError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InternalServiceException" => {
return ListRoutingProfilesError::InternalService(String::from(error_message))
}
"InvalidParameterException" => {
return ListRoutingProfilesError::InvalidParameter(String::from(error_message))
}
"InvalidRequestException" => {
return ListRoutingProfilesError::InvalidRequest(String::from(error_message))
}
"ResourceNotFoundException" => {
return ListRoutingProfilesError::ResourceNotFound(String::from(error_message))
}
"ThrottlingException" => {
return ListRoutingProfilesError::Throttling(String::from(error_message))
}
"ValidationException" => {
return ListRoutingProfilesError::Validation(error_message.to_string())
}
_ => {}
}
}
return ListRoutingProfilesError::Unknown(res);
}
}
impl From<serde_json::error::Error> for ListRoutingProfilesError {
fn from(err: serde_json::error::Error) -> ListRoutingProfilesError {
ListRoutingProfilesError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for ListRoutingProfilesError {
fn from(err: CredentialsError) -> ListRoutingProfilesError {
ListRoutingProfilesError::Credentials(err)
}
}
impl From<HttpDispatchError> for ListRoutingProfilesError {
fn from(err: HttpDispatchError) -> ListRoutingProfilesError {
ListRoutingProfilesError::HttpDispatch(err)
}
}
impl From<io::Error> for ListRoutingProfilesError {
fn from(err: io::Error) -> ListRoutingProfilesError {
ListRoutingProfilesError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for ListRoutingProfilesError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for ListRoutingProfilesError {
fn description(&self) -> &str {
match *self {
ListRoutingProfilesError::InternalService(ref cause) => cause,
ListRoutingProfilesError::InvalidParameter(ref cause) => cause,
ListRoutingProfilesError::InvalidRequest(ref cause) => cause,
ListRoutingProfilesError::ResourceNotFound(ref cause) => cause,
ListRoutingProfilesError::Throttling(ref cause) => cause,
ListRoutingProfilesError::Validation(ref cause) => cause,
ListRoutingProfilesError::Credentials(ref err) => err.description(),
ListRoutingProfilesError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
ListRoutingProfilesError::ParseError(ref cause) => cause,
ListRoutingProfilesError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum ListSecurityProfilesError {
InternalService(String),
InvalidParameter(String),
InvalidRequest(String),
ResourceNotFound(String),
Throttling(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl ListSecurityProfilesError {
pub fn from_response(res: BufferedHttpResponse) -> ListSecurityProfilesError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InternalServiceException" => {
return ListSecurityProfilesError::InternalService(String::from(error_message))
}
"InvalidParameterException" => {
return ListSecurityProfilesError::InvalidParameter(String::from(error_message))
}
"InvalidRequestException" => {
return ListSecurityProfilesError::InvalidRequest(String::from(error_message))
}
"ResourceNotFoundException" => {
return ListSecurityProfilesError::ResourceNotFound(String::from(error_message))
}
"ThrottlingException" => {
return ListSecurityProfilesError::Throttling(String::from(error_message))
}
"ValidationException" => {
return ListSecurityProfilesError::Validation(error_message.to_string())
}
_ => {}
}
}
return ListSecurityProfilesError::Unknown(res);
}
}
impl From<serde_json::error::Error> for ListSecurityProfilesError {
fn from(err: serde_json::error::Error) -> ListSecurityProfilesError {
ListSecurityProfilesError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for ListSecurityProfilesError {
fn from(err: CredentialsError) -> ListSecurityProfilesError {
ListSecurityProfilesError::Credentials(err)
}
}
impl From<HttpDispatchError> for ListSecurityProfilesError {
fn from(err: HttpDispatchError) -> ListSecurityProfilesError {
ListSecurityProfilesError::HttpDispatch(err)
}
}
impl From<io::Error> for ListSecurityProfilesError {
fn from(err: io::Error) -> ListSecurityProfilesError {
ListSecurityProfilesError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for ListSecurityProfilesError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for ListSecurityProfilesError {
fn description(&self) -> &str {
match *self {
ListSecurityProfilesError::InternalService(ref cause) => cause,
ListSecurityProfilesError::InvalidParameter(ref cause) => cause,
ListSecurityProfilesError::InvalidRequest(ref cause) => cause,
ListSecurityProfilesError::ResourceNotFound(ref cause) => cause,
ListSecurityProfilesError::Throttling(ref cause) => cause,
ListSecurityProfilesError::Validation(ref cause) => cause,
ListSecurityProfilesError::Credentials(ref err) => err.description(),
ListSecurityProfilesError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
ListSecurityProfilesError::ParseError(ref cause) => cause,
ListSecurityProfilesError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum ListUserHierarchyGroupsError {
InternalService(String),
InvalidParameter(String),
InvalidRequest(String),
ResourceNotFound(String),
Throttling(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl ListUserHierarchyGroupsError {
pub fn from_response(res: BufferedHttpResponse) -> ListUserHierarchyGroupsError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InternalServiceException" => {
return ListUserHierarchyGroupsError::InternalService(String::from(
error_message,
))
}
"InvalidParameterException" => {
return ListUserHierarchyGroupsError::InvalidParameter(String::from(
error_message,
))
}
"InvalidRequestException" => {
return ListUserHierarchyGroupsError::InvalidRequest(String::from(error_message))
}
"ResourceNotFoundException" => {
return ListUserHierarchyGroupsError::ResourceNotFound(String::from(
error_message,
))
}
"ThrottlingException" => {
return ListUserHierarchyGroupsError::Throttling(String::from(error_message))
}
"ValidationException" => {
return ListUserHierarchyGroupsError::Validation(error_message.to_string())
}
_ => {}
}
}
return ListUserHierarchyGroupsError::Unknown(res);
}
}
impl From<serde_json::error::Error> for ListUserHierarchyGroupsError {
fn from(err: serde_json::error::Error) -> ListUserHierarchyGroupsError {
ListUserHierarchyGroupsError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for ListUserHierarchyGroupsError {
fn from(err: CredentialsError) -> ListUserHierarchyGroupsError {
ListUserHierarchyGroupsError::Credentials(err)
}
}
impl From<HttpDispatchError> for ListUserHierarchyGroupsError {
fn from(err: HttpDispatchError) -> ListUserHierarchyGroupsError {
ListUserHierarchyGroupsError::HttpDispatch(err)
}
}
impl From<io::Error> for ListUserHierarchyGroupsError {
fn from(err: io::Error) -> ListUserHierarchyGroupsError {
ListUserHierarchyGroupsError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for ListUserHierarchyGroupsError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for ListUserHierarchyGroupsError {
fn description(&self) -> &str {
match *self {
ListUserHierarchyGroupsError::InternalService(ref cause) => cause,
ListUserHierarchyGroupsError::InvalidParameter(ref cause) => cause,
ListUserHierarchyGroupsError::InvalidRequest(ref cause) => cause,
ListUserHierarchyGroupsError::ResourceNotFound(ref cause) => cause,
ListUserHierarchyGroupsError::Throttling(ref cause) => cause,
ListUserHierarchyGroupsError::Validation(ref cause) => cause,
ListUserHierarchyGroupsError::Credentials(ref err) => err.description(),
ListUserHierarchyGroupsError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
ListUserHierarchyGroupsError::ParseError(ref cause) => cause,
ListUserHierarchyGroupsError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum ListUsersError {
InternalService(String),
InvalidParameter(String),
InvalidRequest(String),
ResourceNotFound(String),
Throttling(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl ListUsersError {
pub fn from_response(res: BufferedHttpResponse) -> ListUsersError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InternalServiceException" => {
return ListUsersError::InternalService(String::from(error_message))
}
"InvalidParameterException" => {
return ListUsersError::InvalidParameter(String::from(error_message))
}
"InvalidRequestException" => {
return ListUsersError::InvalidRequest(String::from(error_message))
}
"ResourceNotFoundException" => {
return ListUsersError::ResourceNotFound(String::from(error_message))
}
"ThrottlingException" => {
return ListUsersError::Throttling(String::from(error_message))
}
"ValidationException" => {
return ListUsersError::Validation(error_message.to_string())
}
_ => {}
}
}
return ListUsersError::Unknown(res);
}
}
impl From<serde_json::error::Error> for ListUsersError {
fn from(err: serde_json::error::Error) -> ListUsersError {
ListUsersError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for ListUsersError {
fn from(err: CredentialsError) -> ListUsersError {
ListUsersError::Credentials(err)
}
}
impl From<HttpDispatchError> for ListUsersError {
fn from(err: HttpDispatchError) -> ListUsersError {
ListUsersError::HttpDispatch(err)
}
}
impl From<io::Error> for ListUsersError {
fn from(err: io::Error) -> ListUsersError {
ListUsersError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for ListUsersError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for ListUsersError {
fn description(&self) -> &str {
match *self {
ListUsersError::InternalService(ref cause) => cause,
ListUsersError::InvalidParameter(ref cause) => cause,
ListUsersError::InvalidRequest(ref cause) => cause,
ListUsersError::ResourceNotFound(ref cause) => cause,
ListUsersError::Throttling(ref cause) => cause,
ListUsersError::Validation(ref cause) => cause,
ListUsersError::Credentials(ref err) => err.description(),
ListUsersError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
ListUsersError::ParseError(ref cause) => cause,
ListUsersError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum StartOutboundVoiceContactError {
DestinationNotAllowed(String),
InternalService(String),
InvalidParameter(String),
InvalidRequest(String),
LimitExceeded(String),
OutboundContactNotPermitted(String),
ResourceNotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl StartOutboundVoiceContactError {
pub fn from_response(res: BufferedHttpResponse) -> StartOutboundVoiceContactError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"DestinationNotAllowedException" => {
return StartOutboundVoiceContactError::DestinationNotAllowed(String::from(
error_message,
))
}
"InternalServiceException" => {
return StartOutboundVoiceContactError::InternalService(String::from(
error_message,
))
}
"InvalidParameterException" => {
return StartOutboundVoiceContactError::InvalidParameter(String::from(
error_message,
))
}
"InvalidRequestException" => {
return StartOutboundVoiceContactError::InvalidRequest(String::from(
error_message,
))
}
"LimitExceededException" => {
return StartOutboundVoiceContactError::LimitExceeded(String::from(
error_message,
))
}
"OutboundContactNotPermittedException" => {
return StartOutboundVoiceContactError::OutboundContactNotPermitted(
String::from(error_message),
)
}
"ResourceNotFoundException" => {
return StartOutboundVoiceContactError::ResourceNotFound(String::from(
error_message,
))
}
"ValidationException" => {
return StartOutboundVoiceContactError::Validation(error_message.to_string())
}
_ => {}
}
}
return StartOutboundVoiceContactError::Unknown(res);
}
}
impl From<serde_json::error::Error> for StartOutboundVoiceContactError {
fn from(err: serde_json::error::Error) -> StartOutboundVoiceContactError {
StartOutboundVoiceContactError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for StartOutboundVoiceContactError {
fn from(err: CredentialsError) -> StartOutboundVoiceContactError {
StartOutboundVoiceContactError::Credentials(err)
}
}
impl From<HttpDispatchError> for StartOutboundVoiceContactError {
fn from(err: HttpDispatchError) -> StartOutboundVoiceContactError {
StartOutboundVoiceContactError::HttpDispatch(err)
}
}
impl From<io::Error> for StartOutboundVoiceContactError {
fn from(err: io::Error) -> StartOutboundVoiceContactError {
StartOutboundVoiceContactError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for StartOutboundVoiceContactError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for StartOutboundVoiceContactError {
fn description(&self) -> &str {
match *self {
StartOutboundVoiceContactError::DestinationNotAllowed(ref cause) => cause,
StartOutboundVoiceContactError::InternalService(ref cause) => cause,
StartOutboundVoiceContactError::InvalidParameter(ref cause) => cause,
StartOutboundVoiceContactError::InvalidRequest(ref cause) => cause,
StartOutboundVoiceContactError::LimitExceeded(ref cause) => cause,
StartOutboundVoiceContactError::OutboundContactNotPermitted(ref cause) => cause,
StartOutboundVoiceContactError::ResourceNotFound(ref cause) => cause,
StartOutboundVoiceContactError::Validation(ref cause) => cause,
StartOutboundVoiceContactError::Credentials(ref err) => err.description(),
StartOutboundVoiceContactError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
StartOutboundVoiceContactError::ParseError(ref cause) => cause,
StartOutboundVoiceContactError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum StopContactError {
ContactNotFound(String),
InternalService(String),
InvalidParameter(String),
InvalidRequest(String),
ResourceNotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl StopContactError {
pub fn from_response(res: BufferedHttpResponse) -> StopContactError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"ContactNotFoundException" => {
return StopContactError::ContactNotFound(String::from(error_message))
}
"InternalServiceException" => {
return StopContactError::InternalService(String::from(error_message))
}
"InvalidParameterException" => {
return StopContactError::InvalidParameter(String::from(error_message))
}
"InvalidRequestException" => {
return StopContactError::InvalidRequest(String::from(error_message))
}
"ResourceNotFoundException" => {
return StopContactError::ResourceNotFound(String::from(error_message))
}
"ValidationException" => {
return StopContactError::Validation(error_message.to_string())
}
_ => {}
}
}
return StopContactError::Unknown(res);
}
}
impl From<serde_json::error::Error> for StopContactError {
fn from(err: serde_json::error::Error) -> StopContactError {
StopContactError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for StopContactError {
fn from(err: CredentialsError) -> StopContactError {
StopContactError::Credentials(err)
}
}
impl From<HttpDispatchError> for StopContactError {
fn from(err: HttpDispatchError) -> StopContactError {
StopContactError::HttpDispatch(err)
}
}
impl From<io::Error> for StopContactError {
fn from(err: io::Error) -> StopContactError {
StopContactError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for StopContactError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for StopContactError {
fn description(&self) -> &str {
match *self {
StopContactError::ContactNotFound(ref cause) => cause,
StopContactError::InternalService(ref cause) => cause,
StopContactError::InvalidParameter(ref cause) => cause,
StopContactError::InvalidRequest(ref cause) => cause,
StopContactError::ResourceNotFound(ref cause) => cause,
StopContactError::Validation(ref cause) => cause,
StopContactError::Credentials(ref err) => err.description(),
StopContactError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
StopContactError::ParseError(ref cause) => cause,
StopContactError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum UpdateUserHierarchyError {
InternalService(String),
InvalidParameter(String),
InvalidRequest(String),
ResourceNotFound(String),
Throttling(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl UpdateUserHierarchyError {
pub fn from_response(res: BufferedHttpResponse) -> UpdateUserHierarchyError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InternalServiceException" => {
return UpdateUserHierarchyError::InternalService(String::from(error_message))
}
"InvalidParameterException" => {
return UpdateUserHierarchyError::InvalidParameter(String::from(error_message))
}
"InvalidRequestException" => {
return UpdateUserHierarchyError::InvalidRequest(String::from(error_message))
}
"ResourceNotFoundException" => {
return UpdateUserHierarchyError::ResourceNotFound(String::from(error_message))
}
"ThrottlingException" => {
return UpdateUserHierarchyError::Throttling(String::from(error_message))
}
"ValidationException" => {
return UpdateUserHierarchyError::Validation(error_message.to_string())
}
_ => {}
}
}
return UpdateUserHierarchyError::Unknown(res);
}
}
impl From<serde_json::error::Error> for UpdateUserHierarchyError {
fn from(err: serde_json::error::Error) -> UpdateUserHierarchyError {
UpdateUserHierarchyError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for UpdateUserHierarchyError {
fn from(err: CredentialsError) -> UpdateUserHierarchyError {
UpdateUserHierarchyError::Credentials(err)
}
}
impl From<HttpDispatchError> for UpdateUserHierarchyError {
fn from(err: HttpDispatchError) -> UpdateUserHierarchyError {
UpdateUserHierarchyError::HttpDispatch(err)
}
}
impl From<io::Error> for UpdateUserHierarchyError {
fn from(err: io::Error) -> UpdateUserHierarchyError {
UpdateUserHierarchyError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for UpdateUserHierarchyError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for UpdateUserHierarchyError {
fn description(&self) -> &str {
match *self {
UpdateUserHierarchyError::InternalService(ref cause) => cause,
UpdateUserHierarchyError::InvalidParameter(ref cause) => cause,
UpdateUserHierarchyError::InvalidRequest(ref cause) => cause,
UpdateUserHierarchyError::ResourceNotFound(ref cause) => cause,
UpdateUserHierarchyError::Throttling(ref cause) => cause,
UpdateUserHierarchyError::Validation(ref cause) => cause,
UpdateUserHierarchyError::Credentials(ref err) => err.description(),
UpdateUserHierarchyError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
UpdateUserHierarchyError::ParseError(ref cause) => cause,
UpdateUserHierarchyError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum UpdateUserIdentityInfoError {
InternalService(String),
InvalidParameter(String),
InvalidRequest(String),
ResourceNotFound(String),
Throttling(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl UpdateUserIdentityInfoError {
pub fn from_response(res: BufferedHttpResponse) -> UpdateUserIdentityInfoError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InternalServiceException" => {
return UpdateUserIdentityInfoError::InternalService(String::from(error_message))
}
"InvalidParameterException" => {
return UpdateUserIdentityInfoError::InvalidParameter(String::from(
error_message,
))
}
"InvalidRequestException" => {
return UpdateUserIdentityInfoError::InvalidRequest(String::from(error_message))
}
"ResourceNotFoundException" => {
return UpdateUserIdentityInfoError::ResourceNotFound(String::from(
error_message,
))
}
"ThrottlingException" => {
return UpdateUserIdentityInfoError::Throttling(String::from(error_message))
}
"ValidationException" => {
return UpdateUserIdentityInfoError::Validation(error_message.to_string())
}
_ => {}
}
}
return UpdateUserIdentityInfoError::Unknown(res);
}
}
impl From<serde_json::error::Error> for UpdateUserIdentityInfoError {
fn from(err: serde_json::error::Error) -> UpdateUserIdentityInfoError {
UpdateUserIdentityInfoError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for UpdateUserIdentityInfoError {
fn from(err: CredentialsError) -> UpdateUserIdentityInfoError {
UpdateUserIdentityInfoError::Credentials(err)
}
}
impl From<HttpDispatchError> for UpdateUserIdentityInfoError {
fn from(err: HttpDispatchError) -> UpdateUserIdentityInfoError {
UpdateUserIdentityInfoError::HttpDispatch(err)
}
}
impl From<io::Error> for UpdateUserIdentityInfoError {
fn from(err: io::Error) -> UpdateUserIdentityInfoError {
UpdateUserIdentityInfoError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for UpdateUserIdentityInfoError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for UpdateUserIdentityInfoError {
fn description(&self) -> &str {
match *self {
UpdateUserIdentityInfoError::InternalService(ref cause) => cause,
UpdateUserIdentityInfoError::InvalidParameter(ref cause) => cause,
UpdateUserIdentityInfoError::InvalidRequest(ref cause) => cause,
UpdateUserIdentityInfoError::ResourceNotFound(ref cause) => cause,
UpdateUserIdentityInfoError::Throttling(ref cause) => cause,
UpdateUserIdentityInfoError::Validation(ref cause) => cause,
UpdateUserIdentityInfoError::Credentials(ref err) => err.description(),
UpdateUserIdentityInfoError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
UpdateUserIdentityInfoError::ParseError(ref cause) => cause,
UpdateUserIdentityInfoError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum UpdateUserPhoneConfigError {
InternalService(String),
InvalidParameter(String),
InvalidRequest(String),
ResourceNotFound(String),
Throttling(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl UpdateUserPhoneConfigError {
pub fn from_response(res: BufferedHttpResponse) -> UpdateUserPhoneConfigError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InternalServiceException" => {
return UpdateUserPhoneConfigError::InternalService(String::from(error_message))
}
"InvalidParameterException" => {
return UpdateUserPhoneConfigError::InvalidParameter(String::from(error_message))
}
"InvalidRequestException" => {
return UpdateUserPhoneConfigError::InvalidRequest(String::from(error_message))
}
"ResourceNotFoundException" => {
return UpdateUserPhoneConfigError::ResourceNotFound(String::from(error_message))
}
"ThrottlingException" => {
return UpdateUserPhoneConfigError::Throttling(String::from(error_message))
}
"ValidationException" => {
return UpdateUserPhoneConfigError::Validation(error_message.to_string())
}
_ => {}
}
}
return UpdateUserPhoneConfigError::Unknown(res);
}
}
impl From<serde_json::error::Error> for UpdateUserPhoneConfigError {
fn from(err: serde_json::error::Error) -> UpdateUserPhoneConfigError {
UpdateUserPhoneConfigError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for UpdateUserPhoneConfigError {
fn from(err: CredentialsError) -> UpdateUserPhoneConfigError {
UpdateUserPhoneConfigError::Credentials(err)
}
}
impl From<HttpDispatchError> for UpdateUserPhoneConfigError {
fn from(err: HttpDispatchError) -> UpdateUserPhoneConfigError {
UpdateUserPhoneConfigError::HttpDispatch(err)
}
}
impl From<io::Error> for UpdateUserPhoneConfigError {
fn from(err: io::Error) -> UpdateUserPhoneConfigError {
UpdateUserPhoneConfigError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for UpdateUserPhoneConfigError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for UpdateUserPhoneConfigError {
fn description(&self) -> &str {
match *self {
UpdateUserPhoneConfigError::InternalService(ref cause) => cause,
UpdateUserPhoneConfigError::InvalidParameter(ref cause) => cause,
UpdateUserPhoneConfigError::InvalidRequest(ref cause) => cause,
UpdateUserPhoneConfigError::ResourceNotFound(ref cause) => cause,
UpdateUserPhoneConfigError::Throttling(ref cause) => cause,
UpdateUserPhoneConfigError::Validation(ref cause) => cause,
UpdateUserPhoneConfigError::Credentials(ref err) => err.description(),
UpdateUserPhoneConfigError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
UpdateUserPhoneConfigError::ParseError(ref cause) => cause,
UpdateUserPhoneConfigError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum UpdateUserRoutingProfileError {
InternalService(String),
InvalidParameter(String),
InvalidRequest(String),
ResourceNotFound(String),
Throttling(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl UpdateUserRoutingProfileError {
pub fn from_response(res: BufferedHttpResponse) -> UpdateUserRoutingProfileError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InternalServiceException" => {
return UpdateUserRoutingProfileError::InternalService(String::from(
error_message,
))
}
"InvalidParameterException" => {
return UpdateUserRoutingProfileError::InvalidParameter(String::from(
error_message,
))
}
"InvalidRequestException" => {
return UpdateUserRoutingProfileError::InvalidRequest(String::from(
error_message,
))
}
"ResourceNotFoundException" => {
return UpdateUserRoutingProfileError::ResourceNotFound(String::from(
error_message,
))
}
"ThrottlingException" => {
return UpdateUserRoutingProfileError::Throttling(String::from(error_message))
}
"ValidationException" => {
return UpdateUserRoutingProfileError::Validation(error_message.to_string())
}
_ => {}
}
}
return UpdateUserRoutingProfileError::Unknown(res);
}
}
impl From<serde_json::error::Error> for UpdateUserRoutingProfileError {
fn from(err: serde_json::error::Error) -> UpdateUserRoutingProfileError {
UpdateUserRoutingProfileError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for UpdateUserRoutingProfileError {
fn from(err: CredentialsError) -> UpdateUserRoutingProfileError {
UpdateUserRoutingProfileError::Credentials(err)
}
}
impl From<HttpDispatchError> for UpdateUserRoutingProfileError {
fn from(err: HttpDispatchError) -> UpdateUserRoutingProfileError {
UpdateUserRoutingProfileError::HttpDispatch(err)
}
}
impl From<io::Error> for UpdateUserRoutingProfileError {
fn from(err: io::Error) -> UpdateUserRoutingProfileError {
UpdateUserRoutingProfileError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for UpdateUserRoutingProfileError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for UpdateUserRoutingProfileError {
fn description(&self) -> &str {
match *self {
UpdateUserRoutingProfileError::InternalService(ref cause) => cause,
UpdateUserRoutingProfileError::InvalidParameter(ref cause) => cause,
UpdateUserRoutingProfileError::InvalidRequest(ref cause) => cause,
UpdateUserRoutingProfileError::ResourceNotFound(ref cause) => cause,
UpdateUserRoutingProfileError::Throttling(ref cause) => cause,
UpdateUserRoutingProfileError::Validation(ref cause) => cause,
UpdateUserRoutingProfileError::Credentials(ref err) => err.description(),
UpdateUserRoutingProfileError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
UpdateUserRoutingProfileError::ParseError(ref cause) => cause,
UpdateUserRoutingProfileError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum UpdateUserSecurityProfilesError {
InternalService(String),
InvalidParameter(String),
InvalidRequest(String),
ResourceNotFound(String),
Throttling(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl UpdateUserSecurityProfilesError {
pub fn from_response(res: BufferedHttpResponse) -> UpdateUserSecurityProfilesError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InternalServiceException" => {
return UpdateUserSecurityProfilesError::InternalService(String::from(
error_message,
))
}
"InvalidParameterException" => {
return UpdateUserSecurityProfilesError::InvalidParameter(String::from(
error_message,
))
}
"InvalidRequestException" => {
return UpdateUserSecurityProfilesError::InvalidRequest(String::from(
error_message,
))
}
"ResourceNotFoundException" => {
return UpdateUserSecurityProfilesError::ResourceNotFound(String::from(
error_message,
))
}
"ThrottlingException" => {
return UpdateUserSecurityProfilesError::Throttling(String::from(error_message))
}
"ValidationException" => {
return UpdateUserSecurityProfilesError::Validation(error_message.to_string())
}
_ => {}
}
}
return UpdateUserSecurityProfilesError::Unknown(res);
}
}
impl From<serde_json::error::Error> for UpdateUserSecurityProfilesError {
fn from(err: serde_json::error::Error) -> UpdateUserSecurityProfilesError {
UpdateUserSecurityProfilesError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for UpdateUserSecurityProfilesError {
fn from(err: CredentialsError) -> UpdateUserSecurityProfilesError {
UpdateUserSecurityProfilesError::Credentials(err)
}
}
impl From<HttpDispatchError> for UpdateUserSecurityProfilesError {
fn from(err: HttpDispatchError) -> UpdateUserSecurityProfilesError {
UpdateUserSecurityProfilesError::HttpDispatch(err)
}
}
impl From<io::Error> for UpdateUserSecurityProfilesError {
fn from(err: io::Error) -> UpdateUserSecurityProfilesError {
UpdateUserSecurityProfilesError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for UpdateUserSecurityProfilesError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for UpdateUserSecurityProfilesError {
fn description(&self) -> &str {
match *self {
UpdateUserSecurityProfilesError::InternalService(ref cause) => cause,
UpdateUserSecurityProfilesError::InvalidParameter(ref cause) => cause,
UpdateUserSecurityProfilesError::InvalidRequest(ref cause) => cause,
UpdateUserSecurityProfilesError::ResourceNotFound(ref cause) => cause,
UpdateUserSecurityProfilesError::Throttling(ref cause) => cause,
UpdateUserSecurityProfilesError::Validation(ref cause) => cause,
UpdateUserSecurityProfilesError::Credentials(ref err) => err.description(),
UpdateUserSecurityProfilesError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
UpdateUserSecurityProfilesError::ParseError(ref cause) => cause,
UpdateUserSecurityProfilesError::Unknown(_) => "unknown error",
}
}
}
pub trait Connect {
fn create_user(
&self,
input: CreateUserRequest,
) -> RusotoFuture<CreateUserResponse, CreateUserError>;
fn delete_user(&self, input: DeleteUserRequest) -> RusotoFuture<(), DeleteUserError>;
fn describe_user(
&self,
input: DescribeUserRequest,
) -> RusotoFuture<DescribeUserResponse, DescribeUserError>;
fn describe_user_hierarchy_group(
&self,
input: DescribeUserHierarchyGroupRequest,
) -> RusotoFuture<DescribeUserHierarchyGroupResponse, DescribeUserHierarchyGroupError>;
fn describe_user_hierarchy_structure(
&self,
input: DescribeUserHierarchyStructureRequest,
) -> RusotoFuture<DescribeUserHierarchyStructureResponse, DescribeUserHierarchyStructureError>;
fn get_federation_token(
&self,
input: GetFederationTokenRequest,
) -> RusotoFuture<GetFederationTokenResponse, GetFederationTokenError>;
fn list_routing_profiles(
&self,
input: ListRoutingProfilesRequest,
) -> RusotoFuture<ListRoutingProfilesResponse, ListRoutingProfilesError>;
fn list_security_profiles(
&self,
input: ListSecurityProfilesRequest,
) -> RusotoFuture<ListSecurityProfilesResponse, ListSecurityProfilesError>;
fn list_user_hierarchy_groups(
&self,
input: ListUserHierarchyGroupsRequest,
) -> RusotoFuture<ListUserHierarchyGroupsResponse, ListUserHierarchyGroupsError>;
fn list_users(
&self,
input: ListUsersRequest,
) -> RusotoFuture<ListUsersResponse, ListUsersError>;
fn start_outbound_voice_contact(
&self,
input: StartOutboundVoiceContactRequest,
) -> RusotoFuture<StartOutboundVoiceContactResponse, StartOutboundVoiceContactError>;
fn stop_contact(
&self,
input: StopContactRequest,
) -> RusotoFuture<StopContactResponse, StopContactError>;
fn update_user_hierarchy(
&self,
input: UpdateUserHierarchyRequest,
) -> RusotoFuture<(), UpdateUserHierarchyError>;
fn update_user_identity_info(
&self,
input: UpdateUserIdentityInfoRequest,
) -> RusotoFuture<(), UpdateUserIdentityInfoError>;
fn update_user_phone_config(
&self,
input: UpdateUserPhoneConfigRequest,
) -> RusotoFuture<(), UpdateUserPhoneConfigError>;
fn update_user_routing_profile(
&self,
input: UpdateUserRoutingProfileRequest,
) -> RusotoFuture<(), UpdateUserRoutingProfileError>;
fn update_user_security_profiles(
&self,
input: UpdateUserSecurityProfilesRequest,
) -> RusotoFuture<(), UpdateUserSecurityProfilesError>;
}
pub struct ConnectClient {
client: Client,
region: region::Region,
}
impl ConnectClient {
pub fn new(region: region::Region) -> ConnectClient {
ConnectClient {
client: Client::shared(),
region: region,
}
}
pub fn new_with<P, D>(
request_dispatcher: D,
credentials_provider: P,
region: region::Region,
) -> ConnectClient
where
P: ProvideAwsCredentials + Send + Sync + 'static,
P::Future: Send,
D: DispatchSignedRequest + Send + Sync + 'static,
D::Future: Send,
{
ConnectClient {
client: Client::new_with(credentials_provider, request_dispatcher),
region: region,
}
}
}
impl Connect for ConnectClient {
fn create_user(
&self,
input: CreateUserRequest,
) -> RusotoFuture<CreateUserResponse, CreateUserError> {
let request_uri = format!("/users/{instance_id}", instance_id = input.instance_id);
let mut request = SignedRequest::new("PUT", "connect", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result = serde_json::from_slice::<CreateUserResponse>(&body).unwrap();
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(CreateUserError::from_response(response))),
)
}
})
}
fn delete_user(&self, input: DeleteUserRequest) -> RusotoFuture<(), DeleteUserError> {
let request_uri = format!(
"/users/{instance_id}/{user_id}",
instance_id = input.instance_id,
user_id = input.user_id
);
let mut request = SignedRequest::new("DELETE", "connect", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let result = ::std::mem::drop(response);
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DeleteUserError::from_response(response))),
)
}
})
}
fn describe_user(
&self,
input: DescribeUserRequest,
) -> RusotoFuture<DescribeUserResponse, DescribeUserError> {
let request_uri = format!(
"/users/{instance_id}/{user_id}",
instance_id = input.instance_id,
user_id = input.user_id
);
let mut request = SignedRequest::new("GET", "connect", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result = serde_json::from_slice::<DescribeUserResponse>(&body).unwrap();
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DescribeUserError::from_response(response))),
)
}
})
}
fn describe_user_hierarchy_group(
&self,
input: DescribeUserHierarchyGroupRequest,
) -> RusotoFuture<DescribeUserHierarchyGroupResponse, DescribeUserHierarchyGroupError> {
let request_uri = format!(
"/user-hierarchy-groups/{instance_id}/{hierarchy_group_id}",
hierarchy_group_id = input.hierarchy_group_id,
instance_id = input.instance_id
);
let mut request = SignedRequest::new("GET", "connect", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result =
serde_json::from_slice::<DescribeUserHierarchyGroupResponse>(&body)
.unwrap();
result
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(DescribeUserHierarchyGroupError::from_response(response))
}))
}
})
}
fn describe_user_hierarchy_structure(
&self,
input: DescribeUserHierarchyStructureRequest,
) -> RusotoFuture<DescribeUserHierarchyStructureResponse, DescribeUserHierarchyStructureError>
{
let request_uri = format!(
"/user-hierarchy-structure/{instance_id}",
instance_id = input.instance_id
);
let mut request = SignedRequest::new("GET", "connect", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result =
serde_json::from_slice::<DescribeUserHierarchyStructureResponse>(&body)
.unwrap();
result
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(DescribeUserHierarchyStructureError::from_response(response))
}))
}
})
}
fn get_federation_token(
&self,
input: GetFederationTokenRequest,
) -> RusotoFuture<GetFederationTokenResponse, GetFederationTokenError> {
let request_uri = format!(
"/user/federate/{instance_id}",
instance_id = input.instance_id
);
let mut request = SignedRequest::new("GET", "connect", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result =
serde_json::from_slice::<GetFederationTokenResponse>(&body).unwrap();
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(GetFederationTokenError::from_response(response))),
)
}
})
}
fn list_routing_profiles(
&self,
input: ListRoutingProfilesRequest,
) -> RusotoFuture<ListRoutingProfilesResponse, ListRoutingProfilesError> {
let request_uri = format!(
"/routing-profiles-summary/{instance_id}",
instance_id = input.instance_id
);
let mut request = SignedRequest::new("GET", "connect", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let mut params = Params::new();
if let Some(ref x) = input.max_results {
params.put("maxResults", x);
}
if let Some(ref x) = input.next_token {
params.put("nextToken", x);
}
request.set_params(params);
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result =
serde_json::from_slice::<ListRoutingProfilesResponse>(&body).unwrap();
result
}))
} else {
Box::new(
response.buffer().from_err().and_then(|response| {
Err(ListRoutingProfilesError::from_response(response))
}),
)
}
})
}
fn list_security_profiles(
&self,
input: ListSecurityProfilesRequest,
) -> RusotoFuture<ListSecurityProfilesResponse, ListSecurityProfilesError> {
let request_uri = format!(
"/security-profiles-summary/{instance_id}",
instance_id = input.instance_id
);
let mut request = SignedRequest::new("GET", "connect", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let mut params = Params::new();
if let Some(ref x) = input.max_results {
params.put("maxResults", x);
}
if let Some(ref x) = input.next_token {
params.put("nextToken", x);
}
request.set_params(params);
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result =
serde_json::from_slice::<ListSecurityProfilesResponse>(&body).unwrap();
result
}))
} else {
Box::new(
response.buffer().from_err().and_then(|response| {
Err(ListSecurityProfilesError::from_response(response))
}),
)
}
})
}
fn list_user_hierarchy_groups(
&self,
input: ListUserHierarchyGroupsRequest,
) -> RusotoFuture<ListUserHierarchyGroupsResponse, ListUserHierarchyGroupsError> {
let request_uri = format!(
"/user-hierarchy-groups-summary/{instance_id}",
instance_id = input.instance_id
);
let mut request = SignedRequest::new("GET", "connect", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let mut params = Params::new();
if let Some(ref x) = input.max_results {
params.put("maxResults", x);
}
if let Some(ref x) = input.next_token {
params.put("nextToken", x);
}
request.set_params(params);
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result =
serde_json::from_slice::<ListUserHierarchyGroupsResponse>(&body).unwrap();
result
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(ListUserHierarchyGroupsError::from_response(response))
}))
}
})
}
fn list_users(
&self,
input: ListUsersRequest,
) -> RusotoFuture<ListUsersResponse, ListUsersError> {
let request_uri = format!(
"/users-summary/{instance_id}",
instance_id = input.instance_id
);
let mut request = SignedRequest::new("GET", "connect", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let mut params = Params::new();
if let Some(ref x) = input.max_results {
params.put("maxResults", x);
}
if let Some(ref x) = input.next_token {
params.put("nextToken", x);
}
request.set_params(params);
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result = serde_json::from_slice::<ListUsersResponse>(&body).unwrap();
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(ListUsersError::from_response(response))),
)
}
})
}
fn start_outbound_voice_contact(
&self,
input: StartOutboundVoiceContactRequest,
) -> RusotoFuture<StartOutboundVoiceContactResponse, StartOutboundVoiceContactError> {
let request_uri = "/contact/outbound-voice";
let mut request = SignedRequest::new("PUT", "connect", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result =
serde_json::from_slice::<StartOutboundVoiceContactResponse>(&body).unwrap();
result
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(StartOutboundVoiceContactError::from_response(response))
}))
}
})
}
fn stop_contact(
&self,
input: StopContactRequest,
) -> RusotoFuture<StopContactResponse, StopContactError> {
let request_uri = "/contact/stop";
let mut request = SignedRequest::new("POST", "connect", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result = serde_json::from_slice::<StopContactResponse>(&body).unwrap();
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(StopContactError::from_response(response))),
)
}
})
}
fn update_user_hierarchy(
&self,
input: UpdateUserHierarchyRequest,
) -> RusotoFuture<(), UpdateUserHierarchyError> {
let request_uri = format!(
"/users/{instance_id}/{user_id}/hierarchy",
instance_id = input.instance_id,
user_id = input.user_id
);
let mut request = SignedRequest::new("POST", "connect", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let result = ::std::mem::drop(response);
result
}))
} else {
Box::new(
response.buffer().from_err().and_then(|response| {
Err(UpdateUserHierarchyError::from_response(response))
}),
)
}
})
}
fn update_user_identity_info(
&self,
input: UpdateUserIdentityInfoRequest,
) -> RusotoFuture<(), UpdateUserIdentityInfoError> {
let request_uri = format!(
"/users/{instance_id}/{user_id}/identity-info",
instance_id = input.instance_id,
user_id = input.user_id
);
let mut request = SignedRequest::new("POST", "connect", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let result = ::std::mem::drop(response);
result
}))
} else {
Box::new(
response.buffer().from_err().and_then(|response| {
Err(UpdateUserIdentityInfoError::from_response(response))
}),
)
}
})
}
fn update_user_phone_config(
&self,
input: UpdateUserPhoneConfigRequest,
) -> RusotoFuture<(), UpdateUserPhoneConfigError> {
let request_uri = format!(
"/users/{instance_id}/{user_id}/phone-config",
instance_id = input.instance_id,
user_id = input.user_id
);
let mut request = SignedRequest::new("POST", "connect", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let result = ::std::mem::drop(response);
result
}))
} else {
Box::new(
response.buffer().from_err().and_then(|response| {
Err(UpdateUserPhoneConfigError::from_response(response))
}),
)
}
})
}
fn update_user_routing_profile(
&self,
input: UpdateUserRoutingProfileRequest,
) -> RusotoFuture<(), UpdateUserRoutingProfileError> {
let request_uri = format!(
"/users/{instance_id}/{user_id}/routing-profile",
instance_id = input.instance_id,
user_id = input.user_id
);
let mut request = SignedRequest::new("POST", "connect", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let result = ::std::mem::drop(response);
result
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(UpdateUserRoutingProfileError::from_response(response))
}))
}
})
}
fn update_user_security_profiles(
&self,
input: UpdateUserSecurityProfilesRequest,
) -> RusotoFuture<(), UpdateUserSecurityProfilesError> {
let request_uri = format!(
"/users/{instance_id}/{user_id}/security-profiles",
instance_id = input.instance_id,
user_id = input.user_id
);
let mut request = SignedRequest::new("POST", "connect", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let result = ::std::mem::drop(response);
result
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(UpdateUserSecurityProfilesError::from_response(response))
}))
}
})
}
}
#[cfg(test)]
mod protocol_tests {}