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 AddAttachmentsToSetRequest {
#[serde(rename = "attachmentSetId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub attachment_set_id: Option<String>,
#[serde(rename = "attachments")]
pub attachments: Vec<Attachment>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct AddAttachmentsToSetResponse {
#[serde(rename = "attachmentSetId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub attachment_set_id: Option<String>,
#[serde(rename = "expiryTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub expiry_time: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct AddCommunicationToCaseRequest {
#[serde(rename = "attachmentSetId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub attachment_set_id: Option<String>,
#[serde(rename = "caseId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub case_id: Option<String>,
#[serde(rename = "ccEmailAddresses")]
#[serde(skip_serializing_if = "Option::is_none")]
pub cc_email_addresses: Option<Vec<String>>,
#[serde(rename = "communicationBody")]
pub communication_body: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct AddCommunicationToCaseResponse {
#[serde(rename = "result")]
#[serde(skip_serializing_if = "Option::is_none")]
pub result: Option<bool>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Attachment {
#[serde(rename = "data")]
#[serde(
deserialize_with = "::rusoto_core::serialization::SerdeBlob::deserialize_blob",
serialize_with = "::rusoto_core::serialization::SerdeBlob::serialize_blob",
default
)]
#[serde(skip_serializing_if = "Option::is_none")]
pub data: Option<Vec<u8>>,
#[serde(rename = "fileName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub file_name: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct AttachmentDetails {
#[serde(rename = "attachmentId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub attachment_id: Option<String>,
#[serde(rename = "fileName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub file_name: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct CaseDetails {
#[serde(rename = "caseId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub case_id: Option<String>,
#[serde(rename = "categoryCode")]
#[serde(skip_serializing_if = "Option::is_none")]
pub category_code: Option<String>,
#[serde(rename = "ccEmailAddresses")]
#[serde(skip_serializing_if = "Option::is_none")]
pub cc_email_addresses: Option<Vec<String>>,
#[serde(rename = "displayId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub display_id: Option<String>,
#[serde(rename = "language")]
#[serde(skip_serializing_if = "Option::is_none")]
pub language: Option<String>,
#[serde(rename = "recentCommunications")]
#[serde(skip_serializing_if = "Option::is_none")]
pub recent_communications: Option<RecentCaseCommunications>,
#[serde(rename = "serviceCode")]
#[serde(skip_serializing_if = "Option::is_none")]
pub service_code: Option<String>,
#[serde(rename = "severityCode")]
#[serde(skip_serializing_if = "Option::is_none")]
pub severity_code: Option<String>,
#[serde(rename = "status")]
#[serde(skip_serializing_if = "Option::is_none")]
pub status: Option<String>,
#[serde(rename = "subject")]
#[serde(skip_serializing_if = "Option::is_none")]
pub subject: Option<String>,
#[serde(rename = "submittedBy")]
#[serde(skip_serializing_if = "Option::is_none")]
pub submitted_by: Option<String>,
#[serde(rename = "timeCreated")]
#[serde(skip_serializing_if = "Option::is_none")]
pub time_created: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct Category {
#[serde(rename = "code")]
#[serde(skip_serializing_if = "Option::is_none")]
pub code: 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 Communication {
#[serde(rename = "attachmentSet")]
#[serde(skip_serializing_if = "Option::is_none")]
pub attachment_set: Option<Vec<AttachmentDetails>>,
#[serde(rename = "body")]
#[serde(skip_serializing_if = "Option::is_none")]
pub body: Option<String>,
#[serde(rename = "caseId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub case_id: Option<String>,
#[serde(rename = "submittedBy")]
#[serde(skip_serializing_if = "Option::is_none")]
pub submitted_by: Option<String>,
#[serde(rename = "timeCreated")]
#[serde(skip_serializing_if = "Option::is_none")]
pub time_created: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct CreateCaseRequest {
#[serde(rename = "attachmentSetId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub attachment_set_id: Option<String>,
#[serde(rename = "categoryCode")]
#[serde(skip_serializing_if = "Option::is_none")]
pub category_code: Option<String>,
#[serde(rename = "ccEmailAddresses")]
#[serde(skip_serializing_if = "Option::is_none")]
pub cc_email_addresses: Option<Vec<String>>,
#[serde(rename = "communicationBody")]
pub communication_body: String,
#[serde(rename = "issueType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub issue_type: Option<String>,
#[serde(rename = "language")]
#[serde(skip_serializing_if = "Option::is_none")]
pub language: Option<String>,
#[serde(rename = "serviceCode")]
#[serde(skip_serializing_if = "Option::is_none")]
pub service_code: Option<String>,
#[serde(rename = "severityCode")]
#[serde(skip_serializing_if = "Option::is_none")]
pub severity_code: Option<String>,
#[serde(rename = "subject")]
pub subject: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct CreateCaseResponse {
#[serde(rename = "caseId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub case_id: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DescribeAttachmentRequest {
#[serde(rename = "attachmentId")]
pub attachment_id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DescribeAttachmentResponse {
#[serde(rename = "attachment")]
#[serde(skip_serializing_if = "Option::is_none")]
pub attachment: Option<Attachment>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DescribeCasesRequest {
#[serde(rename = "afterTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub after_time: Option<String>,
#[serde(rename = "beforeTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub before_time: Option<String>,
#[serde(rename = "caseIdList")]
#[serde(skip_serializing_if = "Option::is_none")]
pub case_id_list: Option<Vec<String>>,
#[serde(rename = "displayId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub display_id: Option<String>,
#[serde(rename = "includeCommunications")]
#[serde(skip_serializing_if = "Option::is_none")]
pub include_communications: Option<bool>,
#[serde(rename = "includeResolvedCases")]
#[serde(skip_serializing_if = "Option::is_none")]
pub include_resolved_cases: Option<bool>,
#[serde(rename = "language")]
#[serde(skip_serializing_if = "Option::is_none")]
pub language: Option<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 DescribeCasesResponse {
#[serde(rename = "cases")]
#[serde(skip_serializing_if = "Option::is_none")]
pub cases: Option<Vec<CaseDetails>>,
#[serde(rename = "nextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DescribeCommunicationsRequest {
#[serde(rename = "afterTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub after_time: Option<String>,
#[serde(rename = "beforeTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub before_time: Option<String>,
#[serde(rename = "caseId")]
pub case_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 DescribeCommunicationsResponse {
#[serde(rename = "communications")]
#[serde(skip_serializing_if = "Option::is_none")]
pub communications: Option<Vec<Communication>>,
#[serde(rename = "nextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DescribeServicesRequest {
#[serde(rename = "language")]
#[serde(skip_serializing_if = "Option::is_none")]
pub language: Option<String>,
#[serde(rename = "serviceCodeList")]
#[serde(skip_serializing_if = "Option::is_none")]
pub service_code_list: Option<Vec<String>>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DescribeServicesResponse {
#[serde(rename = "services")]
#[serde(skip_serializing_if = "Option::is_none")]
pub services: Option<Vec<Service>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DescribeSeverityLevelsRequest {
#[serde(rename = "language")]
#[serde(skip_serializing_if = "Option::is_none")]
pub language: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DescribeSeverityLevelsResponse {
#[serde(rename = "severityLevels")]
#[serde(skip_serializing_if = "Option::is_none")]
pub severity_levels: Option<Vec<SeverityLevel>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DescribeTrustedAdvisorCheckRefreshStatusesRequest {
#[serde(rename = "checkIds")]
pub check_ids: Vec<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DescribeTrustedAdvisorCheckRefreshStatusesResponse {
#[serde(rename = "statuses")]
pub statuses: Vec<TrustedAdvisorCheckRefreshStatus>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DescribeTrustedAdvisorCheckResultRequest {
#[serde(rename = "checkId")]
pub check_id: String,
#[serde(rename = "language")]
#[serde(skip_serializing_if = "Option::is_none")]
pub language: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DescribeTrustedAdvisorCheckResultResponse {
#[serde(rename = "result")]
#[serde(skip_serializing_if = "Option::is_none")]
pub result: Option<TrustedAdvisorCheckResult>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DescribeTrustedAdvisorCheckSummariesRequest {
#[serde(rename = "checkIds")]
pub check_ids: Vec<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DescribeTrustedAdvisorCheckSummariesResponse {
#[serde(rename = "summaries")]
pub summaries: Vec<TrustedAdvisorCheckSummary>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DescribeTrustedAdvisorChecksRequest {
#[serde(rename = "language")]
pub language: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DescribeTrustedAdvisorChecksResponse {
#[serde(rename = "checks")]
pub checks: Vec<TrustedAdvisorCheckDescription>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct RecentCaseCommunications {
#[serde(rename = "communications")]
#[serde(skip_serializing_if = "Option::is_none")]
pub communications: Option<Vec<Communication>>,
#[serde(rename = "nextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct RefreshTrustedAdvisorCheckRequest {
#[serde(rename = "checkId")]
pub check_id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct RefreshTrustedAdvisorCheckResponse {
#[serde(rename = "status")]
pub status: TrustedAdvisorCheckRefreshStatus,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct ResolveCaseRequest {
#[serde(rename = "caseId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub case_id: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct ResolveCaseResponse {
#[serde(rename = "finalCaseStatus")]
#[serde(skip_serializing_if = "Option::is_none")]
pub final_case_status: Option<String>,
#[serde(rename = "initialCaseStatus")]
#[serde(skip_serializing_if = "Option::is_none")]
pub initial_case_status: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct Service {
#[serde(rename = "categories")]
#[serde(skip_serializing_if = "Option::is_none")]
pub categories: Option<Vec<Category>>,
#[serde(rename = "code")]
#[serde(skip_serializing_if = "Option::is_none")]
pub code: 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 SeverityLevel {
#[serde(rename = "code")]
#[serde(skip_serializing_if = "Option::is_none")]
pub code: 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 TrustedAdvisorCategorySpecificSummary {
#[serde(rename = "costOptimizing")]
#[serde(skip_serializing_if = "Option::is_none")]
pub cost_optimizing: Option<TrustedAdvisorCostOptimizingSummary>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct TrustedAdvisorCheckDescription {
#[serde(rename = "category")]
pub category: String,
#[serde(rename = "description")]
pub description: String,
#[serde(rename = "id")]
pub id: String,
#[serde(rename = "metadata")]
pub metadata: Vec<String>,
#[serde(rename = "name")]
pub name: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct TrustedAdvisorCheckRefreshStatus {
#[serde(rename = "checkId")]
pub check_id: String,
#[serde(rename = "millisUntilNextRefreshable")]
pub millis_until_next_refreshable: i64,
#[serde(rename = "status")]
pub status: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct TrustedAdvisorCheckResult {
#[serde(rename = "categorySpecificSummary")]
pub category_specific_summary: TrustedAdvisorCategorySpecificSummary,
#[serde(rename = "checkId")]
pub check_id: String,
#[serde(rename = "flaggedResources")]
pub flagged_resources: Vec<TrustedAdvisorResourceDetail>,
#[serde(rename = "resourcesSummary")]
pub resources_summary: TrustedAdvisorResourcesSummary,
#[serde(rename = "status")]
pub status: String,
#[serde(rename = "timestamp")]
pub timestamp: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct TrustedAdvisorCheckSummary {
#[serde(rename = "categorySpecificSummary")]
pub category_specific_summary: TrustedAdvisorCategorySpecificSummary,
#[serde(rename = "checkId")]
pub check_id: String,
#[serde(rename = "hasFlaggedResources")]
#[serde(skip_serializing_if = "Option::is_none")]
pub has_flagged_resources: Option<bool>,
#[serde(rename = "resourcesSummary")]
pub resources_summary: TrustedAdvisorResourcesSummary,
#[serde(rename = "status")]
pub status: String,
#[serde(rename = "timestamp")]
pub timestamp: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct TrustedAdvisorCostOptimizingSummary {
#[serde(rename = "estimatedMonthlySavings")]
pub estimated_monthly_savings: f64,
#[serde(rename = "estimatedPercentMonthlySavings")]
pub estimated_percent_monthly_savings: f64,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct TrustedAdvisorResourceDetail {
#[serde(rename = "isSuppressed")]
#[serde(skip_serializing_if = "Option::is_none")]
pub is_suppressed: Option<bool>,
#[serde(rename = "metadata")]
pub metadata: Vec<String>,
#[serde(rename = "region")]
#[serde(skip_serializing_if = "Option::is_none")]
pub region: Option<String>,
#[serde(rename = "resourceId")]
pub resource_id: String,
#[serde(rename = "status")]
pub status: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct TrustedAdvisorResourcesSummary {
#[serde(rename = "resourcesFlagged")]
pub resources_flagged: i64,
#[serde(rename = "resourcesIgnored")]
pub resources_ignored: i64,
#[serde(rename = "resourcesProcessed")]
pub resources_processed: i64,
#[serde(rename = "resourcesSuppressed")]
pub resources_suppressed: i64,
}
#[derive(Debug, PartialEq)]
pub enum AddAttachmentsToSetError {
AttachmentLimitExceeded(String),
AttachmentSetExpired(String),
AttachmentSetIdNotFound(String),
AttachmentSetSizeLimitExceeded(String),
InternalServerError(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl AddAttachmentsToSetError {
pub fn from_response(res: BufferedHttpResponse) -> AddAttachmentsToSetError {
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 {
"AttachmentLimitExceeded" => {
return AddAttachmentsToSetError::AttachmentLimitExceeded(String::from(
error_message,
));
}
"AttachmentSetExpired" => {
return AddAttachmentsToSetError::AttachmentSetExpired(String::from(
error_message,
));
}
"AttachmentSetIdNotFound" => {
return AddAttachmentsToSetError::AttachmentSetIdNotFound(String::from(
error_message,
));
}
"AttachmentSetSizeLimitExceeded" => {
return AddAttachmentsToSetError::AttachmentSetSizeLimitExceeded(String::from(
error_message,
));
}
"InternalServerError" => {
return AddAttachmentsToSetError::InternalServerError(String::from(
error_message,
));
}
"ValidationException" => {
return AddAttachmentsToSetError::Validation(error_message.to_string());
}
_ => {}
}
}
return AddAttachmentsToSetError::Unknown(res);
}
}
impl From<serde_json::error::Error> for AddAttachmentsToSetError {
fn from(err: serde_json::error::Error) -> AddAttachmentsToSetError {
AddAttachmentsToSetError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for AddAttachmentsToSetError {
fn from(err: CredentialsError) -> AddAttachmentsToSetError {
AddAttachmentsToSetError::Credentials(err)
}
}
impl From<HttpDispatchError> for AddAttachmentsToSetError {
fn from(err: HttpDispatchError) -> AddAttachmentsToSetError {
AddAttachmentsToSetError::HttpDispatch(err)
}
}
impl From<io::Error> for AddAttachmentsToSetError {
fn from(err: io::Error) -> AddAttachmentsToSetError {
AddAttachmentsToSetError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for AddAttachmentsToSetError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for AddAttachmentsToSetError {
fn description(&self) -> &str {
match *self {
AddAttachmentsToSetError::AttachmentLimitExceeded(ref cause) => cause,
AddAttachmentsToSetError::AttachmentSetExpired(ref cause) => cause,
AddAttachmentsToSetError::AttachmentSetIdNotFound(ref cause) => cause,
AddAttachmentsToSetError::AttachmentSetSizeLimitExceeded(ref cause) => cause,
AddAttachmentsToSetError::InternalServerError(ref cause) => cause,
AddAttachmentsToSetError::Validation(ref cause) => cause,
AddAttachmentsToSetError::Credentials(ref err) => err.description(),
AddAttachmentsToSetError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
AddAttachmentsToSetError::ParseError(ref cause) => cause,
AddAttachmentsToSetError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum AddCommunicationToCaseError {
AttachmentSetExpired(String),
AttachmentSetIdNotFound(String),
CaseIdNotFound(String),
InternalServerError(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl AddCommunicationToCaseError {
pub fn from_response(res: BufferedHttpResponse) -> AddCommunicationToCaseError {
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 {
"AttachmentSetExpired" => {
return AddCommunicationToCaseError::AttachmentSetExpired(String::from(
error_message,
));
}
"AttachmentSetIdNotFound" => {
return AddCommunicationToCaseError::AttachmentSetIdNotFound(String::from(
error_message,
));
}
"CaseIdNotFound" => {
return AddCommunicationToCaseError::CaseIdNotFound(String::from(error_message));
}
"InternalServerError" => {
return AddCommunicationToCaseError::InternalServerError(String::from(
error_message,
));
}
"ValidationException" => {
return AddCommunicationToCaseError::Validation(error_message.to_string());
}
_ => {}
}
}
return AddCommunicationToCaseError::Unknown(res);
}
}
impl From<serde_json::error::Error> for AddCommunicationToCaseError {
fn from(err: serde_json::error::Error) -> AddCommunicationToCaseError {
AddCommunicationToCaseError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for AddCommunicationToCaseError {
fn from(err: CredentialsError) -> AddCommunicationToCaseError {
AddCommunicationToCaseError::Credentials(err)
}
}
impl From<HttpDispatchError> for AddCommunicationToCaseError {
fn from(err: HttpDispatchError) -> AddCommunicationToCaseError {
AddCommunicationToCaseError::HttpDispatch(err)
}
}
impl From<io::Error> for AddCommunicationToCaseError {
fn from(err: io::Error) -> AddCommunicationToCaseError {
AddCommunicationToCaseError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for AddCommunicationToCaseError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for AddCommunicationToCaseError {
fn description(&self) -> &str {
match *self {
AddCommunicationToCaseError::AttachmentSetExpired(ref cause) => cause,
AddCommunicationToCaseError::AttachmentSetIdNotFound(ref cause) => cause,
AddCommunicationToCaseError::CaseIdNotFound(ref cause) => cause,
AddCommunicationToCaseError::InternalServerError(ref cause) => cause,
AddCommunicationToCaseError::Validation(ref cause) => cause,
AddCommunicationToCaseError::Credentials(ref err) => err.description(),
AddCommunicationToCaseError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
AddCommunicationToCaseError::ParseError(ref cause) => cause,
AddCommunicationToCaseError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum CreateCaseError {
AttachmentSetExpired(String),
AttachmentSetIdNotFound(String),
CaseCreationLimitExceeded(String),
InternalServerError(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl CreateCaseError {
pub fn from_response(res: BufferedHttpResponse) -> CreateCaseError {
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 {
"AttachmentSetExpired" => {
return CreateCaseError::AttachmentSetExpired(String::from(error_message));
}
"AttachmentSetIdNotFound" => {
return CreateCaseError::AttachmentSetIdNotFound(String::from(error_message));
}
"CaseCreationLimitExceeded" => {
return CreateCaseError::CaseCreationLimitExceeded(String::from(error_message));
}
"InternalServerError" => {
return CreateCaseError::InternalServerError(String::from(error_message));
}
"ValidationException" => {
return CreateCaseError::Validation(error_message.to_string());
}
_ => {}
}
}
return CreateCaseError::Unknown(res);
}
}
impl From<serde_json::error::Error> for CreateCaseError {
fn from(err: serde_json::error::Error) -> CreateCaseError {
CreateCaseError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for CreateCaseError {
fn from(err: CredentialsError) -> CreateCaseError {
CreateCaseError::Credentials(err)
}
}
impl From<HttpDispatchError> for CreateCaseError {
fn from(err: HttpDispatchError) -> CreateCaseError {
CreateCaseError::HttpDispatch(err)
}
}
impl From<io::Error> for CreateCaseError {
fn from(err: io::Error) -> CreateCaseError {
CreateCaseError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for CreateCaseError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for CreateCaseError {
fn description(&self) -> &str {
match *self {
CreateCaseError::AttachmentSetExpired(ref cause) => cause,
CreateCaseError::AttachmentSetIdNotFound(ref cause) => cause,
CreateCaseError::CaseCreationLimitExceeded(ref cause) => cause,
CreateCaseError::InternalServerError(ref cause) => cause,
CreateCaseError::Validation(ref cause) => cause,
CreateCaseError::Credentials(ref err) => err.description(),
CreateCaseError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
CreateCaseError::ParseError(ref cause) => cause,
CreateCaseError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DescribeAttachmentError {
AttachmentIdNotFound(String),
DescribeAttachmentLimitExceeded(String),
InternalServerError(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DescribeAttachmentError {
pub fn from_response(res: BufferedHttpResponse) -> DescribeAttachmentError {
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 {
"AttachmentIdNotFound" => {
return DescribeAttachmentError::AttachmentIdNotFound(String::from(
error_message,
));
}
"DescribeAttachmentLimitExceeded" => {
return DescribeAttachmentError::DescribeAttachmentLimitExceeded(String::from(
error_message,
));
}
"InternalServerError" => {
return DescribeAttachmentError::InternalServerError(String::from(error_message));
}
"ValidationException" => {
return DescribeAttachmentError::Validation(error_message.to_string());
}
_ => {}
}
}
return DescribeAttachmentError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DescribeAttachmentError {
fn from(err: serde_json::error::Error) -> DescribeAttachmentError {
DescribeAttachmentError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DescribeAttachmentError {
fn from(err: CredentialsError) -> DescribeAttachmentError {
DescribeAttachmentError::Credentials(err)
}
}
impl From<HttpDispatchError> for DescribeAttachmentError {
fn from(err: HttpDispatchError) -> DescribeAttachmentError {
DescribeAttachmentError::HttpDispatch(err)
}
}
impl From<io::Error> for DescribeAttachmentError {
fn from(err: io::Error) -> DescribeAttachmentError {
DescribeAttachmentError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DescribeAttachmentError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DescribeAttachmentError {
fn description(&self) -> &str {
match *self {
DescribeAttachmentError::AttachmentIdNotFound(ref cause) => cause,
DescribeAttachmentError::DescribeAttachmentLimitExceeded(ref cause) => cause,
DescribeAttachmentError::InternalServerError(ref cause) => cause,
DescribeAttachmentError::Validation(ref cause) => cause,
DescribeAttachmentError::Credentials(ref err) => err.description(),
DescribeAttachmentError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
DescribeAttachmentError::ParseError(ref cause) => cause,
DescribeAttachmentError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DescribeCasesError {
CaseIdNotFound(String),
InternalServerError(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DescribeCasesError {
pub fn from_response(res: BufferedHttpResponse) -> DescribeCasesError {
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 {
"CaseIdNotFound" => {
return DescribeCasesError::CaseIdNotFound(String::from(error_message));
}
"InternalServerError" => {
return DescribeCasesError::InternalServerError(String::from(error_message));
}
"ValidationException" => {
return DescribeCasesError::Validation(error_message.to_string());
}
_ => {}
}
}
return DescribeCasesError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DescribeCasesError {
fn from(err: serde_json::error::Error) -> DescribeCasesError {
DescribeCasesError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DescribeCasesError {
fn from(err: CredentialsError) -> DescribeCasesError {
DescribeCasesError::Credentials(err)
}
}
impl From<HttpDispatchError> for DescribeCasesError {
fn from(err: HttpDispatchError) -> DescribeCasesError {
DescribeCasesError::HttpDispatch(err)
}
}
impl From<io::Error> for DescribeCasesError {
fn from(err: io::Error) -> DescribeCasesError {
DescribeCasesError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DescribeCasesError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DescribeCasesError {
fn description(&self) -> &str {
match *self {
DescribeCasesError::CaseIdNotFound(ref cause) => cause,
DescribeCasesError::InternalServerError(ref cause) => cause,
DescribeCasesError::Validation(ref cause) => cause,
DescribeCasesError::Credentials(ref err) => err.description(),
DescribeCasesError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
DescribeCasesError::ParseError(ref cause) => cause,
DescribeCasesError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DescribeCommunicationsError {
CaseIdNotFound(String),
InternalServerError(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DescribeCommunicationsError {
pub fn from_response(res: BufferedHttpResponse) -> DescribeCommunicationsError {
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 {
"CaseIdNotFound" => {
return DescribeCommunicationsError::CaseIdNotFound(String::from(error_message));
}
"InternalServerError" => {
return DescribeCommunicationsError::InternalServerError(String::from(
error_message,
));
}
"ValidationException" => {
return DescribeCommunicationsError::Validation(error_message.to_string());
}
_ => {}
}
}
return DescribeCommunicationsError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DescribeCommunicationsError {
fn from(err: serde_json::error::Error) -> DescribeCommunicationsError {
DescribeCommunicationsError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DescribeCommunicationsError {
fn from(err: CredentialsError) -> DescribeCommunicationsError {
DescribeCommunicationsError::Credentials(err)
}
}
impl From<HttpDispatchError> for DescribeCommunicationsError {
fn from(err: HttpDispatchError) -> DescribeCommunicationsError {
DescribeCommunicationsError::HttpDispatch(err)
}
}
impl From<io::Error> for DescribeCommunicationsError {
fn from(err: io::Error) -> DescribeCommunicationsError {
DescribeCommunicationsError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DescribeCommunicationsError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DescribeCommunicationsError {
fn description(&self) -> &str {
match *self {
DescribeCommunicationsError::CaseIdNotFound(ref cause) => cause,
DescribeCommunicationsError::InternalServerError(ref cause) => cause,
DescribeCommunicationsError::Validation(ref cause) => cause,
DescribeCommunicationsError::Credentials(ref err) => err.description(),
DescribeCommunicationsError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
DescribeCommunicationsError::ParseError(ref cause) => cause,
DescribeCommunicationsError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DescribeServicesError {
InternalServerError(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DescribeServicesError {
pub fn from_response(res: BufferedHttpResponse) -> DescribeServicesError {
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 {
"InternalServerError" => {
return DescribeServicesError::InternalServerError(String::from(error_message));
}
"ValidationException" => {
return DescribeServicesError::Validation(error_message.to_string());
}
_ => {}
}
}
return DescribeServicesError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DescribeServicesError {
fn from(err: serde_json::error::Error) -> DescribeServicesError {
DescribeServicesError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DescribeServicesError {
fn from(err: CredentialsError) -> DescribeServicesError {
DescribeServicesError::Credentials(err)
}
}
impl From<HttpDispatchError> for DescribeServicesError {
fn from(err: HttpDispatchError) -> DescribeServicesError {
DescribeServicesError::HttpDispatch(err)
}
}
impl From<io::Error> for DescribeServicesError {
fn from(err: io::Error) -> DescribeServicesError {
DescribeServicesError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DescribeServicesError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DescribeServicesError {
fn description(&self) -> &str {
match *self {
DescribeServicesError::InternalServerError(ref cause) => cause,
DescribeServicesError::Validation(ref cause) => cause,
DescribeServicesError::Credentials(ref err) => err.description(),
DescribeServicesError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
DescribeServicesError::ParseError(ref cause) => cause,
DescribeServicesError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DescribeSeverityLevelsError {
InternalServerError(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DescribeSeverityLevelsError {
pub fn from_response(res: BufferedHttpResponse) -> DescribeSeverityLevelsError {
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 {
"InternalServerError" => {
return DescribeSeverityLevelsError::InternalServerError(String::from(
error_message,
));
}
"ValidationException" => {
return DescribeSeverityLevelsError::Validation(error_message.to_string());
}
_ => {}
}
}
return DescribeSeverityLevelsError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DescribeSeverityLevelsError {
fn from(err: serde_json::error::Error) -> DescribeSeverityLevelsError {
DescribeSeverityLevelsError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DescribeSeverityLevelsError {
fn from(err: CredentialsError) -> DescribeSeverityLevelsError {
DescribeSeverityLevelsError::Credentials(err)
}
}
impl From<HttpDispatchError> for DescribeSeverityLevelsError {
fn from(err: HttpDispatchError) -> DescribeSeverityLevelsError {
DescribeSeverityLevelsError::HttpDispatch(err)
}
}
impl From<io::Error> for DescribeSeverityLevelsError {
fn from(err: io::Error) -> DescribeSeverityLevelsError {
DescribeSeverityLevelsError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DescribeSeverityLevelsError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DescribeSeverityLevelsError {
fn description(&self) -> &str {
match *self {
DescribeSeverityLevelsError::InternalServerError(ref cause) => cause,
DescribeSeverityLevelsError::Validation(ref cause) => cause,
DescribeSeverityLevelsError::Credentials(ref err) => err.description(),
DescribeSeverityLevelsError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
DescribeSeverityLevelsError::ParseError(ref cause) => cause,
DescribeSeverityLevelsError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DescribeTrustedAdvisorCheckRefreshStatusesError {
InternalServerError(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DescribeTrustedAdvisorCheckRefreshStatusesError {
pub fn from_response(
res: BufferedHttpResponse,
) -> DescribeTrustedAdvisorCheckRefreshStatusesError {
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 {
"InternalServerError" => {
return DescribeTrustedAdvisorCheckRefreshStatusesError::InternalServerError(
String::from(error_message),
);
}
"ValidationException" => {
return DescribeTrustedAdvisorCheckRefreshStatusesError::Validation(
error_message.to_string(),
);
}
_ => {}
}
}
return DescribeTrustedAdvisorCheckRefreshStatusesError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DescribeTrustedAdvisorCheckRefreshStatusesError {
fn from(err: serde_json::error::Error) -> DescribeTrustedAdvisorCheckRefreshStatusesError {
DescribeTrustedAdvisorCheckRefreshStatusesError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DescribeTrustedAdvisorCheckRefreshStatusesError {
fn from(err: CredentialsError) -> DescribeTrustedAdvisorCheckRefreshStatusesError {
DescribeTrustedAdvisorCheckRefreshStatusesError::Credentials(err)
}
}
impl From<HttpDispatchError> for DescribeTrustedAdvisorCheckRefreshStatusesError {
fn from(err: HttpDispatchError) -> DescribeTrustedAdvisorCheckRefreshStatusesError {
DescribeTrustedAdvisorCheckRefreshStatusesError::HttpDispatch(err)
}
}
impl From<io::Error> for DescribeTrustedAdvisorCheckRefreshStatusesError {
fn from(err: io::Error) -> DescribeTrustedAdvisorCheckRefreshStatusesError {
DescribeTrustedAdvisorCheckRefreshStatusesError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DescribeTrustedAdvisorCheckRefreshStatusesError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DescribeTrustedAdvisorCheckRefreshStatusesError {
fn description(&self) -> &str {
match *self {
DescribeTrustedAdvisorCheckRefreshStatusesError::InternalServerError(ref cause) => {
cause
}
DescribeTrustedAdvisorCheckRefreshStatusesError::Validation(ref cause) => cause,
DescribeTrustedAdvisorCheckRefreshStatusesError::Credentials(ref err) => {
err.description()
}
DescribeTrustedAdvisorCheckRefreshStatusesError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
DescribeTrustedAdvisorCheckRefreshStatusesError::ParseError(ref cause) => cause,
DescribeTrustedAdvisorCheckRefreshStatusesError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DescribeTrustedAdvisorCheckResultError {
InternalServerError(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DescribeTrustedAdvisorCheckResultError {
pub fn from_response(res: BufferedHttpResponse) -> DescribeTrustedAdvisorCheckResultError {
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 {
"InternalServerError" => {
return DescribeTrustedAdvisorCheckResultError::InternalServerError(
String::from(error_message),
);
}
"ValidationException" => {
return DescribeTrustedAdvisorCheckResultError::Validation(
error_message.to_string(),
);
}
_ => {}
}
}
return DescribeTrustedAdvisorCheckResultError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DescribeTrustedAdvisorCheckResultError {
fn from(err: serde_json::error::Error) -> DescribeTrustedAdvisorCheckResultError {
DescribeTrustedAdvisorCheckResultError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DescribeTrustedAdvisorCheckResultError {
fn from(err: CredentialsError) -> DescribeTrustedAdvisorCheckResultError {
DescribeTrustedAdvisorCheckResultError::Credentials(err)
}
}
impl From<HttpDispatchError> for DescribeTrustedAdvisorCheckResultError {
fn from(err: HttpDispatchError) -> DescribeTrustedAdvisorCheckResultError {
DescribeTrustedAdvisorCheckResultError::HttpDispatch(err)
}
}
impl From<io::Error> for DescribeTrustedAdvisorCheckResultError {
fn from(err: io::Error) -> DescribeTrustedAdvisorCheckResultError {
DescribeTrustedAdvisorCheckResultError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DescribeTrustedAdvisorCheckResultError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DescribeTrustedAdvisorCheckResultError {
fn description(&self) -> &str {
match *self {
DescribeTrustedAdvisorCheckResultError::InternalServerError(ref cause) => cause,
DescribeTrustedAdvisorCheckResultError::Validation(ref cause) => cause,
DescribeTrustedAdvisorCheckResultError::Credentials(ref err) => err.description(),
DescribeTrustedAdvisorCheckResultError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
DescribeTrustedAdvisorCheckResultError::ParseError(ref cause) => cause,
DescribeTrustedAdvisorCheckResultError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DescribeTrustedAdvisorCheckSummariesError {
InternalServerError(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DescribeTrustedAdvisorCheckSummariesError {
pub fn from_response(res: BufferedHttpResponse) -> DescribeTrustedAdvisorCheckSummariesError {
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 {
"InternalServerError" => {
return DescribeTrustedAdvisorCheckSummariesError::InternalServerError(
String::from(error_message),
);
}
"ValidationException" => {
return DescribeTrustedAdvisorCheckSummariesError::Validation(
error_message.to_string(),
);
}
_ => {}
}
}
return DescribeTrustedAdvisorCheckSummariesError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DescribeTrustedAdvisorCheckSummariesError {
fn from(err: serde_json::error::Error) -> DescribeTrustedAdvisorCheckSummariesError {
DescribeTrustedAdvisorCheckSummariesError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DescribeTrustedAdvisorCheckSummariesError {
fn from(err: CredentialsError) -> DescribeTrustedAdvisorCheckSummariesError {
DescribeTrustedAdvisorCheckSummariesError::Credentials(err)
}
}
impl From<HttpDispatchError> for DescribeTrustedAdvisorCheckSummariesError {
fn from(err: HttpDispatchError) -> DescribeTrustedAdvisorCheckSummariesError {
DescribeTrustedAdvisorCheckSummariesError::HttpDispatch(err)
}
}
impl From<io::Error> for DescribeTrustedAdvisorCheckSummariesError {
fn from(err: io::Error) -> DescribeTrustedAdvisorCheckSummariesError {
DescribeTrustedAdvisorCheckSummariesError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DescribeTrustedAdvisorCheckSummariesError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DescribeTrustedAdvisorCheckSummariesError {
fn description(&self) -> &str {
match *self {
DescribeTrustedAdvisorCheckSummariesError::InternalServerError(ref cause) => cause,
DescribeTrustedAdvisorCheckSummariesError::Validation(ref cause) => cause,
DescribeTrustedAdvisorCheckSummariesError::Credentials(ref err) => err.description(),
DescribeTrustedAdvisorCheckSummariesError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
DescribeTrustedAdvisorCheckSummariesError::ParseError(ref cause) => cause,
DescribeTrustedAdvisorCheckSummariesError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DescribeTrustedAdvisorChecksError {
InternalServerError(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DescribeTrustedAdvisorChecksError {
pub fn from_response(res: BufferedHttpResponse) -> DescribeTrustedAdvisorChecksError {
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 {
"InternalServerError" => {
return DescribeTrustedAdvisorChecksError::InternalServerError(String::from(
error_message,
));
}
"ValidationException" => {
return DescribeTrustedAdvisorChecksError::Validation(error_message.to_string());
}
_ => {}
}
}
return DescribeTrustedAdvisorChecksError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DescribeTrustedAdvisorChecksError {
fn from(err: serde_json::error::Error) -> DescribeTrustedAdvisorChecksError {
DescribeTrustedAdvisorChecksError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DescribeTrustedAdvisorChecksError {
fn from(err: CredentialsError) -> DescribeTrustedAdvisorChecksError {
DescribeTrustedAdvisorChecksError::Credentials(err)
}
}
impl From<HttpDispatchError> for DescribeTrustedAdvisorChecksError {
fn from(err: HttpDispatchError) -> DescribeTrustedAdvisorChecksError {
DescribeTrustedAdvisorChecksError::HttpDispatch(err)
}
}
impl From<io::Error> for DescribeTrustedAdvisorChecksError {
fn from(err: io::Error) -> DescribeTrustedAdvisorChecksError {
DescribeTrustedAdvisorChecksError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DescribeTrustedAdvisorChecksError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DescribeTrustedAdvisorChecksError {
fn description(&self) -> &str {
match *self {
DescribeTrustedAdvisorChecksError::InternalServerError(ref cause) => cause,
DescribeTrustedAdvisorChecksError::Validation(ref cause) => cause,
DescribeTrustedAdvisorChecksError::Credentials(ref err) => err.description(),
DescribeTrustedAdvisorChecksError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
DescribeTrustedAdvisorChecksError::ParseError(ref cause) => cause,
DescribeTrustedAdvisorChecksError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum RefreshTrustedAdvisorCheckError {
InternalServerError(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl RefreshTrustedAdvisorCheckError {
pub fn from_response(res: BufferedHttpResponse) -> RefreshTrustedAdvisorCheckError {
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 {
"InternalServerError" => {
return RefreshTrustedAdvisorCheckError::InternalServerError(String::from(
error_message,
));
}
"ValidationException" => {
return RefreshTrustedAdvisorCheckError::Validation(error_message.to_string());
}
_ => {}
}
}
return RefreshTrustedAdvisorCheckError::Unknown(res);
}
}
impl From<serde_json::error::Error> for RefreshTrustedAdvisorCheckError {
fn from(err: serde_json::error::Error) -> RefreshTrustedAdvisorCheckError {
RefreshTrustedAdvisorCheckError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for RefreshTrustedAdvisorCheckError {
fn from(err: CredentialsError) -> RefreshTrustedAdvisorCheckError {
RefreshTrustedAdvisorCheckError::Credentials(err)
}
}
impl From<HttpDispatchError> for RefreshTrustedAdvisorCheckError {
fn from(err: HttpDispatchError) -> RefreshTrustedAdvisorCheckError {
RefreshTrustedAdvisorCheckError::HttpDispatch(err)
}
}
impl From<io::Error> for RefreshTrustedAdvisorCheckError {
fn from(err: io::Error) -> RefreshTrustedAdvisorCheckError {
RefreshTrustedAdvisorCheckError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for RefreshTrustedAdvisorCheckError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for RefreshTrustedAdvisorCheckError {
fn description(&self) -> &str {
match *self {
RefreshTrustedAdvisorCheckError::InternalServerError(ref cause) => cause,
RefreshTrustedAdvisorCheckError::Validation(ref cause) => cause,
RefreshTrustedAdvisorCheckError::Credentials(ref err) => err.description(),
RefreshTrustedAdvisorCheckError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
RefreshTrustedAdvisorCheckError::ParseError(ref cause) => cause,
RefreshTrustedAdvisorCheckError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum ResolveCaseError {
CaseIdNotFound(String),
InternalServerError(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl ResolveCaseError {
pub fn from_response(res: BufferedHttpResponse) -> ResolveCaseError {
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 {
"CaseIdNotFound" => {
return ResolveCaseError::CaseIdNotFound(String::from(error_message));
}
"InternalServerError" => {
return ResolveCaseError::InternalServerError(String::from(error_message));
}
"ValidationException" => {
return ResolveCaseError::Validation(error_message.to_string());
}
_ => {}
}
}
return ResolveCaseError::Unknown(res);
}
}
impl From<serde_json::error::Error> for ResolveCaseError {
fn from(err: serde_json::error::Error) -> ResolveCaseError {
ResolveCaseError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for ResolveCaseError {
fn from(err: CredentialsError) -> ResolveCaseError {
ResolveCaseError::Credentials(err)
}
}
impl From<HttpDispatchError> for ResolveCaseError {
fn from(err: HttpDispatchError) -> ResolveCaseError {
ResolveCaseError::HttpDispatch(err)
}
}
impl From<io::Error> for ResolveCaseError {
fn from(err: io::Error) -> ResolveCaseError {
ResolveCaseError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for ResolveCaseError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for ResolveCaseError {
fn description(&self) -> &str {
match *self {
ResolveCaseError::CaseIdNotFound(ref cause) => cause,
ResolveCaseError::InternalServerError(ref cause) => cause,
ResolveCaseError::Validation(ref cause) => cause,
ResolveCaseError::Credentials(ref err) => err.description(),
ResolveCaseError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
ResolveCaseError::ParseError(ref cause) => cause,
ResolveCaseError::Unknown(_) => "unknown error",
}
}
}
pub trait AWSSupport {
fn add_attachments_to_set(
&self,
input: AddAttachmentsToSetRequest,
) -> RusotoFuture<AddAttachmentsToSetResponse, AddAttachmentsToSetError>;
fn add_communication_to_case(
&self,
input: AddCommunicationToCaseRequest,
) -> RusotoFuture<AddCommunicationToCaseResponse, AddCommunicationToCaseError>;
fn create_case(
&self,
input: CreateCaseRequest,
) -> RusotoFuture<CreateCaseResponse, CreateCaseError>;
fn describe_attachment(
&self,
input: DescribeAttachmentRequest,
) -> RusotoFuture<DescribeAttachmentResponse, DescribeAttachmentError>;
fn describe_cases(
&self,
input: DescribeCasesRequest,
) -> RusotoFuture<DescribeCasesResponse, DescribeCasesError>;
fn describe_communications(
&self,
input: DescribeCommunicationsRequest,
) -> RusotoFuture<DescribeCommunicationsResponse, DescribeCommunicationsError>;
fn describe_services(
&self,
input: DescribeServicesRequest,
) -> RusotoFuture<DescribeServicesResponse, DescribeServicesError>;
fn describe_severity_levels(
&self,
input: DescribeSeverityLevelsRequest,
) -> RusotoFuture<DescribeSeverityLevelsResponse, DescribeSeverityLevelsError>;
fn describe_trusted_advisor_check_refresh_statuses(
&self,
input: DescribeTrustedAdvisorCheckRefreshStatusesRequest,
) -> RusotoFuture<
DescribeTrustedAdvisorCheckRefreshStatusesResponse,
DescribeTrustedAdvisorCheckRefreshStatusesError,
>;
fn describe_trusted_advisor_check_result(
&self,
input: DescribeTrustedAdvisorCheckResultRequest,
) -> RusotoFuture<
DescribeTrustedAdvisorCheckResultResponse,
DescribeTrustedAdvisorCheckResultError,
>;
fn describe_trusted_advisor_check_summaries(
&self,
input: DescribeTrustedAdvisorCheckSummariesRequest,
) -> RusotoFuture<
DescribeTrustedAdvisorCheckSummariesResponse,
DescribeTrustedAdvisorCheckSummariesError,
>;
fn describe_trusted_advisor_checks(
&self,
input: DescribeTrustedAdvisorChecksRequest,
) -> RusotoFuture<DescribeTrustedAdvisorChecksResponse, DescribeTrustedAdvisorChecksError>;
fn refresh_trusted_advisor_check(
&self,
input: RefreshTrustedAdvisorCheckRequest,
) -> RusotoFuture<RefreshTrustedAdvisorCheckResponse, RefreshTrustedAdvisorCheckError>;
fn resolve_case(
&self,
input: ResolveCaseRequest,
) -> RusotoFuture<ResolveCaseResponse, ResolveCaseError>;
}
#[derive(Clone)]
pub struct AWSSupportClient {
client: Client,
region: region::Region,
}
impl AWSSupportClient {
pub fn new(region: region::Region) -> AWSSupportClient {
AWSSupportClient {
client: Client::shared(),
region: region,
}
}
pub fn new_with<P, D>(
request_dispatcher: D,
credentials_provider: P,
region: region::Region,
) -> AWSSupportClient
where
P: ProvideAwsCredentials + Send + Sync + 'static,
P::Future: Send,
D: DispatchSignedRequest + Send + Sync + 'static,
D::Future: Send,
{
AWSSupportClient {
client: Client::new_with(credentials_provider, request_dispatcher),
region: region,
}
}
}
impl AWSSupport for AWSSupportClient {
fn add_attachments_to_set(
&self,
input: AddAttachmentsToSetRequest,
) -> RusotoFuture<AddAttachmentsToSetResponse, AddAttachmentsToSetError> {
let mut request = SignedRequest::new("POST", "support", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AWSSupport_20130415.AddAttachmentsToSet");
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::<AddAttachmentsToSetResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response.buffer().from_err().and_then(|response| {
Err(AddAttachmentsToSetError::from_response(response))
}),
)
}
})
}
fn add_communication_to_case(
&self,
input: AddCommunicationToCaseRequest,
) -> RusotoFuture<AddCommunicationToCaseResponse, AddCommunicationToCaseError> {
let mut request = SignedRequest::new("POST", "support", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AWSSupport_20130415.AddCommunicationToCase");
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::<AddCommunicationToCaseResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response.buffer().from_err().and_then(|response| {
Err(AddCommunicationToCaseError::from_response(response))
}),
)
}
})
}
fn create_case(
&self,
input: CreateCaseRequest,
) -> RusotoFuture<CreateCaseResponse, CreateCaseError> {
let mut request = SignedRequest::new("POST", "support", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AWSSupport_20130415.CreateCase");
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::<CreateCaseResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(CreateCaseError::from_response(response))),
)
}
})
}
fn describe_attachment(
&self,
input: DescribeAttachmentRequest,
) -> RusotoFuture<DescribeAttachmentResponse, DescribeAttachmentError> {
let mut request = SignedRequest::new("POST", "support", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AWSSupport_20130415.DescribeAttachment");
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::<DescribeAttachmentResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DescribeAttachmentError::from_response(response))),
)
}
})
}
fn describe_cases(
&self,
input: DescribeCasesRequest,
) -> RusotoFuture<DescribeCasesResponse, DescribeCasesError> {
let mut request = SignedRequest::new("POST", "support", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AWSSupport_20130415.DescribeCases");
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::<DescribeCasesResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DescribeCasesError::from_response(response))),
)
}
})
}
fn describe_communications(
&self,
input: DescribeCommunicationsRequest,
) -> RusotoFuture<DescribeCommunicationsResponse, DescribeCommunicationsError> {
let mut request = SignedRequest::new("POST", "support", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AWSSupport_20130415.DescribeCommunications");
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::<DescribeCommunicationsResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response.buffer().from_err().and_then(|response| {
Err(DescribeCommunicationsError::from_response(response))
}),
)
}
})
}
fn describe_services(
&self,
input: DescribeServicesRequest,
) -> RusotoFuture<DescribeServicesResponse, DescribeServicesError> {
let mut request = SignedRequest::new("POST", "support", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AWSSupport_20130415.DescribeServices");
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::<DescribeServicesResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DescribeServicesError::from_response(response))),
)
}
})
}
fn describe_severity_levels(
&self,
input: DescribeSeverityLevelsRequest,
) -> RusotoFuture<DescribeSeverityLevelsResponse, DescribeSeverityLevelsError> {
let mut request = SignedRequest::new("POST", "support", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AWSSupport_20130415.DescribeSeverityLevels");
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::<DescribeSeverityLevelsResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response.buffer().from_err().and_then(|response| {
Err(DescribeSeverityLevelsError::from_response(response))
}),
)
}
})
}
fn describe_trusted_advisor_check_refresh_statuses(
&self,
input: DescribeTrustedAdvisorCheckRefreshStatusesRequest,
) -> RusotoFuture<
DescribeTrustedAdvisorCheckRefreshStatusesResponse,
DescribeTrustedAdvisorCheckRefreshStatusesError,
> {
let mut request = SignedRequest::new("POST", "support", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header(
"x-amz-target",
"AWSSupport_20130415.DescribeTrustedAdvisorCheckRefreshStatuses",
);
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::<DescribeTrustedAdvisorCheckRefreshStatusesResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(DescribeTrustedAdvisorCheckRefreshStatusesError::from_response(response))
}))
}
})
}
fn describe_trusted_advisor_check_result(
&self,
input: DescribeTrustedAdvisorCheckResultRequest,
) -> RusotoFuture<
DescribeTrustedAdvisorCheckResultResponse,
DescribeTrustedAdvisorCheckResultError,
> {
let mut request = SignedRequest::new("POST", "support", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header(
"x-amz-target",
"AWSSupport_20130415.DescribeTrustedAdvisorCheckResult",
);
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::<DescribeTrustedAdvisorCheckResultResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(DescribeTrustedAdvisorCheckResultError::from_response(
response,
))
}))
}
})
}
fn describe_trusted_advisor_check_summaries(
&self,
input: DescribeTrustedAdvisorCheckSummariesRequest,
) -> RusotoFuture<
DescribeTrustedAdvisorCheckSummariesResponse,
DescribeTrustedAdvisorCheckSummariesError,
> {
let mut request = SignedRequest::new("POST", "support", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header(
"x-amz-target",
"AWSSupport_20130415.DescribeTrustedAdvisorCheckSummaries",
);
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::<DescribeTrustedAdvisorCheckSummariesResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(DescribeTrustedAdvisorCheckSummariesError::from_response(
response,
))
}))
}
})
}
fn describe_trusted_advisor_checks(
&self,
input: DescribeTrustedAdvisorChecksRequest,
) -> RusotoFuture<DescribeTrustedAdvisorChecksResponse, DescribeTrustedAdvisorChecksError> {
let mut request = SignedRequest::new("POST", "support", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header(
"x-amz-target",
"AWSSupport_20130415.DescribeTrustedAdvisorChecks",
);
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::<DescribeTrustedAdvisorChecksResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(DescribeTrustedAdvisorChecksError::from_response(response))
}))
}
})
}
fn refresh_trusted_advisor_check(
&self,
input: RefreshTrustedAdvisorCheckRequest,
) -> RusotoFuture<RefreshTrustedAdvisorCheckResponse, RefreshTrustedAdvisorCheckError> {
let mut request = SignedRequest::new("POST", "support", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header(
"x-amz-target",
"AWSSupport_20130415.RefreshTrustedAdvisorCheck",
);
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::<RefreshTrustedAdvisorCheckResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(RefreshTrustedAdvisorCheckError::from_response(response))
}))
}
})
}
fn resolve_case(
&self,
input: ResolveCaseRequest,
) -> RusotoFuture<ResolveCaseResponse, ResolveCaseError> {
let mut request = SignedRequest::new("POST", "support", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AWSSupport_20130415.ResolveCase");
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::<ResolveCaseResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(ResolveCaseError::from_response(response))),
)
}
})
}
}
#[cfg(test)]
mod protocol_tests {}