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, Deserialize)]
pub struct Budget {
#[serde(rename = "BudgetLimit")]
#[serde(skip_serializing_if = "Option::is_none")]
pub budget_limit: Option<Spend>,
#[serde(rename = "BudgetName")]
pub budget_name: String,
#[serde(rename = "BudgetType")]
pub budget_type: String,
#[serde(rename = "CalculatedSpend")]
#[serde(skip_serializing_if = "Option::is_none")]
pub calculated_spend: Option<CalculatedSpend>,
#[serde(rename = "CostFilters")]
#[serde(skip_serializing_if = "Option::is_none")]
pub cost_filters: Option<::std::collections::HashMap<String, Vec<String>>>,
#[serde(rename = "CostTypes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub cost_types: Option<CostTypes>,
#[serde(rename = "LastUpdatedTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_updated_time: Option<f64>,
#[serde(rename = "TimePeriod")]
#[serde(skip_serializing_if = "Option::is_none")]
pub time_period: Option<TimePeriod>,
#[serde(rename = "TimeUnit")]
pub time_unit: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct BudgetPerformanceHistory {
#[serde(rename = "BudgetName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub budget_name: Option<String>,
#[serde(rename = "BudgetType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub budget_type: Option<String>,
#[serde(rename = "BudgetedAndActualAmountsList")]
#[serde(skip_serializing_if = "Option::is_none")]
pub budgeted_and_actual_amounts_list: Option<Vec<BudgetedAndActualAmounts>>,
#[serde(rename = "CostFilters")]
#[serde(skip_serializing_if = "Option::is_none")]
pub cost_filters: Option<::std::collections::HashMap<String, Vec<String>>>,
#[serde(rename = "CostTypes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub cost_types: Option<CostTypes>,
#[serde(rename = "TimeUnit")]
#[serde(skip_serializing_if = "Option::is_none")]
pub time_unit: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct BudgetedAndActualAmounts {
#[serde(rename = "ActualAmount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub actual_amount: Option<Spend>,
#[serde(rename = "BudgetedAmount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub budgeted_amount: Option<Spend>,
#[serde(rename = "TimePeriod")]
#[serde(skip_serializing_if = "Option::is_none")]
pub time_period: Option<TimePeriod>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct CalculatedSpend {
#[serde(rename = "ActualSpend")]
pub actual_spend: Spend,
#[serde(rename = "ForecastedSpend")]
#[serde(skip_serializing_if = "Option::is_none")]
pub forecasted_spend: Option<Spend>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct CostTypes {
#[serde(rename = "IncludeCredit")]
#[serde(skip_serializing_if = "Option::is_none")]
pub include_credit: Option<bool>,
#[serde(rename = "IncludeDiscount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub include_discount: Option<bool>,
#[serde(rename = "IncludeOtherSubscription")]
#[serde(skip_serializing_if = "Option::is_none")]
pub include_other_subscription: Option<bool>,
#[serde(rename = "IncludeRecurring")]
#[serde(skip_serializing_if = "Option::is_none")]
pub include_recurring: Option<bool>,
#[serde(rename = "IncludeRefund")]
#[serde(skip_serializing_if = "Option::is_none")]
pub include_refund: Option<bool>,
#[serde(rename = "IncludeSubscription")]
#[serde(skip_serializing_if = "Option::is_none")]
pub include_subscription: Option<bool>,
#[serde(rename = "IncludeSupport")]
#[serde(skip_serializing_if = "Option::is_none")]
pub include_support: Option<bool>,
#[serde(rename = "IncludeTax")]
#[serde(skip_serializing_if = "Option::is_none")]
pub include_tax: Option<bool>,
#[serde(rename = "IncludeUpfront")]
#[serde(skip_serializing_if = "Option::is_none")]
pub include_upfront: Option<bool>,
#[serde(rename = "UseAmortized")]
#[serde(skip_serializing_if = "Option::is_none")]
pub use_amortized: Option<bool>,
#[serde(rename = "UseBlended")]
#[serde(skip_serializing_if = "Option::is_none")]
pub use_blended: Option<bool>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct CreateBudgetRequest {
#[serde(rename = "AccountId")]
pub account_id: String,
#[serde(rename = "Budget")]
pub budget: Budget,
#[serde(rename = "NotificationsWithSubscribers")]
#[serde(skip_serializing_if = "Option::is_none")]
pub notifications_with_subscribers: Option<Vec<NotificationWithSubscribers>>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct CreateBudgetResponse {}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct CreateNotificationRequest {
#[serde(rename = "AccountId")]
pub account_id: String,
#[serde(rename = "BudgetName")]
pub budget_name: String,
#[serde(rename = "Notification")]
pub notification: Notification,
#[serde(rename = "Subscribers")]
pub subscribers: Vec<Subscriber>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct CreateNotificationResponse {}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct CreateSubscriberRequest {
#[serde(rename = "AccountId")]
pub account_id: String,
#[serde(rename = "BudgetName")]
pub budget_name: String,
#[serde(rename = "Notification")]
pub notification: Notification,
#[serde(rename = "Subscriber")]
pub subscriber: Subscriber,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct CreateSubscriberResponse {}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DeleteBudgetRequest {
#[serde(rename = "AccountId")]
pub account_id: String,
#[serde(rename = "BudgetName")]
pub budget_name: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DeleteBudgetResponse {}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DeleteNotificationRequest {
#[serde(rename = "AccountId")]
pub account_id: String,
#[serde(rename = "BudgetName")]
pub budget_name: String,
#[serde(rename = "Notification")]
pub notification: Notification,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DeleteNotificationResponse {}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DeleteSubscriberRequest {
#[serde(rename = "AccountId")]
pub account_id: String,
#[serde(rename = "BudgetName")]
pub budget_name: String,
#[serde(rename = "Notification")]
pub notification: Notification,
#[serde(rename = "Subscriber")]
pub subscriber: Subscriber,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DeleteSubscriberResponse {}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DescribeBudgetPerformanceHistoryRequest {
#[serde(rename = "AccountId")]
pub account_id: String,
#[serde(rename = "BudgetName")]
pub budget_name: 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>,
#[serde(rename = "TimePeriod")]
#[serde(skip_serializing_if = "Option::is_none")]
pub time_period: Option<TimePeriod>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DescribeBudgetPerformanceHistoryResponse {
#[serde(rename = "BudgetPerformanceHistory")]
#[serde(skip_serializing_if = "Option::is_none")]
pub budget_performance_history: Option<BudgetPerformanceHistory>,
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DescribeBudgetRequest {
#[serde(rename = "AccountId")]
pub account_id: String,
#[serde(rename = "BudgetName")]
pub budget_name: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DescribeBudgetResponse {
#[serde(rename = "Budget")]
#[serde(skip_serializing_if = "Option::is_none")]
pub budget: Option<Budget>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DescribeBudgetsRequest {
#[serde(rename = "AccountId")]
pub account_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 DescribeBudgetsResponse {
#[serde(rename = "Budgets")]
#[serde(skip_serializing_if = "Option::is_none")]
pub budgets: Option<Vec<Budget>>,
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DescribeNotificationsForBudgetRequest {
#[serde(rename = "AccountId")]
pub account_id: String,
#[serde(rename = "BudgetName")]
pub budget_name: 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 DescribeNotificationsForBudgetResponse {
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
#[serde(rename = "Notifications")]
#[serde(skip_serializing_if = "Option::is_none")]
pub notifications: Option<Vec<Notification>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DescribeSubscribersForNotificationRequest {
#[serde(rename = "AccountId")]
pub account_id: String,
#[serde(rename = "BudgetName")]
pub budget_name: 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>,
#[serde(rename = "Notification")]
pub notification: Notification,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DescribeSubscribersForNotificationResponse {
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
#[serde(rename = "Subscribers")]
#[serde(skip_serializing_if = "Option::is_none")]
pub subscribers: Option<Vec<Subscriber>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Notification {
#[serde(rename = "ComparisonOperator")]
pub comparison_operator: String,
#[serde(rename = "NotificationState")]
#[serde(skip_serializing_if = "Option::is_none")]
pub notification_state: Option<String>,
#[serde(rename = "NotificationType")]
pub notification_type: String,
#[serde(rename = "Threshold")]
pub threshold: f64,
#[serde(rename = "ThresholdType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub threshold_type: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct NotificationWithSubscribers {
#[serde(rename = "Notification")]
pub notification: Notification,
#[serde(rename = "Subscribers")]
pub subscribers: Vec<Subscriber>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Spend {
#[serde(rename = "Amount")]
pub amount: String,
#[serde(rename = "Unit")]
pub unit: String,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Subscriber {
#[serde(rename = "Address")]
pub address: String,
#[serde(rename = "SubscriptionType")]
pub subscription_type: String,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct TimePeriod {
#[serde(rename = "End")]
#[serde(skip_serializing_if = "Option::is_none")]
pub end: Option<f64>,
#[serde(rename = "Start")]
#[serde(skip_serializing_if = "Option::is_none")]
pub start: Option<f64>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct UpdateBudgetRequest {
#[serde(rename = "AccountId")]
pub account_id: String,
#[serde(rename = "NewBudget")]
pub new_budget: Budget,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct UpdateBudgetResponse {}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct UpdateNotificationRequest {
#[serde(rename = "AccountId")]
pub account_id: String,
#[serde(rename = "BudgetName")]
pub budget_name: String,
#[serde(rename = "NewNotification")]
pub new_notification: Notification,
#[serde(rename = "OldNotification")]
pub old_notification: Notification,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct UpdateNotificationResponse {}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct UpdateSubscriberRequest {
#[serde(rename = "AccountId")]
pub account_id: String,
#[serde(rename = "BudgetName")]
pub budget_name: String,
#[serde(rename = "NewSubscriber")]
pub new_subscriber: Subscriber,
#[serde(rename = "Notification")]
pub notification: Notification,
#[serde(rename = "OldSubscriber")]
pub old_subscriber: Subscriber,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct UpdateSubscriberResponse {}
#[derive(Debug, PartialEq)]
pub enum CreateBudgetError {
CreationLimitExceeded(String),
DuplicateRecord(String),
InternalError(String),
InvalidParameter(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl CreateBudgetError {
pub fn from_response(res: BufferedHttpResponse) -> CreateBudgetError {
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 {
"CreationLimitExceededException" => {
return CreateBudgetError::CreationLimitExceeded(String::from(error_message));
}
"DuplicateRecordException" => {
return CreateBudgetError::DuplicateRecord(String::from(error_message));
}
"InternalErrorException" => {
return CreateBudgetError::InternalError(String::from(error_message));
}
"InvalidParameterException" => {
return CreateBudgetError::InvalidParameter(String::from(error_message));
}
"ValidationException" => {
return CreateBudgetError::Validation(error_message.to_string());
}
_ => {}
}
}
return CreateBudgetError::Unknown(res);
}
}
impl From<serde_json::error::Error> for CreateBudgetError {
fn from(err: serde_json::error::Error) -> CreateBudgetError {
CreateBudgetError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for CreateBudgetError {
fn from(err: CredentialsError) -> CreateBudgetError {
CreateBudgetError::Credentials(err)
}
}
impl From<HttpDispatchError> for CreateBudgetError {
fn from(err: HttpDispatchError) -> CreateBudgetError {
CreateBudgetError::HttpDispatch(err)
}
}
impl From<io::Error> for CreateBudgetError {
fn from(err: io::Error) -> CreateBudgetError {
CreateBudgetError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for CreateBudgetError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for CreateBudgetError {
fn description(&self) -> &str {
match *self {
CreateBudgetError::CreationLimitExceeded(ref cause) => cause,
CreateBudgetError::DuplicateRecord(ref cause) => cause,
CreateBudgetError::InternalError(ref cause) => cause,
CreateBudgetError::InvalidParameter(ref cause) => cause,
CreateBudgetError::Validation(ref cause) => cause,
CreateBudgetError::Credentials(ref err) => err.description(),
CreateBudgetError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
CreateBudgetError::ParseError(ref cause) => cause,
CreateBudgetError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum CreateNotificationError {
CreationLimitExceeded(String),
DuplicateRecord(String),
InternalError(String),
InvalidParameter(String),
NotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl CreateNotificationError {
pub fn from_response(res: BufferedHttpResponse) -> CreateNotificationError {
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 {
"CreationLimitExceededException" => {
return CreateNotificationError::CreationLimitExceeded(String::from(
error_message,
));
}
"DuplicateRecordException" => {
return CreateNotificationError::DuplicateRecord(String::from(error_message));
}
"InternalErrorException" => {
return CreateNotificationError::InternalError(String::from(error_message));
}
"InvalidParameterException" => {
return CreateNotificationError::InvalidParameter(String::from(error_message));
}
"NotFoundException" => {
return CreateNotificationError::NotFound(String::from(error_message));
}
"ValidationException" => {
return CreateNotificationError::Validation(error_message.to_string());
}
_ => {}
}
}
return CreateNotificationError::Unknown(res);
}
}
impl From<serde_json::error::Error> for CreateNotificationError {
fn from(err: serde_json::error::Error) -> CreateNotificationError {
CreateNotificationError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for CreateNotificationError {
fn from(err: CredentialsError) -> CreateNotificationError {
CreateNotificationError::Credentials(err)
}
}
impl From<HttpDispatchError> for CreateNotificationError {
fn from(err: HttpDispatchError) -> CreateNotificationError {
CreateNotificationError::HttpDispatch(err)
}
}
impl From<io::Error> for CreateNotificationError {
fn from(err: io::Error) -> CreateNotificationError {
CreateNotificationError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for CreateNotificationError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for CreateNotificationError {
fn description(&self) -> &str {
match *self {
CreateNotificationError::CreationLimitExceeded(ref cause) => cause,
CreateNotificationError::DuplicateRecord(ref cause) => cause,
CreateNotificationError::InternalError(ref cause) => cause,
CreateNotificationError::InvalidParameter(ref cause) => cause,
CreateNotificationError::NotFound(ref cause) => cause,
CreateNotificationError::Validation(ref cause) => cause,
CreateNotificationError::Credentials(ref err) => err.description(),
CreateNotificationError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
CreateNotificationError::ParseError(ref cause) => cause,
CreateNotificationError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum CreateSubscriberError {
CreationLimitExceeded(String),
DuplicateRecord(String),
InternalError(String),
InvalidParameter(String),
NotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl CreateSubscriberError {
pub fn from_response(res: BufferedHttpResponse) -> CreateSubscriberError {
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 {
"CreationLimitExceededException" => {
return CreateSubscriberError::CreationLimitExceeded(String::from(error_message));
}
"DuplicateRecordException" => {
return CreateSubscriberError::DuplicateRecord(String::from(error_message));
}
"InternalErrorException" => {
return CreateSubscriberError::InternalError(String::from(error_message));
}
"InvalidParameterException" => {
return CreateSubscriberError::InvalidParameter(String::from(error_message));
}
"NotFoundException" => {
return CreateSubscriberError::NotFound(String::from(error_message));
}
"ValidationException" => {
return CreateSubscriberError::Validation(error_message.to_string());
}
_ => {}
}
}
return CreateSubscriberError::Unknown(res);
}
}
impl From<serde_json::error::Error> for CreateSubscriberError {
fn from(err: serde_json::error::Error) -> CreateSubscriberError {
CreateSubscriberError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for CreateSubscriberError {
fn from(err: CredentialsError) -> CreateSubscriberError {
CreateSubscriberError::Credentials(err)
}
}
impl From<HttpDispatchError> for CreateSubscriberError {
fn from(err: HttpDispatchError) -> CreateSubscriberError {
CreateSubscriberError::HttpDispatch(err)
}
}
impl From<io::Error> for CreateSubscriberError {
fn from(err: io::Error) -> CreateSubscriberError {
CreateSubscriberError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for CreateSubscriberError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for CreateSubscriberError {
fn description(&self) -> &str {
match *self {
CreateSubscriberError::CreationLimitExceeded(ref cause) => cause,
CreateSubscriberError::DuplicateRecord(ref cause) => cause,
CreateSubscriberError::InternalError(ref cause) => cause,
CreateSubscriberError::InvalidParameter(ref cause) => cause,
CreateSubscriberError::NotFound(ref cause) => cause,
CreateSubscriberError::Validation(ref cause) => cause,
CreateSubscriberError::Credentials(ref err) => err.description(),
CreateSubscriberError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
CreateSubscriberError::ParseError(ref cause) => cause,
CreateSubscriberError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DeleteBudgetError {
InternalError(String),
InvalidParameter(String),
NotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DeleteBudgetError {
pub fn from_response(res: BufferedHttpResponse) -> DeleteBudgetError {
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 DeleteBudgetError::InternalError(String::from(error_message));
}
"InvalidParameterException" => {
return DeleteBudgetError::InvalidParameter(String::from(error_message));
}
"NotFoundException" => {
return DeleteBudgetError::NotFound(String::from(error_message));
}
"ValidationException" => {
return DeleteBudgetError::Validation(error_message.to_string());
}
_ => {}
}
}
return DeleteBudgetError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DeleteBudgetError {
fn from(err: serde_json::error::Error) -> DeleteBudgetError {
DeleteBudgetError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DeleteBudgetError {
fn from(err: CredentialsError) -> DeleteBudgetError {
DeleteBudgetError::Credentials(err)
}
}
impl From<HttpDispatchError> for DeleteBudgetError {
fn from(err: HttpDispatchError) -> DeleteBudgetError {
DeleteBudgetError::HttpDispatch(err)
}
}
impl From<io::Error> for DeleteBudgetError {
fn from(err: io::Error) -> DeleteBudgetError {
DeleteBudgetError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DeleteBudgetError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DeleteBudgetError {
fn description(&self) -> &str {
match *self {
DeleteBudgetError::InternalError(ref cause) => cause,
DeleteBudgetError::InvalidParameter(ref cause) => cause,
DeleteBudgetError::NotFound(ref cause) => cause,
DeleteBudgetError::Validation(ref cause) => cause,
DeleteBudgetError::Credentials(ref err) => err.description(),
DeleteBudgetError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
DeleteBudgetError::ParseError(ref cause) => cause,
DeleteBudgetError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DeleteNotificationError {
InternalError(String),
InvalidParameter(String),
NotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DeleteNotificationError {
pub fn from_response(res: BufferedHttpResponse) -> DeleteNotificationError {
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 DeleteNotificationError::InternalError(String::from(error_message));
}
"InvalidParameterException" => {
return DeleteNotificationError::InvalidParameter(String::from(error_message));
}
"NotFoundException" => {
return DeleteNotificationError::NotFound(String::from(error_message));
}
"ValidationException" => {
return DeleteNotificationError::Validation(error_message.to_string());
}
_ => {}
}
}
return DeleteNotificationError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DeleteNotificationError {
fn from(err: serde_json::error::Error) -> DeleteNotificationError {
DeleteNotificationError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DeleteNotificationError {
fn from(err: CredentialsError) -> DeleteNotificationError {
DeleteNotificationError::Credentials(err)
}
}
impl From<HttpDispatchError> for DeleteNotificationError {
fn from(err: HttpDispatchError) -> DeleteNotificationError {
DeleteNotificationError::HttpDispatch(err)
}
}
impl From<io::Error> for DeleteNotificationError {
fn from(err: io::Error) -> DeleteNotificationError {
DeleteNotificationError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DeleteNotificationError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DeleteNotificationError {
fn description(&self) -> &str {
match *self {
DeleteNotificationError::InternalError(ref cause) => cause,
DeleteNotificationError::InvalidParameter(ref cause) => cause,
DeleteNotificationError::NotFound(ref cause) => cause,
DeleteNotificationError::Validation(ref cause) => cause,
DeleteNotificationError::Credentials(ref err) => err.description(),
DeleteNotificationError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
DeleteNotificationError::ParseError(ref cause) => cause,
DeleteNotificationError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DeleteSubscriberError {
InternalError(String),
InvalidParameter(String),
NotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DeleteSubscriberError {
pub fn from_response(res: BufferedHttpResponse) -> DeleteSubscriberError {
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 DeleteSubscriberError::InternalError(String::from(error_message));
}
"InvalidParameterException" => {
return DeleteSubscriberError::InvalidParameter(String::from(error_message));
}
"NotFoundException" => {
return DeleteSubscriberError::NotFound(String::from(error_message));
}
"ValidationException" => {
return DeleteSubscriberError::Validation(error_message.to_string());
}
_ => {}
}
}
return DeleteSubscriberError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DeleteSubscriberError {
fn from(err: serde_json::error::Error) -> DeleteSubscriberError {
DeleteSubscriberError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DeleteSubscriberError {
fn from(err: CredentialsError) -> DeleteSubscriberError {
DeleteSubscriberError::Credentials(err)
}
}
impl From<HttpDispatchError> for DeleteSubscriberError {
fn from(err: HttpDispatchError) -> DeleteSubscriberError {
DeleteSubscriberError::HttpDispatch(err)
}
}
impl From<io::Error> for DeleteSubscriberError {
fn from(err: io::Error) -> DeleteSubscriberError {
DeleteSubscriberError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DeleteSubscriberError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DeleteSubscriberError {
fn description(&self) -> &str {
match *self {
DeleteSubscriberError::InternalError(ref cause) => cause,
DeleteSubscriberError::InvalidParameter(ref cause) => cause,
DeleteSubscriberError::NotFound(ref cause) => cause,
DeleteSubscriberError::Validation(ref cause) => cause,
DeleteSubscriberError::Credentials(ref err) => err.description(),
DeleteSubscriberError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
DeleteSubscriberError::ParseError(ref cause) => cause,
DeleteSubscriberError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DescribeBudgetError {
InternalError(String),
InvalidParameter(String),
NotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DescribeBudgetError {
pub fn from_response(res: BufferedHttpResponse) -> DescribeBudgetError {
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 DescribeBudgetError::InternalError(String::from(error_message));
}
"InvalidParameterException" => {
return DescribeBudgetError::InvalidParameter(String::from(error_message));
}
"NotFoundException" => {
return DescribeBudgetError::NotFound(String::from(error_message));
}
"ValidationException" => {
return DescribeBudgetError::Validation(error_message.to_string());
}
_ => {}
}
}
return DescribeBudgetError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DescribeBudgetError {
fn from(err: serde_json::error::Error) -> DescribeBudgetError {
DescribeBudgetError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DescribeBudgetError {
fn from(err: CredentialsError) -> DescribeBudgetError {
DescribeBudgetError::Credentials(err)
}
}
impl From<HttpDispatchError> for DescribeBudgetError {
fn from(err: HttpDispatchError) -> DescribeBudgetError {
DescribeBudgetError::HttpDispatch(err)
}
}
impl From<io::Error> for DescribeBudgetError {
fn from(err: io::Error) -> DescribeBudgetError {
DescribeBudgetError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DescribeBudgetError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DescribeBudgetError {
fn description(&self) -> &str {
match *self {
DescribeBudgetError::InternalError(ref cause) => cause,
DescribeBudgetError::InvalidParameter(ref cause) => cause,
DescribeBudgetError::NotFound(ref cause) => cause,
DescribeBudgetError::Validation(ref cause) => cause,
DescribeBudgetError::Credentials(ref err) => err.description(),
DescribeBudgetError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
DescribeBudgetError::ParseError(ref cause) => cause,
DescribeBudgetError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DescribeBudgetPerformanceHistoryError {
ExpiredNextToken(String),
InternalError(String),
InvalidNextToken(String),
InvalidParameter(String),
NotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DescribeBudgetPerformanceHistoryError {
pub fn from_response(res: BufferedHttpResponse) -> DescribeBudgetPerformanceHistoryError {
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 {
"ExpiredNextTokenException" => {
return DescribeBudgetPerformanceHistoryError::ExpiredNextToken(String::from(
error_message,
));
}
"InternalErrorException" => {
return DescribeBudgetPerformanceHistoryError::InternalError(String::from(
error_message,
));
}
"InvalidNextTokenException" => {
return DescribeBudgetPerformanceHistoryError::InvalidNextToken(String::from(
error_message,
));
}
"InvalidParameterException" => {
return DescribeBudgetPerformanceHistoryError::InvalidParameter(String::from(
error_message,
));
}
"NotFoundException" => {
return DescribeBudgetPerformanceHistoryError::NotFound(String::from(
error_message,
));
}
"ValidationException" => {
return DescribeBudgetPerformanceHistoryError::Validation(
error_message.to_string(),
);
}
_ => {}
}
}
return DescribeBudgetPerformanceHistoryError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DescribeBudgetPerformanceHistoryError {
fn from(err: serde_json::error::Error) -> DescribeBudgetPerformanceHistoryError {
DescribeBudgetPerformanceHistoryError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DescribeBudgetPerformanceHistoryError {
fn from(err: CredentialsError) -> DescribeBudgetPerformanceHistoryError {
DescribeBudgetPerformanceHistoryError::Credentials(err)
}
}
impl From<HttpDispatchError> for DescribeBudgetPerformanceHistoryError {
fn from(err: HttpDispatchError) -> DescribeBudgetPerformanceHistoryError {
DescribeBudgetPerformanceHistoryError::HttpDispatch(err)
}
}
impl From<io::Error> for DescribeBudgetPerformanceHistoryError {
fn from(err: io::Error) -> DescribeBudgetPerformanceHistoryError {
DescribeBudgetPerformanceHistoryError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DescribeBudgetPerformanceHistoryError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DescribeBudgetPerformanceHistoryError {
fn description(&self) -> &str {
match *self {
DescribeBudgetPerformanceHistoryError::ExpiredNextToken(ref cause) => cause,
DescribeBudgetPerformanceHistoryError::InternalError(ref cause) => cause,
DescribeBudgetPerformanceHistoryError::InvalidNextToken(ref cause) => cause,
DescribeBudgetPerformanceHistoryError::InvalidParameter(ref cause) => cause,
DescribeBudgetPerformanceHistoryError::NotFound(ref cause) => cause,
DescribeBudgetPerformanceHistoryError::Validation(ref cause) => cause,
DescribeBudgetPerformanceHistoryError::Credentials(ref err) => err.description(),
DescribeBudgetPerformanceHistoryError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
DescribeBudgetPerformanceHistoryError::ParseError(ref cause) => cause,
DescribeBudgetPerformanceHistoryError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DescribeBudgetsError {
ExpiredNextToken(String),
InternalError(String),
InvalidNextToken(String),
InvalidParameter(String),
NotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DescribeBudgetsError {
pub fn from_response(res: BufferedHttpResponse) -> DescribeBudgetsError {
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 {
"ExpiredNextTokenException" => {
return DescribeBudgetsError::ExpiredNextToken(String::from(error_message));
}
"InternalErrorException" => {
return DescribeBudgetsError::InternalError(String::from(error_message));
}
"InvalidNextTokenException" => {
return DescribeBudgetsError::InvalidNextToken(String::from(error_message));
}
"InvalidParameterException" => {
return DescribeBudgetsError::InvalidParameter(String::from(error_message));
}
"NotFoundException" => {
return DescribeBudgetsError::NotFound(String::from(error_message));
}
"ValidationException" => {
return DescribeBudgetsError::Validation(error_message.to_string());
}
_ => {}
}
}
return DescribeBudgetsError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DescribeBudgetsError {
fn from(err: serde_json::error::Error) -> DescribeBudgetsError {
DescribeBudgetsError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DescribeBudgetsError {
fn from(err: CredentialsError) -> DescribeBudgetsError {
DescribeBudgetsError::Credentials(err)
}
}
impl From<HttpDispatchError> for DescribeBudgetsError {
fn from(err: HttpDispatchError) -> DescribeBudgetsError {
DescribeBudgetsError::HttpDispatch(err)
}
}
impl From<io::Error> for DescribeBudgetsError {
fn from(err: io::Error) -> DescribeBudgetsError {
DescribeBudgetsError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DescribeBudgetsError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DescribeBudgetsError {
fn description(&self) -> &str {
match *self {
DescribeBudgetsError::ExpiredNextToken(ref cause) => cause,
DescribeBudgetsError::InternalError(ref cause) => cause,
DescribeBudgetsError::InvalidNextToken(ref cause) => cause,
DescribeBudgetsError::InvalidParameter(ref cause) => cause,
DescribeBudgetsError::NotFound(ref cause) => cause,
DescribeBudgetsError::Validation(ref cause) => cause,
DescribeBudgetsError::Credentials(ref err) => err.description(),
DescribeBudgetsError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
DescribeBudgetsError::ParseError(ref cause) => cause,
DescribeBudgetsError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DescribeNotificationsForBudgetError {
ExpiredNextToken(String),
InternalError(String),
InvalidNextToken(String),
InvalidParameter(String),
NotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DescribeNotificationsForBudgetError {
pub fn from_response(res: BufferedHttpResponse) -> DescribeNotificationsForBudgetError {
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 {
"ExpiredNextTokenException" => {
return DescribeNotificationsForBudgetError::ExpiredNextToken(String::from(
error_message,
));
}
"InternalErrorException" => {
return DescribeNotificationsForBudgetError::InternalError(String::from(
error_message,
));
}
"InvalidNextTokenException" => {
return DescribeNotificationsForBudgetError::InvalidNextToken(String::from(
error_message,
));
}
"InvalidParameterException" => {
return DescribeNotificationsForBudgetError::InvalidParameter(String::from(
error_message,
));
}
"NotFoundException" => {
return DescribeNotificationsForBudgetError::NotFound(String::from(
error_message,
));
}
"ValidationException" => {
return DescribeNotificationsForBudgetError::Validation(
error_message.to_string(),
);
}
_ => {}
}
}
return DescribeNotificationsForBudgetError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DescribeNotificationsForBudgetError {
fn from(err: serde_json::error::Error) -> DescribeNotificationsForBudgetError {
DescribeNotificationsForBudgetError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DescribeNotificationsForBudgetError {
fn from(err: CredentialsError) -> DescribeNotificationsForBudgetError {
DescribeNotificationsForBudgetError::Credentials(err)
}
}
impl From<HttpDispatchError> for DescribeNotificationsForBudgetError {
fn from(err: HttpDispatchError) -> DescribeNotificationsForBudgetError {
DescribeNotificationsForBudgetError::HttpDispatch(err)
}
}
impl From<io::Error> for DescribeNotificationsForBudgetError {
fn from(err: io::Error) -> DescribeNotificationsForBudgetError {
DescribeNotificationsForBudgetError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DescribeNotificationsForBudgetError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DescribeNotificationsForBudgetError {
fn description(&self) -> &str {
match *self {
DescribeNotificationsForBudgetError::ExpiredNextToken(ref cause) => cause,
DescribeNotificationsForBudgetError::InternalError(ref cause) => cause,
DescribeNotificationsForBudgetError::InvalidNextToken(ref cause) => cause,
DescribeNotificationsForBudgetError::InvalidParameter(ref cause) => cause,
DescribeNotificationsForBudgetError::NotFound(ref cause) => cause,
DescribeNotificationsForBudgetError::Validation(ref cause) => cause,
DescribeNotificationsForBudgetError::Credentials(ref err) => err.description(),
DescribeNotificationsForBudgetError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
DescribeNotificationsForBudgetError::ParseError(ref cause) => cause,
DescribeNotificationsForBudgetError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DescribeSubscribersForNotificationError {
ExpiredNextToken(String),
InternalError(String),
InvalidNextToken(String),
InvalidParameter(String),
NotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DescribeSubscribersForNotificationError {
pub fn from_response(res: BufferedHttpResponse) -> DescribeSubscribersForNotificationError {
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 {
"ExpiredNextTokenException" => {
return DescribeSubscribersForNotificationError::ExpiredNextToken(String::from(
error_message,
));
}
"InternalErrorException" => {
return DescribeSubscribersForNotificationError::InternalError(String::from(
error_message,
));
}
"InvalidNextTokenException" => {
return DescribeSubscribersForNotificationError::InvalidNextToken(String::from(
error_message,
));
}
"InvalidParameterException" => {
return DescribeSubscribersForNotificationError::InvalidParameter(String::from(
error_message,
));
}
"NotFoundException" => {
return DescribeSubscribersForNotificationError::NotFound(String::from(
error_message,
));
}
"ValidationException" => {
return DescribeSubscribersForNotificationError::Validation(
error_message.to_string(),
);
}
_ => {}
}
}
return DescribeSubscribersForNotificationError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DescribeSubscribersForNotificationError {
fn from(err: serde_json::error::Error) -> DescribeSubscribersForNotificationError {
DescribeSubscribersForNotificationError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DescribeSubscribersForNotificationError {
fn from(err: CredentialsError) -> DescribeSubscribersForNotificationError {
DescribeSubscribersForNotificationError::Credentials(err)
}
}
impl From<HttpDispatchError> for DescribeSubscribersForNotificationError {
fn from(err: HttpDispatchError) -> DescribeSubscribersForNotificationError {
DescribeSubscribersForNotificationError::HttpDispatch(err)
}
}
impl From<io::Error> for DescribeSubscribersForNotificationError {
fn from(err: io::Error) -> DescribeSubscribersForNotificationError {
DescribeSubscribersForNotificationError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DescribeSubscribersForNotificationError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DescribeSubscribersForNotificationError {
fn description(&self) -> &str {
match *self {
DescribeSubscribersForNotificationError::ExpiredNextToken(ref cause) => cause,
DescribeSubscribersForNotificationError::InternalError(ref cause) => cause,
DescribeSubscribersForNotificationError::InvalidNextToken(ref cause) => cause,
DescribeSubscribersForNotificationError::InvalidParameter(ref cause) => cause,
DescribeSubscribersForNotificationError::NotFound(ref cause) => cause,
DescribeSubscribersForNotificationError::Validation(ref cause) => cause,
DescribeSubscribersForNotificationError::Credentials(ref err) => err.description(),
DescribeSubscribersForNotificationError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
DescribeSubscribersForNotificationError::ParseError(ref cause) => cause,
DescribeSubscribersForNotificationError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum UpdateBudgetError {
InternalError(String),
InvalidParameter(String),
NotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl UpdateBudgetError {
pub fn from_response(res: BufferedHttpResponse) -> UpdateBudgetError {
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 UpdateBudgetError::InternalError(String::from(error_message));
}
"InvalidParameterException" => {
return UpdateBudgetError::InvalidParameter(String::from(error_message));
}
"NotFoundException" => {
return UpdateBudgetError::NotFound(String::from(error_message));
}
"ValidationException" => {
return UpdateBudgetError::Validation(error_message.to_string());
}
_ => {}
}
}
return UpdateBudgetError::Unknown(res);
}
}
impl From<serde_json::error::Error> for UpdateBudgetError {
fn from(err: serde_json::error::Error) -> UpdateBudgetError {
UpdateBudgetError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for UpdateBudgetError {
fn from(err: CredentialsError) -> UpdateBudgetError {
UpdateBudgetError::Credentials(err)
}
}
impl From<HttpDispatchError> for UpdateBudgetError {
fn from(err: HttpDispatchError) -> UpdateBudgetError {
UpdateBudgetError::HttpDispatch(err)
}
}
impl From<io::Error> for UpdateBudgetError {
fn from(err: io::Error) -> UpdateBudgetError {
UpdateBudgetError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for UpdateBudgetError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for UpdateBudgetError {
fn description(&self) -> &str {
match *self {
UpdateBudgetError::InternalError(ref cause) => cause,
UpdateBudgetError::InvalidParameter(ref cause) => cause,
UpdateBudgetError::NotFound(ref cause) => cause,
UpdateBudgetError::Validation(ref cause) => cause,
UpdateBudgetError::Credentials(ref err) => err.description(),
UpdateBudgetError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
UpdateBudgetError::ParseError(ref cause) => cause,
UpdateBudgetError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum UpdateNotificationError {
DuplicateRecord(String),
InternalError(String),
InvalidParameter(String),
NotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl UpdateNotificationError {
pub fn from_response(res: BufferedHttpResponse) -> UpdateNotificationError {
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 {
"DuplicateRecordException" => {
return UpdateNotificationError::DuplicateRecord(String::from(error_message));
}
"InternalErrorException" => {
return UpdateNotificationError::InternalError(String::from(error_message));
}
"InvalidParameterException" => {
return UpdateNotificationError::InvalidParameter(String::from(error_message));
}
"NotFoundException" => {
return UpdateNotificationError::NotFound(String::from(error_message));
}
"ValidationException" => {
return UpdateNotificationError::Validation(error_message.to_string());
}
_ => {}
}
}
return UpdateNotificationError::Unknown(res);
}
}
impl From<serde_json::error::Error> for UpdateNotificationError {
fn from(err: serde_json::error::Error) -> UpdateNotificationError {
UpdateNotificationError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for UpdateNotificationError {
fn from(err: CredentialsError) -> UpdateNotificationError {
UpdateNotificationError::Credentials(err)
}
}
impl From<HttpDispatchError> for UpdateNotificationError {
fn from(err: HttpDispatchError) -> UpdateNotificationError {
UpdateNotificationError::HttpDispatch(err)
}
}
impl From<io::Error> for UpdateNotificationError {
fn from(err: io::Error) -> UpdateNotificationError {
UpdateNotificationError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for UpdateNotificationError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for UpdateNotificationError {
fn description(&self) -> &str {
match *self {
UpdateNotificationError::DuplicateRecord(ref cause) => cause,
UpdateNotificationError::InternalError(ref cause) => cause,
UpdateNotificationError::InvalidParameter(ref cause) => cause,
UpdateNotificationError::NotFound(ref cause) => cause,
UpdateNotificationError::Validation(ref cause) => cause,
UpdateNotificationError::Credentials(ref err) => err.description(),
UpdateNotificationError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
UpdateNotificationError::ParseError(ref cause) => cause,
UpdateNotificationError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum UpdateSubscriberError {
DuplicateRecord(String),
InternalError(String),
InvalidParameter(String),
NotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl UpdateSubscriberError {
pub fn from_response(res: BufferedHttpResponse) -> UpdateSubscriberError {
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 {
"DuplicateRecordException" => {
return UpdateSubscriberError::DuplicateRecord(String::from(error_message));
}
"InternalErrorException" => {
return UpdateSubscriberError::InternalError(String::from(error_message));
}
"InvalidParameterException" => {
return UpdateSubscriberError::InvalidParameter(String::from(error_message));
}
"NotFoundException" => {
return UpdateSubscriberError::NotFound(String::from(error_message));
}
"ValidationException" => {
return UpdateSubscriberError::Validation(error_message.to_string());
}
_ => {}
}
}
return UpdateSubscriberError::Unknown(res);
}
}
impl From<serde_json::error::Error> for UpdateSubscriberError {
fn from(err: serde_json::error::Error) -> UpdateSubscriberError {
UpdateSubscriberError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for UpdateSubscriberError {
fn from(err: CredentialsError) -> UpdateSubscriberError {
UpdateSubscriberError::Credentials(err)
}
}
impl From<HttpDispatchError> for UpdateSubscriberError {
fn from(err: HttpDispatchError) -> UpdateSubscriberError {
UpdateSubscriberError::HttpDispatch(err)
}
}
impl From<io::Error> for UpdateSubscriberError {
fn from(err: io::Error) -> UpdateSubscriberError {
UpdateSubscriberError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for UpdateSubscriberError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for UpdateSubscriberError {
fn description(&self) -> &str {
match *self {
UpdateSubscriberError::DuplicateRecord(ref cause) => cause,
UpdateSubscriberError::InternalError(ref cause) => cause,
UpdateSubscriberError::InvalidParameter(ref cause) => cause,
UpdateSubscriberError::NotFound(ref cause) => cause,
UpdateSubscriberError::Validation(ref cause) => cause,
UpdateSubscriberError::Credentials(ref err) => err.description(),
UpdateSubscriberError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
UpdateSubscriberError::ParseError(ref cause) => cause,
UpdateSubscriberError::Unknown(_) => "unknown error",
}
}
}
pub trait Budgets {
fn create_budget(
&self,
input: CreateBudgetRequest,
) -> RusotoFuture<CreateBudgetResponse, CreateBudgetError>;
fn create_notification(
&self,
input: CreateNotificationRequest,
) -> RusotoFuture<CreateNotificationResponse, CreateNotificationError>;
fn create_subscriber(
&self,
input: CreateSubscriberRequest,
) -> RusotoFuture<CreateSubscriberResponse, CreateSubscriberError>;
fn delete_budget(
&self,
input: DeleteBudgetRequest,
) -> RusotoFuture<DeleteBudgetResponse, DeleteBudgetError>;
fn delete_notification(
&self,
input: DeleteNotificationRequest,
) -> RusotoFuture<DeleteNotificationResponse, DeleteNotificationError>;
fn delete_subscriber(
&self,
input: DeleteSubscriberRequest,
) -> RusotoFuture<DeleteSubscriberResponse, DeleteSubscriberError>;
fn describe_budget(
&self,
input: DescribeBudgetRequest,
) -> RusotoFuture<DescribeBudgetResponse, DescribeBudgetError>;
fn describe_budget_performance_history(
&self,
input: DescribeBudgetPerformanceHistoryRequest,
) -> RusotoFuture<DescribeBudgetPerformanceHistoryResponse, DescribeBudgetPerformanceHistoryError>;
fn describe_budgets(
&self,
input: DescribeBudgetsRequest,
) -> RusotoFuture<DescribeBudgetsResponse, DescribeBudgetsError>;
fn describe_notifications_for_budget(
&self,
input: DescribeNotificationsForBudgetRequest,
) -> RusotoFuture<DescribeNotificationsForBudgetResponse, DescribeNotificationsForBudgetError>;
fn describe_subscribers_for_notification(
&self,
input: DescribeSubscribersForNotificationRequest,
) -> RusotoFuture<
DescribeSubscribersForNotificationResponse,
DescribeSubscribersForNotificationError,
>;
fn update_budget(
&self,
input: UpdateBudgetRequest,
) -> RusotoFuture<UpdateBudgetResponse, UpdateBudgetError>;
fn update_notification(
&self,
input: UpdateNotificationRequest,
) -> RusotoFuture<UpdateNotificationResponse, UpdateNotificationError>;
fn update_subscriber(
&self,
input: UpdateSubscriberRequest,
) -> RusotoFuture<UpdateSubscriberResponse, UpdateSubscriberError>;
}
#[derive(Clone)]
pub struct BudgetsClient {
client: Client,
region: region::Region,
}
impl BudgetsClient {
pub fn new(region: region::Region) -> BudgetsClient {
BudgetsClient {
client: Client::shared(),
region: region,
}
}
pub fn new_with<P, D>(
request_dispatcher: D,
credentials_provider: P,
region: region::Region,
) -> BudgetsClient
where
P: ProvideAwsCredentials + Send + Sync + 'static,
P::Future: Send,
D: DispatchSignedRequest + Send + Sync + 'static,
D::Future: Send,
{
BudgetsClient {
client: Client::new_with(credentials_provider, request_dispatcher),
region: region,
}
}
}
impl Budgets for BudgetsClient {
fn create_budget(
&self,
input: CreateBudgetRequest,
) -> RusotoFuture<CreateBudgetResponse, CreateBudgetError> {
let mut request = SignedRequest::new("POST", "budgets", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AWSBudgetServiceGateway.CreateBudget");
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::<CreateBudgetResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(CreateBudgetError::from_response(response))),
)
}
})
}
fn create_notification(
&self,
input: CreateNotificationRequest,
) -> RusotoFuture<CreateNotificationResponse, CreateNotificationError> {
let mut request = SignedRequest::new("POST", "budgets", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AWSBudgetServiceGateway.CreateNotification");
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::<CreateNotificationResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(CreateNotificationError::from_response(response))),
)
}
})
}
fn create_subscriber(
&self,
input: CreateSubscriberRequest,
) -> RusotoFuture<CreateSubscriberResponse, CreateSubscriberError> {
let mut request = SignedRequest::new("POST", "budgets", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AWSBudgetServiceGateway.CreateSubscriber");
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::<CreateSubscriberResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(CreateSubscriberError::from_response(response))),
)
}
})
}
fn delete_budget(
&self,
input: DeleteBudgetRequest,
) -> RusotoFuture<DeleteBudgetResponse, DeleteBudgetError> {
let mut request = SignedRequest::new("POST", "budgets", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AWSBudgetServiceGateway.DeleteBudget");
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::<DeleteBudgetResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DeleteBudgetError::from_response(response))),
)
}
})
}
fn delete_notification(
&self,
input: DeleteNotificationRequest,
) -> RusotoFuture<DeleteNotificationResponse, DeleteNotificationError> {
let mut request = SignedRequest::new("POST", "budgets", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AWSBudgetServiceGateway.DeleteNotification");
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::<DeleteNotificationResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DeleteNotificationError::from_response(response))),
)
}
})
}
fn delete_subscriber(
&self,
input: DeleteSubscriberRequest,
) -> RusotoFuture<DeleteSubscriberResponse, DeleteSubscriberError> {
let mut request = SignedRequest::new("POST", "budgets", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AWSBudgetServiceGateway.DeleteSubscriber");
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::<DeleteSubscriberResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DeleteSubscriberError::from_response(response))),
)
}
})
}
fn describe_budget(
&self,
input: DescribeBudgetRequest,
) -> RusotoFuture<DescribeBudgetResponse, DescribeBudgetError> {
let mut request = SignedRequest::new("POST", "budgets", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AWSBudgetServiceGateway.DescribeBudget");
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::<DescribeBudgetResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DescribeBudgetError::from_response(response))),
)
}
})
}
fn describe_budget_performance_history(
&self,
input: DescribeBudgetPerformanceHistoryRequest,
) -> RusotoFuture<DescribeBudgetPerformanceHistoryResponse, DescribeBudgetPerformanceHistoryError>
{
let mut request = SignedRequest::new("POST", "budgets", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header(
"x-amz-target",
"AWSBudgetServiceGateway.DescribeBudgetPerformanceHistory",
);
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::<DescribeBudgetPerformanceHistoryResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(DescribeBudgetPerformanceHistoryError::from_response(
response,
))
}))
}
})
}
fn describe_budgets(
&self,
input: DescribeBudgetsRequest,
) -> RusotoFuture<DescribeBudgetsResponse, DescribeBudgetsError> {
let mut request = SignedRequest::new("POST", "budgets", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AWSBudgetServiceGateway.DescribeBudgets");
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::<DescribeBudgetsResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DescribeBudgetsError::from_response(response))),
)
}
})
}
fn describe_notifications_for_budget(
&self,
input: DescribeNotificationsForBudgetRequest,
) -> RusotoFuture<DescribeNotificationsForBudgetResponse, DescribeNotificationsForBudgetError>
{
let mut request = SignedRequest::new("POST", "budgets", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header(
"x-amz-target",
"AWSBudgetServiceGateway.DescribeNotificationsForBudget",
);
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::<DescribeNotificationsForBudgetResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(DescribeNotificationsForBudgetError::from_response(response))
}))
}
})
}
fn describe_subscribers_for_notification(
&self,
input: DescribeSubscribersForNotificationRequest,
) -> RusotoFuture<
DescribeSubscribersForNotificationResponse,
DescribeSubscribersForNotificationError,
> {
let mut request = SignedRequest::new("POST", "budgets", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header(
"x-amz-target",
"AWSBudgetServiceGateway.DescribeSubscribersForNotification",
);
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::<DescribeSubscribersForNotificationResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(DescribeSubscribersForNotificationError::from_response(
response,
))
}))
}
})
}
fn update_budget(
&self,
input: UpdateBudgetRequest,
) -> RusotoFuture<UpdateBudgetResponse, UpdateBudgetError> {
let mut request = SignedRequest::new("POST", "budgets", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AWSBudgetServiceGateway.UpdateBudget");
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::<UpdateBudgetResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(UpdateBudgetError::from_response(response))),
)
}
})
}
fn update_notification(
&self,
input: UpdateNotificationRequest,
) -> RusotoFuture<UpdateNotificationResponse, UpdateNotificationError> {
let mut request = SignedRequest::new("POST", "budgets", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AWSBudgetServiceGateway.UpdateNotification");
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::<UpdateNotificationResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(UpdateNotificationError::from_response(response))),
)
}
})
}
fn update_subscriber(
&self,
input: UpdateSubscriberRequest,
) -> RusotoFuture<UpdateSubscriberResponse, UpdateSubscriberError> {
let mut request = SignedRequest::new("POST", "budgets", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "AWSBudgetServiceGateway.UpdateSubscriber");
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::<UpdateSubscriberResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(UpdateSubscriberError::from_response(response))),
)
}
})
}
}
#[cfg(test)]
mod protocol_tests {}