use std::error::Error;
use std::fmt;
use async_trait::async_trait;
use rusoto_core::credential::ProvideAwsCredentials;
use rusoto_core::region;
use rusoto_core::request::{BufferedHttpResponse, DispatchSignedRequest};
use rusoto_core::{Client, RusotoError};
use rusoto_core::proto;
use rusoto_core::signature::SignedRequest;
#[allow(unused_imports)]
use serde::{Deserialize, Serialize};
use serde_json;
#[derive(Clone, Debug, Default, PartialEq, Serialize)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct CreateSavingsPlanRequest {
#[serde(rename = "clientToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub client_token: Option<String>,
#[serde(rename = "commitment")]
pub commitment: String,
#[serde(rename = "savingsPlanOfferingId")]
pub savings_plan_offering_id: String,
#[serde(rename = "tags")]
#[serde(skip_serializing_if = "Option::is_none")]
pub tags: Option<::std::collections::HashMap<String, String>>,
#[serde(rename = "upfrontPaymentAmount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub upfront_payment_amount: Option<String>,
}
#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
pub struct CreateSavingsPlanResponse {
#[serde(rename = "savingsPlanId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub savings_plan_id: Option<String>,
}
#[derive(Clone, Debug, Default, PartialEq, Serialize)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct DescribeSavingsPlanRatesRequest {
#[serde(rename = "filters")]
#[serde(skip_serializing_if = "Option::is_none")]
pub filters: Option<Vec<SavingsPlanRateFilter>>,
#[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 = "savingsPlanId")]
pub savings_plan_id: String,
}
#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
pub struct DescribeSavingsPlanRatesResponse {
#[serde(rename = "nextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
#[serde(rename = "savingsPlanId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub savings_plan_id: Option<String>,
#[serde(rename = "searchResults")]
#[serde(skip_serializing_if = "Option::is_none")]
pub search_results: Option<Vec<SavingsPlanRate>>,
}
#[derive(Clone, Debug, Default, PartialEq, Serialize)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct DescribeSavingsPlansOfferingRatesRequest {
#[serde(rename = "filters")]
#[serde(skip_serializing_if = "Option::is_none")]
pub filters: Option<Vec<SavingsPlanOfferingRateFilterElement>>,
#[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 = "operations")]
#[serde(skip_serializing_if = "Option::is_none")]
pub operations: Option<Vec<String>>,
#[serde(rename = "products")]
#[serde(skip_serializing_if = "Option::is_none")]
pub products: Option<Vec<String>>,
#[serde(rename = "savingsPlanOfferingIds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub savings_plan_offering_ids: Option<Vec<String>>,
#[serde(rename = "savingsPlanPaymentOptions")]
#[serde(skip_serializing_if = "Option::is_none")]
pub savings_plan_payment_options: Option<Vec<String>>,
#[serde(rename = "savingsPlanTypes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub savings_plan_types: Option<Vec<String>>,
#[serde(rename = "serviceCodes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub service_codes: Option<Vec<String>>,
#[serde(rename = "usageTypes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub usage_types: Option<Vec<String>>,
}
#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
pub struct DescribeSavingsPlansOfferingRatesResponse {
#[serde(rename = "nextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
#[serde(rename = "searchResults")]
#[serde(skip_serializing_if = "Option::is_none")]
pub search_results: Option<Vec<SavingsPlanOfferingRate>>,
}
#[derive(Clone, Debug, Default, PartialEq, Serialize)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct DescribeSavingsPlansOfferingsRequest {
#[serde(rename = "currencies")]
#[serde(skip_serializing_if = "Option::is_none")]
pub currencies: Option<Vec<String>>,
#[serde(rename = "descriptions")]
#[serde(skip_serializing_if = "Option::is_none")]
pub descriptions: Option<Vec<String>>,
#[serde(rename = "durations")]
#[serde(skip_serializing_if = "Option::is_none")]
pub durations: Option<Vec<i64>>,
#[serde(rename = "filters")]
#[serde(skip_serializing_if = "Option::is_none")]
pub filters: Option<Vec<SavingsPlanOfferingFilterElement>>,
#[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 = "offeringIds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub offering_ids: Option<Vec<String>>,
#[serde(rename = "operations")]
#[serde(skip_serializing_if = "Option::is_none")]
pub operations: Option<Vec<String>>,
#[serde(rename = "paymentOptions")]
#[serde(skip_serializing_if = "Option::is_none")]
pub payment_options: Option<Vec<String>>,
#[serde(rename = "planTypes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub plan_types: Option<Vec<String>>,
#[serde(rename = "productType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub product_type: Option<String>,
#[serde(rename = "serviceCodes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub service_codes: Option<Vec<String>>,
#[serde(rename = "usageTypes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub usage_types: Option<Vec<String>>,
}
#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
pub struct DescribeSavingsPlansOfferingsResponse {
#[serde(rename = "nextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
#[serde(rename = "searchResults")]
#[serde(skip_serializing_if = "Option::is_none")]
pub search_results: Option<Vec<SavingsPlanOffering>>,
}
#[derive(Clone, Debug, Default, PartialEq, Serialize)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct DescribeSavingsPlansRequest {
#[serde(rename = "filters")]
#[serde(skip_serializing_if = "Option::is_none")]
pub filters: Option<Vec<SavingsPlanFilter>>,
#[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 = "savingsPlanArns")]
#[serde(skip_serializing_if = "Option::is_none")]
pub savings_plan_arns: Option<Vec<String>>,
#[serde(rename = "savingsPlanIds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub savings_plan_ids: Option<Vec<String>>,
#[serde(rename = "states")]
#[serde(skip_serializing_if = "Option::is_none")]
pub states: Option<Vec<String>>,
}
#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
pub struct DescribeSavingsPlansResponse {
#[serde(rename = "nextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
#[serde(rename = "savingsPlans")]
#[serde(skip_serializing_if = "Option::is_none")]
pub savings_plans: Option<Vec<SavingsPlan>>,
}
#[derive(Clone, Debug, Default, PartialEq, Serialize)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct ListTagsForResourceRequest {
#[serde(rename = "resourceArn")]
pub resource_arn: String,
}
#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
pub struct ListTagsForResourceResponse {
#[serde(rename = "tags")]
#[serde(skip_serializing_if = "Option::is_none")]
pub tags: Option<::std::collections::HashMap<String, String>>,
}
#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
pub struct ParentSavingsPlanOffering {
#[serde(rename = "currency")]
#[serde(skip_serializing_if = "Option::is_none")]
pub currency: Option<String>,
#[serde(rename = "durationSeconds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub duration_seconds: Option<i64>,
#[serde(rename = "offeringId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub offering_id: Option<String>,
#[serde(rename = "paymentOption")]
#[serde(skip_serializing_if = "Option::is_none")]
pub payment_option: Option<String>,
#[serde(rename = "planDescription")]
#[serde(skip_serializing_if = "Option::is_none")]
pub plan_description: Option<String>,
#[serde(rename = "planType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub plan_type: Option<String>,
}
#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
pub struct SavingsPlan {
#[serde(rename = "commitment")]
#[serde(skip_serializing_if = "Option::is_none")]
pub commitment: Option<String>,
#[serde(rename = "currency")]
#[serde(skip_serializing_if = "Option::is_none")]
pub currency: Option<String>,
#[serde(rename = "description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "ec2InstanceFamily")]
#[serde(skip_serializing_if = "Option::is_none")]
pub ec_2_instance_family: Option<String>,
#[serde(rename = "end")]
#[serde(skip_serializing_if = "Option::is_none")]
pub end: Option<String>,
#[serde(rename = "offeringId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub offering_id: Option<String>,
#[serde(rename = "paymentOption")]
#[serde(skip_serializing_if = "Option::is_none")]
pub payment_option: Option<String>,
#[serde(rename = "productTypes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub product_types: Option<Vec<String>>,
#[serde(rename = "recurringPaymentAmount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub recurring_payment_amount: Option<String>,
#[serde(rename = "region")]
#[serde(skip_serializing_if = "Option::is_none")]
pub region: Option<String>,
#[serde(rename = "savingsPlanArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub savings_plan_arn: Option<String>,
#[serde(rename = "savingsPlanId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub savings_plan_id: Option<String>,
#[serde(rename = "savingsPlanType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub savings_plan_type: Option<String>,
#[serde(rename = "start")]
#[serde(skip_serializing_if = "Option::is_none")]
pub start: Option<String>,
#[serde(rename = "state")]
#[serde(skip_serializing_if = "Option::is_none")]
pub state: Option<String>,
#[serde(rename = "tags")]
#[serde(skip_serializing_if = "Option::is_none")]
pub tags: Option<::std::collections::HashMap<String, String>>,
#[serde(rename = "termDurationInSeconds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub term_duration_in_seconds: Option<i64>,
#[serde(rename = "upfrontPaymentAmount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub upfront_payment_amount: Option<String>,
}
#[derive(Clone, Debug, Default, PartialEq, Serialize)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct SavingsPlanFilter {
#[serde(rename = "name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(rename = "values")]
#[serde(skip_serializing_if = "Option::is_none")]
pub values: Option<Vec<String>>,
}
#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
pub struct SavingsPlanOffering {
#[serde(rename = "currency")]
#[serde(skip_serializing_if = "Option::is_none")]
pub currency: Option<String>,
#[serde(rename = "description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "durationSeconds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub duration_seconds: Option<i64>,
#[serde(rename = "offeringId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub offering_id: Option<String>,
#[serde(rename = "operation")]
#[serde(skip_serializing_if = "Option::is_none")]
pub operation: Option<String>,
#[serde(rename = "paymentOption")]
#[serde(skip_serializing_if = "Option::is_none")]
pub payment_option: Option<String>,
#[serde(rename = "planType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub plan_type: Option<String>,
#[serde(rename = "productTypes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub product_types: Option<Vec<String>>,
#[serde(rename = "properties")]
#[serde(skip_serializing_if = "Option::is_none")]
pub properties: Option<Vec<SavingsPlanOfferingProperty>>,
#[serde(rename = "serviceCode")]
#[serde(skip_serializing_if = "Option::is_none")]
pub service_code: Option<String>,
#[serde(rename = "usageType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub usage_type: Option<String>,
}
#[derive(Clone, Debug, Default, PartialEq, Serialize)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct SavingsPlanOfferingFilterElement {
#[serde(rename = "name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(rename = "values")]
#[serde(skip_serializing_if = "Option::is_none")]
pub values: Option<Vec<String>>,
}
#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
pub struct SavingsPlanOfferingProperty {
#[serde(rename = "name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(rename = "value")]
#[serde(skip_serializing_if = "Option::is_none")]
pub value: Option<String>,
}
#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
pub struct SavingsPlanOfferingRate {
#[serde(rename = "operation")]
#[serde(skip_serializing_if = "Option::is_none")]
pub operation: Option<String>,
#[serde(rename = "productType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub product_type: Option<String>,
#[serde(rename = "properties")]
#[serde(skip_serializing_if = "Option::is_none")]
pub properties: Option<Vec<SavingsPlanOfferingRateProperty>>,
#[serde(rename = "rate")]
#[serde(skip_serializing_if = "Option::is_none")]
pub rate: Option<String>,
#[serde(rename = "savingsPlanOffering")]
#[serde(skip_serializing_if = "Option::is_none")]
pub savings_plan_offering: Option<ParentSavingsPlanOffering>,
#[serde(rename = "serviceCode")]
#[serde(skip_serializing_if = "Option::is_none")]
pub service_code: Option<String>,
#[serde(rename = "unit")]
#[serde(skip_serializing_if = "Option::is_none")]
pub unit: Option<String>,
#[serde(rename = "usageType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub usage_type: Option<String>,
}
#[derive(Clone, Debug, Default, PartialEq, Serialize)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct SavingsPlanOfferingRateFilterElement {
#[serde(rename = "name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(rename = "values")]
#[serde(skip_serializing_if = "Option::is_none")]
pub values: Option<Vec<String>>,
}
#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
pub struct SavingsPlanOfferingRateProperty {
#[serde(rename = "name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(rename = "value")]
#[serde(skip_serializing_if = "Option::is_none")]
pub value: Option<String>,
}
#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
pub struct SavingsPlanRate {
#[serde(rename = "currency")]
#[serde(skip_serializing_if = "Option::is_none")]
pub currency: Option<String>,
#[serde(rename = "operation")]
#[serde(skip_serializing_if = "Option::is_none")]
pub operation: Option<String>,
#[serde(rename = "productType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub product_type: Option<String>,
#[serde(rename = "properties")]
#[serde(skip_serializing_if = "Option::is_none")]
pub properties: Option<Vec<SavingsPlanRateProperty>>,
#[serde(rename = "rate")]
#[serde(skip_serializing_if = "Option::is_none")]
pub rate: Option<String>,
#[serde(rename = "serviceCode")]
#[serde(skip_serializing_if = "Option::is_none")]
pub service_code: Option<String>,
#[serde(rename = "unit")]
#[serde(skip_serializing_if = "Option::is_none")]
pub unit: Option<String>,
#[serde(rename = "usageType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub usage_type: Option<String>,
}
#[derive(Clone, Debug, Default, PartialEq, Serialize)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct SavingsPlanRateFilter {
#[serde(rename = "name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(rename = "values")]
#[serde(skip_serializing_if = "Option::is_none")]
pub values: Option<Vec<String>>,
}
#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
pub struct SavingsPlanRateProperty {
#[serde(rename = "name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(rename = "value")]
#[serde(skip_serializing_if = "Option::is_none")]
pub value: Option<String>,
}
#[derive(Clone, Debug, Default, PartialEq, Serialize)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct TagResourceRequest {
#[serde(rename = "resourceArn")]
pub resource_arn: String,
#[serde(rename = "tags")]
pub tags: ::std::collections::HashMap<String, String>,
}
#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
pub struct TagResourceResponse {}
#[derive(Clone, Debug, Default, PartialEq, Serialize)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct UntagResourceRequest {
#[serde(rename = "resourceArn")]
pub resource_arn: String,
#[serde(rename = "tagKeys")]
pub tag_keys: Vec<String>,
}
#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
#[cfg_attr(any(test, feature = "serialize_structs"), derive(Serialize))]
pub struct UntagResourceResponse {}
#[derive(Debug, PartialEq)]
pub enum CreateSavingsPlanError {
InternalServer(String),
ResourceNotFound(String),
ServiceQuotaExceeded(String),
}
impl CreateSavingsPlanError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<CreateSavingsPlanError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"InternalServerException" => {
return RusotoError::Service(CreateSavingsPlanError::InternalServer(err.msg))
}
"ResourceNotFoundException" => {
return RusotoError::Service(CreateSavingsPlanError::ResourceNotFound(err.msg))
}
"ServiceQuotaExceededException" => {
return RusotoError::Service(CreateSavingsPlanError::ServiceQuotaExceeded(
err.msg,
))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
RusotoError::Unknown(res)
}
}
impl fmt::Display for CreateSavingsPlanError {
#[allow(unused_variables)]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
CreateSavingsPlanError::InternalServer(ref cause) => write!(f, "{}", cause),
CreateSavingsPlanError::ResourceNotFound(ref cause) => write!(f, "{}", cause),
CreateSavingsPlanError::ServiceQuotaExceeded(ref cause) => write!(f, "{}", cause),
}
}
}
impl Error for CreateSavingsPlanError {}
#[derive(Debug, PartialEq)]
pub enum DescribeSavingsPlanRatesError {
ResourceNotFound(String),
}
impl DescribeSavingsPlanRatesError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<DescribeSavingsPlanRatesError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"ResourceNotFoundException" => {
return RusotoError::Service(DescribeSavingsPlanRatesError::ResourceNotFound(
err.msg,
))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
RusotoError::Unknown(res)
}
}
impl fmt::Display for DescribeSavingsPlanRatesError {
#[allow(unused_variables)]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
DescribeSavingsPlanRatesError::ResourceNotFound(ref cause) => write!(f, "{}", cause),
}
}
}
impl Error for DescribeSavingsPlanRatesError {}
#[derive(Debug, PartialEq)]
pub enum DescribeSavingsPlansError {
InternalServer(String),
}
impl DescribeSavingsPlansError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<DescribeSavingsPlansError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"InternalServerException" => {
return RusotoError::Service(DescribeSavingsPlansError::InternalServer(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
RusotoError::Unknown(res)
}
}
impl fmt::Display for DescribeSavingsPlansError {
#[allow(unused_variables)]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
DescribeSavingsPlansError::InternalServer(ref cause) => write!(f, "{}", cause),
}
}
}
impl Error for DescribeSavingsPlansError {}
#[derive(Debug, PartialEq)]
pub enum DescribeSavingsPlansOfferingRatesError {
InternalServer(String),
}
impl DescribeSavingsPlansOfferingRatesError {
pub fn from_response(
res: BufferedHttpResponse,
) -> RusotoError<DescribeSavingsPlansOfferingRatesError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"InternalServerException" => {
return RusotoError::Service(
DescribeSavingsPlansOfferingRatesError::InternalServer(err.msg),
)
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
RusotoError::Unknown(res)
}
}
impl fmt::Display for DescribeSavingsPlansOfferingRatesError {
#[allow(unused_variables)]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
DescribeSavingsPlansOfferingRatesError::InternalServer(ref cause) => {
write!(f, "{}", cause)
}
}
}
}
impl Error for DescribeSavingsPlansOfferingRatesError {}
#[derive(Debug, PartialEq)]
pub enum DescribeSavingsPlansOfferingsError {
InternalServer(String),
}
impl DescribeSavingsPlansOfferingsError {
pub fn from_response(
res: BufferedHttpResponse,
) -> RusotoError<DescribeSavingsPlansOfferingsError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"InternalServerException" => {
return RusotoError::Service(
DescribeSavingsPlansOfferingsError::InternalServer(err.msg),
)
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
RusotoError::Unknown(res)
}
}
impl fmt::Display for DescribeSavingsPlansOfferingsError {
#[allow(unused_variables)]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
DescribeSavingsPlansOfferingsError::InternalServer(ref cause) => write!(f, "{}", cause),
}
}
}
impl Error for DescribeSavingsPlansOfferingsError {}
#[derive(Debug, PartialEq)]
pub enum ListTagsForResourceError {
InternalServer(String),
ResourceNotFound(String),
}
impl ListTagsForResourceError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<ListTagsForResourceError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"InternalServerException" => {
return RusotoError::Service(ListTagsForResourceError::InternalServer(err.msg))
}
"ResourceNotFoundException" => {
return RusotoError::Service(ListTagsForResourceError::ResourceNotFound(
err.msg,
))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
RusotoError::Unknown(res)
}
}
impl fmt::Display for ListTagsForResourceError {
#[allow(unused_variables)]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
ListTagsForResourceError::InternalServer(ref cause) => write!(f, "{}", cause),
ListTagsForResourceError::ResourceNotFound(ref cause) => write!(f, "{}", cause),
}
}
}
impl Error for ListTagsForResourceError {}
#[derive(Debug, PartialEq)]
pub enum TagResourceError {
InternalServer(String),
ResourceNotFound(String),
ServiceQuotaExceeded(String),
}
impl TagResourceError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<TagResourceError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"InternalServerException" => {
return RusotoError::Service(TagResourceError::InternalServer(err.msg))
}
"ResourceNotFoundException" => {
return RusotoError::Service(TagResourceError::ResourceNotFound(err.msg))
}
"ServiceQuotaExceededException" => {
return RusotoError::Service(TagResourceError::ServiceQuotaExceeded(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
RusotoError::Unknown(res)
}
}
impl fmt::Display for TagResourceError {
#[allow(unused_variables)]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
TagResourceError::InternalServer(ref cause) => write!(f, "{}", cause),
TagResourceError::ResourceNotFound(ref cause) => write!(f, "{}", cause),
TagResourceError::ServiceQuotaExceeded(ref cause) => write!(f, "{}", cause),
}
}
}
impl Error for TagResourceError {}
#[derive(Debug, PartialEq)]
pub enum UntagResourceError {
InternalServer(String),
ResourceNotFound(String),
}
impl UntagResourceError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<UntagResourceError> {
if let Some(err) = proto::json::Error::parse_rest(&res) {
match err.typ.as_str() {
"InternalServerException" => {
return RusotoError::Service(UntagResourceError::InternalServer(err.msg))
}
"ResourceNotFoundException" => {
return RusotoError::Service(UntagResourceError::ResourceNotFound(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
RusotoError::Unknown(res)
}
}
impl fmt::Display for UntagResourceError {
#[allow(unused_variables)]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
UntagResourceError::InternalServer(ref cause) => write!(f, "{}", cause),
UntagResourceError::ResourceNotFound(ref cause) => write!(f, "{}", cause),
}
}
}
impl Error for UntagResourceError {}
#[async_trait]
pub trait SavingsPlans {
async fn create_savings_plan(
&self,
input: CreateSavingsPlanRequest,
) -> Result<CreateSavingsPlanResponse, RusotoError<CreateSavingsPlanError>>;
async fn describe_savings_plan_rates(
&self,
input: DescribeSavingsPlanRatesRequest,
) -> Result<DescribeSavingsPlanRatesResponse, RusotoError<DescribeSavingsPlanRatesError>>;
async fn describe_savings_plans(
&self,
input: DescribeSavingsPlansRequest,
) -> Result<DescribeSavingsPlansResponse, RusotoError<DescribeSavingsPlansError>>;
async fn describe_savings_plans_offering_rates(
&self,
input: DescribeSavingsPlansOfferingRatesRequest,
) -> Result<
DescribeSavingsPlansOfferingRatesResponse,
RusotoError<DescribeSavingsPlansOfferingRatesError>,
>;
async fn describe_savings_plans_offerings(
&self,
input: DescribeSavingsPlansOfferingsRequest,
) -> Result<
DescribeSavingsPlansOfferingsResponse,
RusotoError<DescribeSavingsPlansOfferingsError>,
>;
async fn list_tags_for_resource(
&self,
input: ListTagsForResourceRequest,
) -> Result<ListTagsForResourceResponse, RusotoError<ListTagsForResourceError>>;
async fn tag_resource(
&self,
input: TagResourceRequest,
) -> Result<TagResourceResponse, RusotoError<TagResourceError>>;
async fn untag_resource(
&self,
input: UntagResourceRequest,
) -> Result<UntagResourceResponse, RusotoError<UntagResourceError>>;
}
#[derive(Clone)]
pub struct SavingsPlansClient {
client: Client,
region: region::Region,
}
impl SavingsPlansClient {
pub fn new(region: region::Region) -> SavingsPlansClient {
SavingsPlansClient {
client: Client::shared(),
region,
}
}
pub fn new_with<P, D>(
request_dispatcher: D,
credentials_provider: P,
region: region::Region,
) -> SavingsPlansClient
where
P: ProvideAwsCredentials + Send + Sync + 'static,
D: DispatchSignedRequest + Send + Sync + 'static,
{
SavingsPlansClient {
client: Client::new_with(credentials_provider, request_dispatcher),
region,
}
}
pub fn new_with_client(client: Client, region: region::Region) -> SavingsPlansClient {
SavingsPlansClient { client, region }
}
}
#[async_trait]
impl SavingsPlans for SavingsPlansClient {
#[allow(unused_mut)]
async fn create_savings_plan(
&self,
input: CreateSavingsPlanRequest,
) -> Result<CreateSavingsPlanResponse, RusotoError<CreateSavingsPlanError>> {
let request_uri = "/CreateSavingsPlan";
let mut request = SignedRequest::new("POST", "savingsplans", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
let mut response = self
.client
.sign_and_dispatch(request)
.await
.map_err(RusotoError::from)?;
if response.status.is_success() {
let mut response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<CreateSavingsPlanResponse, _>()?;
Ok(result)
} else {
let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
Err(CreateSavingsPlanError::from_response(response))
}
}
#[allow(unused_mut)]
async fn describe_savings_plan_rates(
&self,
input: DescribeSavingsPlanRatesRequest,
) -> Result<DescribeSavingsPlanRatesResponse, RusotoError<DescribeSavingsPlanRatesError>> {
let request_uri = "/DescribeSavingsPlanRates";
let mut request = SignedRequest::new("POST", "savingsplans", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
let mut response = self
.client
.sign_and_dispatch(request)
.await
.map_err(RusotoError::from)?;
if response.status.is_success() {
let mut response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<DescribeSavingsPlanRatesResponse, _>()?;
Ok(result)
} else {
let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
Err(DescribeSavingsPlanRatesError::from_response(response))
}
}
#[allow(unused_mut)]
async fn describe_savings_plans(
&self,
input: DescribeSavingsPlansRequest,
) -> Result<DescribeSavingsPlansResponse, RusotoError<DescribeSavingsPlansError>> {
let request_uri = "/DescribeSavingsPlans";
let mut request = SignedRequest::new("POST", "savingsplans", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
let mut response = self
.client
.sign_and_dispatch(request)
.await
.map_err(RusotoError::from)?;
if response.status.is_success() {
let mut response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<DescribeSavingsPlansResponse, _>()?;
Ok(result)
} else {
let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
Err(DescribeSavingsPlansError::from_response(response))
}
}
#[allow(unused_mut)]
async fn describe_savings_plans_offering_rates(
&self,
input: DescribeSavingsPlansOfferingRatesRequest,
) -> Result<
DescribeSavingsPlansOfferingRatesResponse,
RusotoError<DescribeSavingsPlansOfferingRatesError>,
> {
let request_uri = "/DescribeSavingsPlansOfferingRates";
let mut request = SignedRequest::new("POST", "savingsplans", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
let mut response = self
.client
.sign_and_dispatch(request)
.await
.map_err(RusotoError::from)?;
if response.status.is_success() {
let mut response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<DescribeSavingsPlansOfferingRatesResponse, _>()?;
Ok(result)
} else {
let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
Err(DescribeSavingsPlansOfferingRatesError::from_response(
response,
))
}
}
#[allow(unused_mut)]
async fn describe_savings_plans_offerings(
&self,
input: DescribeSavingsPlansOfferingsRequest,
) -> Result<
DescribeSavingsPlansOfferingsResponse,
RusotoError<DescribeSavingsPlansOfferingsError>,
> {
let request_uri = "/DescribeSavingsPlansOfferings";
let mut request = SignedRequest::new("POST", "savingsplans", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
let mut response = self
.client
.sign_and_dispatch(request)
.await
.map_err(RusotoError::from)?;
if response.status.is_success() {
let mut response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<DescribeSavingsPlansOfferingsResponse, _>()?;
Ok(result)
} else {
let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
Err(DescribeSavingsPlansOfferingsError::from_response(response))
}
}
#[allow(unused_mut)]
async fn list_tags_for_resource(
&self,
input: ListTagsForResourceRequest,
) -> Result<ListTagsForResourceResponse, RusotoError<ListTagsForResourceError>> {
let request_uri = "/ListTagsForResource";
let mut request = SignedRequest::new("POST", "savingsplans", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
let mut response = self
.client
.sign_and_dispatch(request)
.await
.map_err(RusotoError::from)?;
if response.status.is_success() {
let mut response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<ListTagsForResourceResponse, _>()?;
Ok(result)
} else {
let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
Err(ListTagsForResourceError::from_response(response))
}
}
#[allow(unused_mut)]
async fn tag_resource(
&self,
input: TagResourceRequest,
) -> Result<TagResourceResponse, RusotoError<TagResourceError>> {
let request_uri = "/TagResource";
let mut request = SignedRequest::new("POST", "savingsplans", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
let mut response = self
.client
.sign_and_dispatch(request)
.await
.map_err(RusotoError::from)?;
if response.status.is_success() {
let mut response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<TagResourceResponse, _>()?;
Ok(result)
} else {
let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
Err(TagResourceError::from_response(response))
}
}
#[allow(unused_mut)]
async fn untag_resource(
&self,
input: UntagResourceRequest,
) -> Result<UntagResourceResponse, RusotoError<UntagResourceError>> {
let request_uri = "/UntagResource";
let mut request = SignedRequest::new("POST", "savingsplans", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
let mut response = self
.client
.sign_and_dispatch(request)
.await
.map_err(RusotoError::from)?;
if response.status.is_success() {
let mut response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
let result = proto::json::ResponsePayload::new(&response)
.deserialize::<UntagResourceResponse, _>()?;
Ok(result)
} else {
let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
Err(UntagResourceError::from_response(response))
}
}
}