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::signature::SignedRequest;
use serde_json;
use serde_json::from_slice;
use serde_json::Value as SerdeJsonValue;
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct AssociateDRTLogBucketRequest {
#[serde(rename = "LogBucket")]
pub log_bucket: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct AssociateDRTLogBucketResponse {}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct AssociateDRTRoleRequest {
#[serde(rename = "RoleArn")]
pub role_arn: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct AssociateDRTRoleResponse {}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct AttackDetail {
#[serde(rename = "AttackCounters")]
#[serde(skip_serializing_if = "Option::is_none")]
pub attack_counters: Option<Vec<SummarizedCounter>>,
#[serde(rename = "AttackId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub attack_id: Option<String>,
#[serde(rename = "AttackProperties")]
#[serde(skip_serializing_if = "Option::is_none")]
pub attack_properties: Option<Vec<AttackProperty>>,
#[serde(rename = "EndTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub end_time: Option<f64>,
#[serde(rename = "Mitigations")]
#[serde(skip_serializing_if = "Option::is_none")]
pub mitigations: Option<Vec<Mitigation>>,
#[serde(rename = "ResourceArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub resource_arn: Option<String>,
#[serde(rename = "StartTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub start_time: Option<f64>,
#[serde(rename = "SubResources")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sub_resources: Option<Vec<SubResourceSummary>>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct AttackProperty {
#[serde(rename = "AttackLayer")]
#[serde(skip_serializing_if = "Option::is_none")]
pub attack_layer: Option<String>,
#[serde(rename = "AttackPropertyIdentifier")]
#[serde(skip_serializing_if = "Option::is_none")]
pub attack_property_identifier: Option<String>,
#[serde(rename = "TopContributors")]
#[serde(skip_serializing_if = "Option::is_none")]
pub top_contributors: Option<Vec<Contributor>>,
#[serde(rename = "Total")]
#[serde(skip_serializing_if = "Option::is_none")]
pub total: Option<i64>,
#[serde(rename = "Unit")]
#[serde(skip_serializing_if = "Option::is_none")]
pub unit: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct AttackSummary {
#[serde(rename = "AttackId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub attack_id: Option<String>,
#[serde(rename = "AttackVectors")]
#[serde(skip_serializing_if = "Option::is_none")]
pub attack_vectors: Option<Vec<AttackVectorDescription>>,
#[serde(rename = "EndTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub end_time: Option<f64>,
#[serde(rename = "ResourceArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub resource_arn: Option<String>,
#[serde(rename = "StartTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub start_time: Option<f64>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct AttackVectorDescription {
#[serde(rename = "VectorType")]
pub vector_type: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct Contributor {
#[serde(rename = "Name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(rename = "Value")]
#[serde(skip_serializing_if = "Option::is_none")]
pub value: Option<i64>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct CreateProtectionRequest {
#[serde(rename = "Name")]
pub name: String,
#[serde(rename = "ResourceArn")]
pub resource_arn: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct CreateProtectionResponse {
#[serde(rename = "ProtectionId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub protection_id: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct CreateSubscriptionRequest {}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct CreateSubscriptionResponse {}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DeleteProtectionRequest {
#[serde(rename = "ProtectionId")]
pub protection_id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DeleteProtectionResponse {}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DeleteSubscriptionRequest {}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DeleteSubscriptionResponse {}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DescribeAttackRequest {
#[serde(rename = "AttackId")]
pub attack_id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DescribeAttackResponse {
#[serde(rename = "Attack")]
#[serde(skip_serializing_if = "Option::is_none")]
pub attack: Option<AttackDetail>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DescribeDRTAccessRequest {}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DescribeDRTAccessResponse {
#[serde(rename = "LogBucketList")]
#[serde(skip_serializing_if = "Option::is_none")]
pub log_bucket_list: Option<Vec<String>>,
#[serde(rename = "RoleArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub role_arn: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DescribeEmergencyContactSettingsRequest {}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DescribeEmergencyContactSettingsResponse {
#[serde(rename = "EmergencyContactList")]
#[serde(skip_serializing_if = "Option::is_none")]
pub emergency_contact_list: Option<Vec<EmergencyContact>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DescribeProtectionRequest {
#[serde(rename = "ProtectionId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub protection_id: Option<String>,
#[serde(rename = "ResourceArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub resource_arn: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DescribeProtectionResponse {
#[serde(rename = "Protection")]
#[serde(skip_serializing_if = "Option::is_none")]
pub protection: Option<Protection>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DescribeSubscriptionRequest {}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DescribeSubscriptionResponse {
#[serde(rename = "Subscription")]
#[serde(skip_serializing_if = "Option::is_none")]
pub subscription: Option<Subscription>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DisassociateDRTLogBucketRequest {
#[serde(rename = "LogBucket")]
pub log_bucket: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DisassociateDRTLogBucketResponse {}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DisassociateDRTRoleRequest {}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DisassociateDRTRoleResponse {}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct EmergencyContact {
#[serde(rename = "EmailAddress")]
pub email_address: String,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct GetSubscriptionStateRequest {}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct GetSubscriptionStateResponse {
#[serde(rename = "SubscriptionState")]
pub subscription_state: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct Limit {
#[serde(rename = "Max")]
#[serde(skip_serializing_if = "Option::is_none")]
pub max: Option<i64>,
#[serde(rename = "Type")]
#[serde(skip_serializing_if = "Option::is_none")]
pub type_: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct ListAttacksRequest {
#[serde(rename = "EndTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub end_time: Option<TimeRange>,
#[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>,
#[serde(rename = "ResourceArns")]
#[serde(skip_serializing_if = "Option::is_none")]
pub resource_arns: Option<Vec<String>>,
#[serde(rename = "StartTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub start_time: Option<TimeRange>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct ListAttacksResponse {
#[serde(rename = "AttackSummaries")]
#[serde(skip_serializing_if = "Option::is_none")]
pub attack_summaries: Option<Vec<AttackSummary>>,
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct ListProtectionsRequest {
#[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 ListProtectionsResponse {
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
#[serde(rename = "Protections")]
#[serde(skip_serializing_if = "Option::is_none")]
pub protections: Option<Vec<Protection>>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct Mitigation {
#[serde(rename = "MitigationName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub mitigation_name: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct Protection {
#[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>,
#[serde(rename = "ResourceArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub resource_arn: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct SubResourceSummary {
#[serde(rename = "AttackVectors")]
#[serde(skip_serializing_if = "Option::is_none")]
pub attack_vectors: Option<Vec<SummarizedAttackVector>>,
#[serde(rename = "Counters")]
#[serde(skip_serializing_if = "Option::is_none")]
pub counters: Option<Vec<SummarizedCounter>>,
#[serde(rename = "Id")]
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
#[serde(rename = "Type")]
#[serde(skip_serializing_if = "Option::is_none")]
pub type_: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct Subscription {
#[serde(rename = "AutoRenew")]
#[serde(skip_serializing_if = "Option::is_none")]
pub auto_renew: Option<String>,
#[serde(rename = "EndTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub end_time: Option<f64>,
#[serde(rename = "Limits")]
#[serde(skip_serializing_if = "Option::is_none")]
pub limits: Option<Vec<Limit>>,
#[serde(rename = "StartTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub start_time: Option<f64>,
#[serde(rename = "TimeCommitmentInSeconds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub time_commitment_in_seconds: Option<i64>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct SummarizedAttackVector {
#[serde(rename = "VectorCounters")]
#[serde(skip_serializing_if = "Option::is_none")]
pub vector_counters: Option<Vec<SummarizedCounter>>,
#[serde(rename = "VectorType")]
pub vector_type: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct SummarizedCounter {
#[serde(rename = "Average")]
#[serde(skip_serializing_if = "Option::is_none")]
pub average: Option<f64>,
#[serde(rename = "Max")]
#[serde(skip_serializing_if = "Option::is_none")]
pub max: Option<f64>,
#[serde(rename = "N")]
#[serde(skip_serializing_if = "Option::is_none")]
pub n: Option<i64>,
#[serde(rename = "Name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(rename = "Sum")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sum: Option<f64>,
#[serde(rename = "Unit")]
#[serde(skip_serializing_if = "Option::is_none")]
pub unit: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct TimeRange {
#[serde(rename = "FromInclusive")]
#[serde(skip_serializing_if = "Option::is_none")]
pub from_inclusive: Option<f64>,
#[serde(rename = "ToExclusive")]
#[serde(skip_serializing_if = "Option::is_none")]
pub to_exclusive: Option<f64>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct UpdateEmergencyContactSettingsRequest {
#[serde(rename = "EmergencyContactList")]
#[serde(skip_serializing_if = "Option::is_none")]
pub emergency_contact_list: Option<Vec<EmergencyContact>>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct UpdateEmergencyContactSettingsResponse {}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct UpdateSubscriptionRequest {
#[serde(rename = "AutoRenew")]
#[serde(skip_serializing_if = "Option::is_none")]
pub auto_renew: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct UpdateSubscriptionResponse {}
#[derive(Debug, PartialEq)]
pub enum AssociateDRTLogBucketError {
AccessDeniedForDependency(String),
InternalError(String),
InvalidOperation(String),
InvalidParameter(String),
LimitsExceeded(String),
NoAssociatedRole(String),
OptimisticLock(String),
ResourceNotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl AssociateDRTLogBucketError {
pub fn from_response(res: BufferedHttpResponse) -> AssociateDRTLogBucketError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"AccessDeniedForDependencyException" => {
return AssociateDRTLogBucketError::AccessDeniedForDependency(String::from(
error_message,
));
}
"InternalErrorException" => {
return AssociateDRTLogBucketError::InternalError(String::from(error_message));
}
"InvalidOperationException" => {
return AssociateDRTLogBucketError::InvalidOperation(String::from(error_message));
}
"InvalidParameterException" => {
return AssociateDRTLogBucketError::InvalidParameter(String::from(error_message));
}
"LimitsExceededException" => {
return AssociateDRTLogBucketError::LimitsExceeded(String::from(error_message));
}
"NoAssociatedRoleException" => {
return AssociateDRTLogBucketError::NoAssociatedRole(String::from(error_message));
}
"OptimisticLockException" => {
return AssociateDRTLogBucketError::OptimisticLock(String::from(error_message));
}
"ResourceNotFoundException" => {
return AssociateDRTLogBucketError::ResourceNotFound(String::from(error_message));
}
"ValidationException" => {
return AssociateDRTLogBucketError::Validation(error_message.to_string());
}
_ => {}
}
}
return AssociateDRTLogBucketError::Unknown(res);
}
}
impl From<serde_json::error::Error> for AssociateDRTLogBucketError {
fn from(err: serde_json::error::Error) -> AssociateDRTLogBucketError {
AssociateDRTLogBucketError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for AssociateDRTLogBucketError {
fn from(err: CredentialsError) -> AssociateDRTLogBucketError {
AssociateDRTLogBucketError::Credentials(err)
}
}
impl From<HttpDispatchError> for AssociateDRTLogBucketError {
fn from(err: HttpDispatchError) -> AssociateDRTLogBucketError {
AssociateDRTLogBucketError::HttpDispatch(err)
}
}
impl From<io::Error> for AssociateDRTLogBucketError {
fn from(err: io::Error) -> AssociateDRTLogBucketError {
AssociateDRTLogBucketError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for AssociateDRTLogBucketError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for AssociateDRTLogBucketError {
fn description(&self) -> &str {
match *self {
AssociateDRTLogBucketError::AccessDeniedForDependency(ref cause) => cause,
AssociateDRTLogBucketError::InternalError(ref cause) => cause,
AssociateDRTLogBucketError::InvalidOperation(ref cause) => cause,
AssociateDRTLogBucketError::InvalidParameter(ref cause) => cause,
AssociateDRTLogBucketError::LimitsExceeded(ref cause) => cause,
AssociateDRTLogBucketError::NoAssociatedRole(ref cause) => cause,
AssociateDRTLogBucketError::OptimisticLock(ref cause) => cause,
AssociateDRTLogBucketError::ResourceNotFound(ref cause) => cause,
AssociateDRTLogBucketError::Validation(ref cause) => cause,
AssociateDRTLogBucketError::Credentials(ref err) => err.description(),
AssociateDRTLogBucketError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
AssociateDRTLogBucketError::ParseError(ref cause) => cause,
AssociateDRTLogBucketError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum AssociateDRTRoleError {
AccessDeniedForDependency(String),
InternalError(String),
InvalidOperation(String),
InvalidParameter(String),
OptimisticLock(String),
ResourceNotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl AssociateDRTRoleError {
pub fn from_response(res: BufferedHttpResponse) -> AssociateDRTRoleError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"AccessDeniedForDependencyException" => {
return AssociateDRTRoleError::AccessDeniedForDependency(String::from(
error_message,
));
}
"InternalErrorException" => {
return AssociateDRTRoleError::InternalError(String::from(error_message));
}
"InvalidOperationException" => {
return AssociateDRTRoleError::InvalidOperation(String::from(error_message));
}
"InvalidParameterException" => {
return AssociateDRTRoleError::InvalidParameter(String::from(error_message));
}
"OptimisticLockException" => {
return AssociateDRTRoleError::OptimisticLock(String::from(error_message));
}
"ResourceNotFoundException" => {
return AssociateDRTRoleError::ResourceNotFound(String::from(error_message));
}
"ValidationException" => {
return AssociateDRTRoleError::Validation(error_message.to_string());
}
_ => {}
}
}
return AssociateDRTRoleError::Unknown(res);
}
}
impl From<serde_json::error::Error> for AssociateDRTRoleError {
fn from(err: serde_json::error::Error) -> AssociateDRTRoleError {
AssociateDRTRoleError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for AssociateDRTRoleError {
fn from(err: CredentialsError) -> AssociateDRTRoleError {
AssociateDRTRoleError::Credentials(err)
}
}
impl From<HttpDispatchError> for AssociateDRTRoleError {
fn from(err: HttpDispatchError) -> AssociateDRTRoleError {
AssociateDRTRoleError::HttpDispatch(err)
}
}
impl From<io::Error> for AssociateDRTRoleError {
fn from(err: io::Error) -> AssociateDRTRoleError {
AssociateDRTRoleError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for AssociateDRTRoleError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for AssociateDRTRoleError {
fn description(&self) -> &str {
match *self {
AssociateDRTRoleError::AccessDeniedForDependency(ref cause) => cause,
AssociateDRTRoleError::InternalError(ref cause) => cause,
AssociateDRTRoleError::InvalidOperation(ref cause) => cause,
AssociateDRTRoleError::InvalidParameter(ref cause) => cause,
AssociateDRTRoleError::OptimisticLock(ref cause) => cause,
AssociateDRTRoleError::ResourceNotFound(ref cause) => cause,
AssociateDRTRoleError::Validation(ref cause) => cause,
AssociateDRTRoleError::Credentials(ref err) => err.description(),
AssociateDRTRoleError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
AssociateDRTRoleError::ParseError(ref cause) => cause,
AssociateDRTRoleError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum CreateProtectionError {
InternalError(String),
InvalidOperation(String),
InvalidResource(String),
LimitsExceeded(String),
OptimisticLock(String),
ResourceAlreadyExists(String),
ResourceNotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl CreateProtectionError {
pub fn from_response(res: BufferedHttpResponse) -> CreateProtectionError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"InternalErrorException" => {
return CreateProtectionError::InternalError(String::from(error_message));
}
"InvalidOperationException" => {
return CreateProtectionError::InvalidOperation(String::from(error_message));
}
"InvalidResourceException" => {
return CreateProtectionError::InvalidResource(String::from(error_message));
}
"LimitsExceededException" => {
return CreateProtectionError::LimitsExceeded(String::from(error_message));
}
"OptimisticLockException" => {
return CreateProtectionError::OptimisticLock(String::from(error_message));
}
"ResourceAlreadyExistsException" => {
return CreateProtectionError::ResourceAlreadyExists(String::from(error_message));
}
"ResourceNotFoundException" => {
return CreateProtectionError::ResourceNotFound(String::from(error_message));
}
"ValidationException" => {
return CreateProtectionError::Validation(error_message.to_string());
}
_ => {}
}
}
return CreateProtectionError::Unknown(res);
}
}
impl From<serde_json::error::Error> for CreateProtectionError {
fn from(err: serde_json::error::Error) -> CreateProtectionError {
CreateProtectionError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for CreateProtectionError {
fn from(err: CredentialsError) -> CreateProtectionError {
CreateProtectionError::Credentials(err)
}
}
impl From<HttpDispatchError> for CreateProtectionError {
fn from(err: HttpDispatchError) -> CreateProtectionError {
CreateProtectionError::HttpDispatch(err)
}
}
impl From<io::Error> for CreateProtectionError {
fn from(err: io::Error) -> CreateProtectionError {
CreateProtectionError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for CreateProtectionError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for CreateProtectionError {
fn description(&self) -> &str {
match *self {
CreateProtectionError::InternalError(ref cause) => cause,
CreateProtectionError::InvalidOperation(ref cause) => cause,
CreateProtectionError::InvalidResource(ref cause) => cause,
CreateProtectionError::LimitsExceeded(ref cause) => cause,
CreateProtectionError::OptimisticLock(ref cause) => cause,
CreateProtectionError::ResourceAlreadyExists(ref cause) => cause,
CreateProtectionError::ResourceNotFound(ref cause) => cause,
CreateProtectionError::Validation(ref cause) => cause,
CreateProtectionError::Credentials(ref err) => err.description(),
CreateProtectionError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
CreateProtectionError::ParseError(ref cause) => cause,
CreateProtectionError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum CreateSubscriptionError {
InternalError(String),
ResourceAlreadyExists(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl CreateSubscriptionError {
pub fn from_response(res: BufferedHttpResponse) -> CreateSubscriptionError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"InternalErrorException" => {
return CreateSubscriptionError::InternalError(String::from(error_message));
}
"ResourceAlreadyExistsException" => {
return CreateSubscriptionError::ResourceAlreadyExists(String::from(
error_message,
));
}
"ValidationException" => {
return CreateSubscriptionError::Validation(error_message.to_string());
}
_ => {}
}
}
return CreateSubscriptionError::Unknown(res);
}
}
impl From<serde_json::error::Error> for CreateSubscriptionError {
fn from(err: serde_json::error::Error) -> CreateSubscriptionError {
CreateSubscriptionError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for CreateSubscriptionError {
fn from(err: CredentialsError) -> CreateSubscriptionError {
CreateSubscriptionError::Credentials(err)
}
}
impl From<HttpDispatchError> for CreateSubscriptionError {
fn from(err: HttpDispatchError) -> CreateSubscriptionError {
CreateSubscriptionError::HttpDispatch(err)
}
}
impl From<io::Error> for CreateSubscriptionError {
fn from(err: io::Error) -> CreateSubscriptionError {
CreateSubscriptionError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for CreateSubscriptionError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for CreateSubscriptionError {
fn description(&self) -> &str {
match *self {
CreateSubscriptionError::InternalError(ref cause) => cause,
CreateSubscriptionError::ResourceAlreadyExists(ref cause) => cause,
CreateSubscriptionError::Validation(ref cause) => cause,
CreateSubscriptionError::Credentials(ref err) => err.description(),
CreateSubscriptionError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
CreateSubscriptionError::ParseError(ref cause) => cause,
CreateSubscriptionError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DeleteProtectionError {
InternalError(String),
OptimisticLock(String),
ResourceNotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DeleteProtectionError {
pub fn from_response(res: BufferedHttpResponse) -> DeleteProtectionError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"InternalErrorException" => {
return DeleteProtectionError::InternalError(String::from(error_message));
}
"OptimisticLockException" => {
return DeleteProtectionError::OptimisticLock(String::from(error_message));
}
"ResourceNotFoundException" => {
return DeleteProtectionError::ResourceNotFound(String::from(error_message));
}
"ValidationException" => {
return DeleteProtectionError::Validation(error_message.to_string());
}
_ => {}
}
}
return DeleteProtectionError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DeleteProtectionError {
fn from(err: serde_json::error::Error) -> DeleteProtectionError {
DeleteProtectionError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DeleteProtectionError {
fn from(err: CredentialsError) -> DeleteProtectionError {
DeleteProtectionError::Credentials(err)
}
}
impl From<HttpDispatchError> for DeleteProtectionError {
fn from(err: HttpDispatchError) -> DeleteProtectionError {
DeleteProtectionError::HttpDispatch(err)
}
}
impl From<io::Error> for DeleteProtectionError {
fn from(err: io::Error) -> DeleteProtectionError {
DeleteProtectionError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DeleteProtectionError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DeleteProtectionError {
fn description(&self) -> &str {
match *self {
DeleteProtectionError::InternalError(ref cause) => cause,
DeleteProtectionError::OptimisticLock(ref cause) => cause,
DeleteProtectionError::ResourceNotFound(ref cause) => cause,
DeleteProtectionError::Validation(ref cause) => cause,
DeleteProtectionError::Credentials(ref err) => err.description(),
DeleteProtectionError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
DeleteProtectionError::ParseError(ref cause) => cause,
DeleteProtectionError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DeleteSubscriptionError {
InternalError(String),
LockedSubscription(String),
ResourceNotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DeleteSubscriptionError {
pub fn from_response(res: BufferedHttpResponse) -> DeleteSubscriptionError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"InternalErrorException" => {
return DeleteSubscriptionError::InternalError(String::from(error_message));
}
"LockedSubscriptionException" => {
return DeleteSubscriptionError::LockedSubscription(String::from(error_message));
}
"ResourceNotFoundException" => {
return DeleteSubscriptionError::ResourceNotFound(String::from(error_message));
}
"ValidationException" => {
return DeleteSubscriptionError::Validation(error_message.to_string());
}
_ => {}
}
}
return DeleteSubscriptionError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DeleteSubscriptionError {
fn from(err: serde_json::error::Error) -> DeleteSubscriptionError {
DeleteSubscriptionError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DeleteSubscriptionError {
fn from(err: CredentialsError) -> DeleteSubscriptionError {
DeleteSubscriptionError::Credentials(err)
}
}
impl From<HttpDispatchError> for DeleteSubscriptionError {
fn from(err: HttpDispatchError) -> DeleteSubscriptionError {
DeleteSubscriptionError::HttpDispatch(err)
}
}
impl From<io::Error> for DeleteSubscriptionError {
fn from(err: io::Error) -> DeleteSubscriptionError {
DeleteSubscriptionError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DeleteSubscriptionError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DeleteSubscriptionError {
fn description(&self) -> &str {
match *self {
DeleteSubscriptionError::InternalError(ref cause) => cause,
DeleteSubscriptionError::LockedSubscription(ref cause) => cause,
DeleteSubscriptionError::ResourceNotFound(ref cause) => cause,
DeleteSubscriptionError::Validation(ref cause) => cause,
DeleteSubscriptionError::Credentials(ref err) => err.description(),
DeleteSubscriptionError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
DeleteSubscriptionError::ParseError(ref cause) => cause,
DeleteSubscriptionError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DescribeAttackError {
AccessDenied(String),
InternalError(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DescribeAttackError {
pub fn from_response(res: BufferedHttpResponse) -> DescribeAttackError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"AccessDeniedException" => {
return DescribeAttackError::AccessDenied(String::from(error_message));
}
"InternalErrorException" => {
return DescribeAttackError::InternalError(String::from(error_message));
}
"ValidationException" => {
return DescribeAttackError::Validation(error_message.to_string());
}
_ => {}
}
}
return DescribeAttackError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DescribeAttackError {
fn from(err: serde_json::error::Error) -> DescribeAttackError {
DescribeAttackError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DescribeAttackError {
fn from(err: CredentialsError) -> DescribeAttackError {
DescribeAttackError::Credentials(err)
}
}
impl From<HttpDispatchError> for DescribeAttackError {
fn from(err: HttpDispatchError) -> DescribeAttackError {
DescribeAttackError::HttpDispatch(err)
}
}
impl From<io::Error> for DescribeAttackError {
fn from(err: io::Error) -> DescribeAttackError {
DescribeAttackError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DescribeAttackError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DescribeAttackError {
fn description(&self) -> &str {
match *self {
DescribeAttackError::AccessDenied(ref cause) => cause,
DescribeAttackError::InternalError(ref cause) => cause,
DescribeAttackError::Validation(ref cause) => cause,
DescribeAttackError::Credentials(ref err) => err.description(),
DescribeAttackError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
DescribeAttackError::ParseError(ref cause) => cause,
DescribeAttackError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DescribeDRTAccessError {
InternalError(String),
ResourceNotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DescribeDRTAccessError {
pub fn from_response(res: BufferedHttpResponse) -> DescribeDRTAccessError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"InternalErrorException" => {
return DescribeDRTAccessError::InternalError(String::from(error_message));
}
"ResourceNotFoundException" => {
return DescribeDRTAccessError::ResourceNotFound(String::from(error_message));
}
"ValidationException" => {
return DescribeDRTAccessError::Validation(error_message.to_string());
}
_ => {}
}
}
return DescribeDRTAccessError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DescribeDRTAccessError {
fn from(err: serde_json::error::Error) -> DescribeDRTAccessError {
DescribeDRTAccessError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DescribeDRTAccessError {
fn from(err: CredentialsError) -> DescribeDRTAccessError {
DescribeDRTAccessError::Credentials(err)
}
}
impl From<HttpDispatchError> for DescribeDRTAccessError {
fn from(err: HttpDispatchError) -> DescribeDRTAccessError {
DescribeDRTAccessError::HttpDispatch(err)
}
}
impl From<io::Error> for DescribeDRTAccessError {
fn from(err: io::Error) -> DescribeDRTAccessError {
DescribeDRTAccessError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DescribeDRTAccessError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DescribeDRTAccessError {
fn description(&self) -> &str {
match *self {
DescribeDRTAccessError::InternalError(ref cause) => cause,
DescribeDRTAccessError::ResourceNotFound(ref cause) => cause,
DescribeDRTAccessError::Validation(ref cause) => cause,
DescribeDRTAccessError::Credentials(ref err) => err.description(),
DescribeDRTAccessError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
DescribeDRTAccessError::ParseError(ref cause) => cause,
DescribeDRTAccessError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DescribeEmergencyContactSettingsError {
InternalError(String),
ResourceNotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DescribeEmergencyContactSettingsError {
pub fn from_response(res: BufferedHttpResponse) -> DescribeEmergencyContactSettingsError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"InternalErrorException" => {
return DescribeEmergencyContactSettingsError::InternalError(String::from(
error_message,
));
}
"ResourceNotFoundException" => {
return DescribeEmergencyContactSettingsError::ResourceNotFound(String::from(
error_message,
));
}
"ValidationException" => {
return DescribeEmergencyContactSettingsError::Validation(
error_message.to_string(),
);
}
_ => {}
}
}
return DescribeEmergencyContactSettingsError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DescribeEmergencyContactSettingsError {
fn from(err: serde_json::error::Error) -> DescribeEmergencyContactSettingsError {
DescribeEmergencyContactSettingsError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DescribeEmergencyContactSettingsError {
fn from(err: CredentialsError) -> DescribeEmergencyContactSettingsError {
DescribeEmergencyContactSettingsError::Credentials(err)
}
}
impl From<HttpDispatchError> for DescribeEmergencyContactSettingsError {
fn from(err: HttpDispatchError) -> DescribeEmergencyContactSettingsError {
DescribeEmergencyContactSettingsError::HttpDispatch(err)
}
}
impl From<io::Error> for DescribeEmergencyContactSettingsError {
fn from(err: io::Error) -> DescribeEmergencyContactSettingsError {
DescribeEmergencyContactSettingsError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DescribeEmergencyContactSettingsError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DescribeEmergencyContactSettingsError {
fn description(&self) -> &str {
match *self {
DescribeEmergencyContactSettingsError::InternalError(ref cause) => cause,
DescribeEmergencyContactSettingsError::ResourceNotFound(ref cause) => cause,
DescribeEmergencyContactSettingsError::Validation(ref cause) => cause,
DescribeEmergencyContactSettingsError::Credentials(ref err) => err.description(),
DescribeEmergencyContactSettingsError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
DescribeEmergencyContactSettingsError::ParseError(ref cause) => cause,
DescribeEmergencyContactSettingsError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DescribeProtectionError {
InternalError(String),
InvalidParameter(String),
ResourceNotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DescribeProtectionError {
pub fn from_response(res: BufferedHttpResponse) -> DescribeProtectionError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"InternalErrorException" => {
return DescribeProtectionError::InternalError(String::from(error_message));
}
"InvalidParameterException" => {
return DescribeProtectionError::InvalidParameter(String::from(error_message));
}
"ResourceNotFoundException" => {
return DescribeProtectionError::ResourceNotFound(String::from(error_message));
}
"ValidationException" => {
return DescribeProtectionError::Validation(error_message.to_string());
}
_ => {}
}
}
return DescribeProtectionError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DescribeProtectionError {
fn from(err: serde_json::error::Error) -> DescribeProtectionError {
DescribeProtectionError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DescribeProtectionError {
fn from(err: CredentialsError) -> DescribeProtectionError {
DescribeProtectionError::Credentials(err)
}
}
impl From<HttpDispatchError> for DescribeProtectionError {
fn from(err: HttpDispatchError) -> DescribeProtectionError {
DescribeProtectionError::HttpDispatch(err)
}
}
impl From<io::Error> for DescribeProtectionError {
fn from(err: io::Error) -> DescribeProtectionError {
DescribeProtectionError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DescribeProtectionError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DescribeProtectionError {
fn description(&self) -> &str {
match *self {
DescribeProtectionError::InternalError(ref cause) => cause,
DescribeProtectionError::InvalidParameter(ref cause) => cause,
DescribeProtectionError::ResourceNotFound(ref cause) => cause,
DescribeProtectionError::Validation(ref cause) => cause,
DescribeProtectionError::Credentials(ref err) => err.description(),
DescribeProtectionError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
DescribeProtectionError::ParseError(ref cause) => cause,
DescribeProtectionError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DescribeSubscriptionError {
InternalError(String),
ResourceNotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DescribeSubscriptionError {
pub fn from_response(res: BufferedHttpResponse) -> DescribeSubscriptionError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"InternalErrorException" => {
return DescribeSubscriptionError::InternalError(String::from(error_message));
}
"ResourceNotFoundException" => {
return DescribeSubscriptionError::ResourceNotFound(String::from(error_message));
}
"ValidationException" => {
return DescribeSubscriptionError::Validation(error_message.to_string());
}
_ => {}
}
}
return DescribeSubscriptionError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DescribeSubscriptionError {
fn from(err: serde_json::error::Error) -> DescribeSubscriptionError {
DescribeSubscriptionError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DescribeSubscriptionError {
fn from(err: CredentialsError) -> DescribeSubscriptionError {
DescribeSubscriptionError::Credentials(err)
}
}
impl From<HttpDispatchError> for DescribeSubscriptionError {
fn from(err: HttpDispatchError) -> DescribeSubscriptionError {
DescribeSubscriptionError::HttpDispatch(err)
}
}
impl From<io::Error> for DescribeSubscriptionError {
fn from(err: io::Error) -> DescribeSubscriptionError {
DescribeSubscriptionError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DescribeSubscriptionError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DescribeSubscriptionError {
fn description(&self) -> &str {
match *self {
DescribeSubscriptionError::InternalError(ref cause) => cause,
DescribeSubscriptionError::ResourceNotFound(ref cause) => cause,
DescribeSubscriptionError::Validation(ref cause) => cause,
DescribeSubscriptionError::Credentials(ref err) => err.description(),
DescribeSubscriptionError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
DescribeSubscriptionError::ParseError(ref cause) => cause,
DescribeSubscriptionError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DisassociateDRTLogBucketError {
AccessDeniedForDependency(String),
InternalError(String),
InvalidOperation(String),
NoAssociatedRole(String),
OptimisticLock(String),
ResourceNotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DisassociateDRTLogBucketError {
pub fn from_response(res: BufferedHttpResponse) -> DisassociateDRTLogBucketError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"AccessDeniedForDependencyException" => {
return DisassociateDRTLogBucketError::AccessDeniedForDependency(String::from(
error_message,
));
}
"InternalErrorException" => {
return DisassociateDRTLogBucketError::InternalError(String::from(error_message));
}
"InvalidOperationException" => {
return DisassociateDRTLogBucketError::InvalidOperation(String::from(
error_message,
));
}
"NoAssociatedRoleException" => {
return DisassociateDRTLogBucketError::NoAssociatedRole(String::from(
error_message,
));
}
"OptimisticLockException" => {
return DisassociateDRTLogBucketError::OptimisticLock(String::from(
error_message,
));
}
"ResourceNotFoundException" => {
return DisassociateDRTLogBucketError::ResourceNotFound(String::from(
error_message,
));
}
"ValidationException" => {
return DisassociateDRTLogBucketError::Validation(error_message.to_string());
}
_ => {}
}
}
return DisassociateDRTLogBucketError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DisassociateDRTLogBucketError {
fn from(err: serde_json::error::Error) -> DisassociateDRTLogBucketError {
DisassociateDRTLogBucketError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DisassociateDRTLogBucketError {
fn from(err: CredentialsError) -> DisassociateDRTLogBucketError {
DisassociateDRTLogBucketError::Credentials(err)
}
}
impl From<HttpDispatchError> for DisassociateDRTLogBucketError {
fn from(err: HttpDispatchError) -> DisassociateDRTLogBucketError {
DisassociateDRTLogBucketError::HttpDispatch(err)
}
}
impl From<io::Error> for DisassociateDRTLogBucketError {
fn from(err: io::Error) -> DisassociateDRTLogBucketError {
DisassociateDRTLogBucketError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DisassociateDRTLogBucketError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DisassociateDRTLogBucketError {
fn description(&self) -> &str {
match *self {
DisassociateDRTLogBucketError::AccessDeniedForDependency(ref cause) => cause,
DisassociateDRTLogBucketError::InternalError(ref cause) => cause,
DisassociateDRTLogBucketError::InvalidOperation(ref cause) => cause,
DisassociateDRTLogBucketError::NoAssociatedRole(ref cause) => cause,
DisassociateDRTLogBucketError::OptimisticLock(ref cause) => cause,
DisassociateDRTLogBucketError::ResourceNotFound(ref cause) => cause,
DisassociateDRTLogBucketError::Validation(ref cause) => cause,
DisassociateDRTLogBucketError::Credentials(ref err) => err.description(),
DisassociateDRTLogBucketError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
DisassociateDRTLogBucketError::ParseError(ref cause) => cause,
DisassociateDRTLogBucketError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DisassociateDRTRoleError {
InternalError(String),
InvalidOperation(String),
OptimisticLock(String),
ResourceNotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DisassociateDRTRoleError {
pub fn from_response(res: BufferedHttpResponse) -> DisassociateDRTRoleError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"InternalErrorException" => {
return DisassociateDRTRoleError::InternalError(String::from(error_message));
}
"InvalidOperationException" => {
return DisassociateDRTRoleError::InvalidOperation(String::from(error_message));
}
"OptimisticLockException" => {
return DisassociateDRTRoleError::OptimisticLock(String::from(error_message));
}
"ResourceNotFoundException" => {
return DisassociateDRTRoleError::ResourceNotFound(String::from(error_message));
}
"ValidationException" => {
return DisassociateDRTRoleError::Validation(error_message.to_string());
}
_ => {}
}
}
return DisassociateDRTRoleError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DisassociateDRTRoleError {
fn from(err: serde_json::error::Error) -> DisassociateDRTRoleError {
DisassociateDRTRoleError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DisassociateDRTRoleError {
fn from(err: CredentialsError) -> DisassociateDRTRoleError {
DisassociateDRTRoleError::Credentials(err)
}
}
impl From<HttpDispatchError> for DisassociateDRTRoleError {
fn from(err: HttpDispatchError) -> DisassociateDRTRoleError {
DisassociateDRTRoleError::HttpDispatch(err)
}
}
impl From<io::Error> for DisassociateDRTRoleError {
fn from(err: io::Error) -> DisassociateDRTRoleError {
DisassociateDRTRoleError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DisassociateDRTRoleError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DisassociateDRTRoleError {
fn description(&self) -> &str {
match *self {
DisassociateDRTRoleError::InternalError(ref cause) => cause,
DisassociateDRTRoleError::InvalidOperation(ref cause) => cause,
DisassociateDRTRoleError::OptimisticLock(ref cause) => cause,
DisassociateDRTRoleError::ResourceNotFound(ref cause) => cause,
DisassociateDRTRoleError::Validation(ref cause) => cause,
DisassociateDRTRoleError::Credentials(ref err) => err.description(),
DisassociateDRTRoleError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
DisassociateDRTRoleError::ParseError(ref cause) => cause,
DisassociateDRTRoleError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum GetSubscriptionStateError {
InternalError(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl GetSubscriptionStateError {
pub fn from_response(res: BufferedHttpResponse) -> GetSubscriptionStateError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"InternalErrorException" => {
return GetSubscriptionStateError::InternalError(String::from(error_message));
}
"ValidationException" => {
return GetSubscriptionStateError::Validation(error_message.to_string());
}
_ => {}
}
}
return GetSubscriptionStateError::Unknown(res);
}
}
impl From<serde_json::error::Error> for GetSubscriptionStateError {
fn from(err: serde_json::error::Error) -> GetSubscriptionStateError {
GetSubscriptionStateError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for GetSubscriptionStateError {
fn from(err: CredentialsError) -> GetSubscriptionStateError {
GetSubscriptionStateError::Credentials(err)
}
}
impl From<HttpDispatchError> for GetSubscriptionStateError {
fn from(err: HttpDispatchError) -> GetSubscriptionStateError {
GetSubscriptionStateError::HttpDispatch(err)
}
}
impl From<io::Error> for GetSubscriptionStateError {
fn from(err: io::Error) -> GetSubscriptionStateError {
GetSubscriptionStateError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for GetSubscriptionStateError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for GetSubscriptionStateError {
fn description(&self) -> &str {
match *self {
GetSubscriptionStateError::InternalError(ref cause) => cause,
GetSubscriptionStateError::Validation(ref cause) => cause,
GetSubscriptionStateError::Credentials(ref err) => err.description(),
GetSubscriptionStateError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
GetSubscriptionStateError::ParseError(ref cause) => cause,
GetSubscriptionStateError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum ListAttacksError {
InternalError(String),
InvalidOperation(String),
InvalidParameter(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl ListAttacksError {
pub fn from_response(res: BufferedHttpResponse) -> ListAttacksError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"InternalErrorException" => {
return ListAttacksError::InternalError(String::from(error_message));
}
"InvalidOperationException" => {
return ListAttacksError::InvalidOperation(String::from(error_message));
}
"InvalidParameterException" => {
return ListAttacksError::InvalidParameter(String::from(error_message));
}
"ValidationException" => {
return ListAttacksError::Validation(error_message.to_string());
}
_ => {}
}
}
return ListAttacksError::Unknown(res);
}
}
impl From<serde_json::error::Error> for ListAttacksError {
fn from(err: serde_json::error::Error) -> ListAttacksError {
ListAttacksError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for ListAttacksError {
fn from(err: CredentialsError) -> ListAttacksError {
ListAttacksError::Credentials(err)
}
}
impl From<HttpDispatchError> for ListAttacksError {
fn from(err: HttpDispatchError) -> ListAttacksError {
ListAttacksError::HttpDispatch(err)
}
}
impl From<io::Error> for ListAttacksError {
fn from(err: io::Error) -> ListAttacksError {
ListAttacksError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for ListAttacksError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for ListAttacksError {
fn description(&self) -> &str {
match *self {
ListAttacksError::InternalError(ref cause) => cause,
ListAttacksError::InvalidOperation(ref cause) => cause,
ListAttacksError::InvalidParameter(ref cause) => cause,
ListAttacksError::Validation(ref cause) => cause,
ListAttacksError::Credentials(ref err) => err.description(),
ListAttacksError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
ListAttacksError::ParseError(ref cause) => cause,
ListAttacksError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum ListProtectionsError {
InternalError(String),
InvalidPaginationToken(String),
ResourceNotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl ListProtectionsError {
pub fn from_response(res: BufferedHttpResponse) -> ListProtectionsError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"InternalErrorException" => {
return ListProtectionsError::InternalError(String::from(error_message));
}
"InvalidPaginationTokenException" => {
return ListProtectionsError::InvalidPaginationToken(String::from(error_message));
}
"ResourceNotFoundException" => {
return ListProtectionsError::ResourceNotFound(String::from(error_message));
}
"ValidationException" => {
return ListProtectionsError::Validation(error_message.to_string());
}
_ => {}
}
}
return ListProtectionsError::Unknown(res);
}
}
impl From<serde_json::error::Error> for ListProtectionsError {
fn from(err: serde_json::error::Error) -> ListProtectionsError {
ListProtectionsError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for ListProtectionsError {
fn from(err: CredentialsError) -> ListProtectionsError {
ListProtectionsError::Credentials(err)
}
}
impl From<HttpDispatchError> for ListProtectionsError {
fn from(err: HttpDispatchError) -> ListProtectionsError {
ListProtectionsError::HttpDispatch(err)
}
}
impl From<io::Error> for ListProtectionsError {
fn from(err: io::Error) -> ListProtectionsError {
ListProtectionsError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for ListProtectionsError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for ListProtectionsError {
fn description(&self) -> &str {
match *self {
ListProtectionsError::InternalError(ref cause) => cause,
ListProtectionsError::InvalidPaginationToken(ref cause) => cause,
ListProtectionsError::ResourceNotFound(ref cause) => cause,
ListProtectionsError::Validation(ref cause) => cause,
ListProtectionsError::Credentials(ref err) => err.description(),
ListProtectionsError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
ListProtectionsError::ParseError(ref cause) => cause,
ListProtectionsError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum UpdateEmergencyContactSettingsError {
InternalError(String),
InvalidParameter(String),
OptimisticLock(String),
ResourceNotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl UpdateEmergencyContactSettingsError {
pub fn from_response(res: BufferedHttpResponse) -> UpdateEmergencyContactSettingsError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"InternalErrorException" => {
return UpdateEmergencyContactSettingsError::InternalError(String::from(
error_message,
));
}
"InvalidParameterException" => {
return UpdateEmergencyContactSettingsError::InvalidParameter(String::from(
error_message,
));
}
"OptimisticLockException" => {
return UpdateEmergencyContactSettingsError::OptimisticLock(String::from(
error_message,
));
}
"ResourceNotFoundException" => {
return UpdateEmergencyContactSettingsError::ResourceNotFound(String::from(
error_message,
));
}
"ValidationException" => {
return UpdateEmergencyContactSettingsError::Validation(
error_message.to_string(),
);
}
_ => {}
}
}
return UpdateEmergencyContactSettingsError::Unknown(res);
}
}
impl From<serde_json::error::Error> for UpdateEmergencyContactSettingsError {
fn from(err: serde_json::error::Error) -> UpdateEmergencyContactSettingsError {
UpdateEmergencyContactSettingsError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for UpdateEmergencyContactSettingsError {
fn from(err: CredentialsError) -> UpdateEmergencyContactSettingsError {
UpdateEmergencyContactSettingsError::Credentials(err)
}
}
impl From<HttpDispatchError> for UpdateEmergencyContactSettingsError {
fn from(err: HttpDispatchError) -> UpdateEmergencyContactSettingsError {
UpdateEmergencyContactSettingsError::HttpDispatch(err)
}
}
impl From<io::Error> for UpdateEmergencyContactSettingsError {
fn from(err: io::Error) -> UpdateEmergencyContactSettingsError {
UpdateEmergencyContactSettingsError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for UpdateEmergencyContactSettingsError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for UpdateEmergencyContactSettingsError {
fn description(&self) -> &str {
match *self {
UpdateEmergencyContactSettingsError::InternalError(ref cause) => cause,
UpdateEmergencyContactSettingsError::InvalidParameter(ref cause) => cause,
UpdateEmergencyContactSettingsError::OptimisticLock(ref cause) => cause,
UpdateEmergencyContactSettingsError::ResourceNotFound(ref cause) => cause,
UpdateEmergencyContactSettingsError::Validation(ref cause) => cause,
UpdateEmergencyContactSettingsError::Credentials(ref err) => err.description(),
UpdateEmergencyContactSettingsError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
UpdateEmergencyContactSettingsError::ParseError(ref cause) => cause,
UpdateEmergencyContactSettingsError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum UpdateSubscriptionError {
InternalError(String),
InvalidParameter(String),
LockedSubscription(String),
OptimisticLock(String),
ResourceNotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl UpdateSubscriptionError {
pub fn from_response(res: BufferedHttpResponse) -> UpdateSubscriptionError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"InternalErrorException" => {
return UpdateSubscriptionError::InternalError(String::from(error_message));
}
"InvalidParameterException" => {
return UpdateSubscriptionError::InvalidParameter(String::from(error_message));
}
"LockedSubscriptionException" => {
return UpdateSubscriptionError::LockedSubscription(String::from(error_message));
}
"OptimisticLockException" => {
return UpdateSubscriptionError::OptimisticLock(String::from(error_message));
}
"ResourceNotFoundException" => {
return UpdateSubscriptionError::ResourceNotFound(String::from(error_message));
}
"ValidationException" => {
return UpdateSubscriptionError::Validation(error_message.to_string());
}
_ => {}
}
}
return UpdateSubscriptionError::Unknown(res);
}
}
impl From<serde_json::error::Error> for UpdateSubscriptionError {
fn from(err: serde_json::error::Error) -> UpdateSubscriptionError {
UpdateSubscriptionError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for UpdateSubscriptionError {
fn from(err: CredentialsError) -> UpdateSubscriptionError {
UpdateSubscriptionError::Credentials(err)
}
}
impl From<HttpDispatchError> for UpdateSubscriptionError {
fn from(err: HttpDispatchError) -> UpdateSubscriptionError {
UpdateSubscriptionError::HttpDispatch(err)
}
}
impl From<io::Error> for UpdateSubscriptionError {
fn from(err: io::Error) -> UpdateSubscriptionError {
UpdateSubscriptionError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for UpdateSubscriptionError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for UpdateSubscriptionError {
fn description(&self) -> &str {
match *self {
UpdateSubscriptionError::InternalError(ref cause) => cause,
UpdateSubscriptionError::InvalidParameter(ref cause) => cause,
UpdateSubscriptionError::LockedSubscription(ref cause) => cause,
UpdateSubscriptionError::OptimisticLock(ref cause) => cause,
UpdateSubscriptionError::ResourceNotFound(ref cause) => cause,
UpdateSubscriptionError::Validation(ref cause) => cause,
UpdateSubscriptionError::Credentials(ref err) => err.description(),
UpdateSubscriptionError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
UpdateSubscriptionError::ParseError(ref cause) => cause,
UpdateSubscriptionError::Unknown(_) => "unknown error",
}
}
}
pub trait Shield {
fn associate_drt_log_bucket(
&self,
input: AssociateDRTLogBucketRequest,
) -> RusotoFuture<AssociateDRTLogBucketResponse, AssociateDRTLogBucketError>;
fn associate_drt_role(
&self,
input: AssociateDRTRoleRequest,
) -> RusotoFuture<AssociateDRTRoleResponse, AssociateDRTRoleError>;
fn create_protection(
&self,
input: CreateProtectionRequest,
) -> RusotoFuture<CreateProtectionResponse, CreateProtectionError>;
fn create_subscription(
&self,
) -> RusotoFuture<CreateSubscriptionResponse, CreateSubscriptionError>;
fn delete_protection(
&self,
input: DeleteProtectionRequest,
) -> RusotoFuture<DeleteProtectionResponse, DeleteProtectionError>;
fn delete_subscription(
&self,
) -> RusotoFuture<DeleteSubscriptionResponse, DeleteSubscriptionError>;
fn describe_attack(
&self,
input: DescribeAttackRequest,
) -> RusotoFuture<DescribeAttackResponse, DescribeAttackError>;
fn describe_drt_access(
&self,
) -> RusotoFuture<DescribeDRTAccessResponse, DescribeDRTAccessError>;
fn describe_emergency_contact_settings(
&self,
) -> RusotoFuture<DescribeEmergencyContactSettingsResponse, DescribeEmergencyContactSettingsError>;
fn describe_protection(
&self,
input: DescribeProtectionRequest,
) -> RusotoFuture<DescribeProtectionResponse, DescribeProtectionError>;
fn describe_subscription(
&self,
) -> RusotoFuture<DescribeSubscriptionResponse, DescribeSubscriptionError>;
fn disassociate_drt_log_bucket(
&self,
input: DisassociateDRTLogBucketRequest,
) -> RusotoFuture<DisassociateDRTLogBucketResponse, DisassociateDRTLogBucketError>;
fn disassociate_drt_role(
&self,
) -> RusotoFuture<DisassociateDRTRoleResponse, DisassociateDRTRoleError>;
fn get_subscription_state(
&self,
) -> RusotoFuture<GetSubscriptionStateResponse, GetSubscriptionStateError>;
fn list_attacks(
&self,
input: ListAttacksRequest,
) -> RusotoFuture<ListAttacksResponse, ListAttacksError>;
fn list_protections(
&self,
input: ListProtectionsRequest,
) -> RusotoFuture<ListProtectionsResponse, ListProtectionsError>;
fn update_emergency_contact_settings(
&self,
input: UpdateEmergencyContactSettingsRequest,
) -> RusotoFuture<UpdateEmergencyContactSettingsResponse, UpdateEmergencyContactSettingsError>;
fn update_subscription(
&self,
input: UpdateSubscriptionRequest,
) -> RusotoFuture<UpdateSubscriptionResponse, UpdateSubscriptionError>;
}
#[derive(Clone)]
pub struct ShieldClient {
client: Client,
region: region::Region,
}
impl ShieldClient {
pub fn new(region: region::Region) -> ShieldClient {
ShieldClient {
client: Client::shared(),
region: region,
}
}
pub fn new_with<P, D>(
request_dispatcher: D,
credentials_provider: P,
region: region::Region,
) -> ShieldClient
where
P: ProvideAwsCredentials + Send + Sync + 'static,
P::Future: Send,
D: DispatchSignedRequest + Send + Sync + 'static,
D::Future: Send,
{
ShieldClient {
client: Client::new_with(credentials_provider, request_dispatcher),
region: region,
}
}
}
impl Shield for ShieldClient {
fn associate_drt_log_bucket(
&self,
input: AssociateDRTLogBucketRequest,
) -> RusotoFuture<AssociateDRTLogBucketResponse, AssociateDRTLogBucketError> {
let mut request = SignedRequest::new("POST", "shield", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AWSShield_20160616.AssociateDRTLogBucket");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
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.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<AssociateDRTLogBucketResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response.buffer().from_err().and_then(|response| {
Err(AssociateDRTLogBucketError::from_response(response))
}),
)
}
})
}
fn associate_drt_role(
&self,
input: AssociateDRTRoleRequest,
) -> RusotoFuture<AssociateDRTRoleResponse, AssociateDRTRoleError> {
let mut request = SignedRequest::new("POST", "shield", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AWSShield_20160616.AssociateDRTRole");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
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.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<AssociateDRTRoleResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(AssociateDRTRoleError::from_response(response))),
)
}
})
}
fn create_protection(
&self,
input: CreateProtectionRequest,
) -> RusotoFuture<CreateProtectionResponse, CreateProtectionError> {
let mut request = SignedRequest::new("POST", "shield", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AWSShield_20160616.CreateProtection");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
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.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<CreateProtectionResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(CreateProtectionError::from_response(response))),
)
}
})
}
fn create_subscription(
&self,
) -> RusotoFuture<CreateSubscriptionResponse, CreateSubscriptionError> {
let mut request = SignedRequest::new("POST", "shield", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AWSShield_20160616.CreateSubscription");
request.set_payload(Some(b"{}".to_vec()));
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.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<CreateSubscriptionResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(CreateSubscriptionError::from_response(response))),
)
}
})
}
fn delete_protection(
&self,
input: DeleteProtectionRequest,
) -> RusotoFuture<DeleteProtectionResponse, DeleteProtectionError> {
let mut request = SignedRequest::new("POST", "shield", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AWSShield_20160616.DeleteProtection");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
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.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<DeleteProtectionResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DeleteProtectionError::from_response(response))),
)
}
})
}
fn delete_subscription(
&self,
) -> RusotoFuture<DeleteSubscriptionResponse, DeleteSubscriptionError> {
let mut request = SignedRequest::new("POST", "shield", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AWSShield_20160616.DeleteSubscription");
request.set_payload(Some(b"{}".to_vec()));
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.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<DeleteSubscriptionResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DeleteSubscriptionError::from_response(response))),
)
}
})
}
fn describe_attack(
&self,
input: DescribeAttackRequest,
) -> RusotoFuture<DescribeAttackResponse, DescribeAttackError> {
let mut request = SignedRequest::new("POST", "shield", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AWSShield_20160616.DescribeAttack");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
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.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<DescribeAttackResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DescribeAttackError::from_response(response))),
)
}
})
}
fn describe_drt_access(
&self,
) -> RusotoFuture<DescribeDRTAccessResponse, DescribeDRTAccessError> {
let mut request = SignedRequest::new("POST", "shield", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AWSShield_20160616.DescribeDRTAccess");
request.set_payload(Some(b"{}".to_vec()));
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.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<DescribeDRTAccessResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DescribeDRTAccessError::from_response(response))),
)
}
})
}
fn describe_emergency_contact_settings(
&self,
) -> RusotoFuture<DescribeEmergencyContactSettingsResponse, DescribeEmergencyContactSettingsError>
{
let mut request = SignedRequest::new("POST", "shield", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header(
"x-amz-target",
"AWSShield_20160616.DescribeEmergencyContactSettings",
);
request.set_payload(Some(b"{}".to_vec()));
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.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<DescribeEmergencyContactSettingsResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(DescribeEmergencyContactSettingsError::from_response(
response,
))
}))
}
})
}
fn describe_protection(
&self,
input: DescribeProtectionRequest,
) -> RusotoFuture<DescribeProtectionResponse, DescribeProtectionError> {
let mut request = SignedRequest::new("POST", "shield", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AWSShield_20160616.DescribeProtection");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
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.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<DescribeProtectionResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DescribeProtectionError::from_response(response))),
)
}
})
}
fn describe_subscription(
&self,
) -> RusotoFuture<DescribeSubscriptionResponse, DescribeSubscriptionError> {
let mut request = SignedRequest::new("POST", "shield", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AWSShield_20160616.DescribeSubscription");
request.set_payload(Some(b"{}".to_vec()));
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.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<DescribeSubscriptionResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response.buffer().from_err().and_then(|response| {
Err(DescribeSubscriptionError::from_response(response))
}),
)
}
})
}
fn disassociate_drt_log_bucket(
&self,
input: DisassociateDRTLogBucketRequest,
) -> RusotoFuture<DisassociateDRTLogBucketResponse, DisassociateDRTLogBucketError> {
let mut request = SignedRequest::new("POST", "shield", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header(
"x-amz-target",
"AWSShield_20160616.DisassociateDRTLogBucket",
);
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
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.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<DisassociateDRTLogBucketResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(DisassociateDRTLogBucketError::from_response(response))
}))
}
})
}
fn disassociate_drt_role(
&self,
) -> RusotoFuture<DisassociateDRTRoleResponse, DisassociateDRTRoleError> {
let mut request = SignedRequest::new("POST", "shield", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AWSShield_20160616.DisassociateDRTRole");
request.set_payload(Some(b"{}".to_vec()));
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.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<DisassociateDRTRoleResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response.buffer().from_err().and_then(|response| {
Err(DisassociateDRTRoleError::from_response(response))
}),
)
}
})
}
fn get_subscription_state(
&self,
) -> RusotoFuture<GetSubscriptionStateResponse, GetSubscriptionStateError> {
let mut request = SignedRequest::new("POST", "shield", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AWSShield_20160616.GetSubscriptionState");
request.set_payload(Some(b"{}".to_vec()));
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.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<GetSubscriptionStateResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response.buffer().from_err().and_then(|response| {
Err(GetSubscriptionStateError::from_response(response))
}),
)
}
})
}
fn list_attacks(
&self,
input: ListAttacksRequest,
) -> RusotoFuture<ListAttacksResponse, ListAttacksError> {
let mut request = SignedRequest::new("POST", "shield", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AWSShield_20160616.ListAttacks");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
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.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<ListAttacksResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(ListAttacksError::from_response(response))),
)
}
})
}
fn list_protections(
&self,
input: ListProtectionsRequest,
) -> RusotoFuture<ListProtectionsResponse, ListProtectionsError> {
let mut request = SignedRequest::new("POST", "shield", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AWSShield_20160616.ListProtections");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
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.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<ListProtectionsResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(ListProtectionsError::from_response(response))),
)
}
})
}
fn update_emergency_contact_settings(
&self,
input: UpdateEmergencyContactSettingsRequest,
) -> RusotoFuture<UpdateEmergencyContactSettingsResponse, UpdateEmergencyContactSettingsError>
{
let mut request = SignedRequest::new("POST", "shield", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header(
"x-amz-target",
"AWSShield_20160616.UpdateEmergencyContactSettings",
);
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
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.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<UpdateEmergencyContactSettingsResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(UpdateEmergencyContactSettingsError::from_response(response))
}))
}
})
}
fn update_subscription(
&self,
input: UpdateSubscriptionRequest,
) -> RusotoFuture<UpdateSubscriptionResponse, UpdateSubscriptionError> {
let mut request = SignedRequest::new("POST", "shield", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AWSShield_20160616.UpdateSubscription");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
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.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<UpdateSubscriptionResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(UpdateSubscriptionError::from_response(response))),
)
}
})
}
}
#[cfg(test)]
mod protocol_tests {}