use std::error::Error;
use std::fmt;
#[allow(warnings)]
use futures::future;
use futures::Future;
use rusoto_core::credential::ProvideAwsCredentials;
use rusoto_core::region;
use rusoto_core::request::{BufferedHttpResponse, DispatchSignedRequest};
use rusoto_core::{Client, RusotoError, RusotoFuture};
use rusoto_core::param::{Params, ServiceParams};
use rusoto_core::proto::xml::error::*;
use rusoto_core::proto::xml::util::{
characters, deserialize_elements, end_element, find_start_element, peek_at_name, skip_tree,
start_element,
};
use rusoto_core::proto::xml::util::{Next, Peek, XmlParseError, XmlResponse};
use rusoto_core::signature::SignedRequest;
use serde_urlencoded;
use std::str::FromStr;
use xml::reader::ParserConfig;
use xml::EventReader;
#[derive(Default, Debug, Clone, PartialEq)]
pub struct Attribute {
pub alternate_name_encoding: Option<String>,
pub alternate_value_encoding: Option<String>,
pub name: String,
pub value: String,
}
struct AttributeDeserializer;
impl AttributeDeserializer {
#[allow(unused_variables)]
fn deserialize<T: Peek + Next>(
tag_name: &str,
stack: &mut T,
) -> Result<Attribute, XmlParseError> {
deserialize_elements::<_, Attribute, _>(tag_name, stack, |name, stack, obj| {
match name {
"AlternateNameEncoding" => {
obj.alternate_name_encoding = Some(StringDeserializer::deserialize(
"AlternateNameEncoding",
stack,
)?);
}
"AlternateValueEncoding" => {
obj.alternate_value_encoding = Some(StringDeserializer::deserialize(
"AlternateValueEncoding",
stack,
)?);
}
"Name" => {
obj.name = StringDeserializer::deserialize("Name", stack)?;
}
"Value" => {
obj.value = StringDeserializer::deserialize("Value", stack)?;
}
_ => skip_tree(stack),
}
Ok(())
})
}
}
struct AttributeSerializer;
impl AttributeSerializer {
fn serialize(params: &mut Params, name: &str, obj: &Attribute) {
let mut prefix = name.to_string();
if prefix != "" {
prefix.push_str(".");
}
if let Some(ref field_value) = obj.alternate_name_encoding {
params.put(
&format!("{}{}", prefix, "AlternateNameEncoding"),
&field_value,
);
}
if let Some(ref field_value) = obj.alternate_value_encoding {
params.put(
&format!("{}{}", prefix, "AlternateValueEncoding"),
&field_value,
);
}
params.put(&format!("{}{}", prefix, "Name"), &obj.name);
params.put(&format!("{}{}", prefix, "Value"), &obj.value);
}
}
struct AttributeListDeserializer;
impl AttributeListDeserializer {
#[allow(unused_variables)]
fn deserialize<T: Peek + Next>(
tag_name: &str,
stack: &mut T,
) -> Result<Vec<Attribute>, XmlParseError> {
let mut obj = vec![];
loop {
let consume_next_tag = match stack.peek() {
Some(&Ok(xml::reader::XmlEvent::StartElement { ref name, .. })) => {
name.local_name == tag_name
}
_ => false,
};
if consume_next_tag {
obj.push(AttributeDeserializer::deserialize(tag_name, stack)?);
} else {
break;
}
}
Ok(obj)
}
}
struct AttributeListSerializer;
impl AttributeListSerializer {
fn serialize(params: &mut Params, name: &str, obj: &Vec<Attribute>) {
for (index, obj) in obj.iter().enumerate() {
let key = format!("{}.{}", name, index + 1);
AttributeSerializer::serialize(params, &key, obj);
}
}
}
struct AttributeNameListSerializer;
impl AttributeNameListSerializer {
fn serialize(params: &mut Params, name: &str, obj: &Vec<String>) {
for (index, obj) in obj.iter().enumerate() {
let key = format!("{}.{}", name, index + 1);
params.put(&key, &obj);
}
}
}
#[derive(Default, Debug, Clone, PartialEq)]
pub struct BatchDeleteAttributesRequest {
pub domain_name: String,
pub items: Vec<DeletableItem>,
}
struct BatchDeleteAttributesRequestSerializer;
impl BatchDeleteAttributesRequestSerializer {
fn serialize(params: &mut Params, name: &str, obj: &BatchDeleteAttributesRequest) {
let mut prefix = name.to_string();
if prefix != "" {
prefix.push_str(".");
}
params.put(&format!("{}{}", prefix, "DomainName"), &obj.domain_name);
DeletableItemListSerializer::serialize(
params,
&format!("{}{}", prefix, "Item"),
&obj.items,
);
}
}
#[derive(Default, Debug, Clone, PartialEq)]
pub struct BatchPutAttributesRequest {
pub domain_name: String,
pub items: Vec<ReplaceableItem>,
}
struct BatchPutAttributesRequestSerializer;
impl BatchPutAttributesRequestSerializer {
fn serialize(params: &mut Params, name: &str, obj: &BatchPutAttributesRequest) {
let mut prefix = name.to_string();
if prefix != "" {
prefix.push_str(".");
}
params.put(&format!("{}{}", prefix, "DomainName"), &obj.domain_name);
ReplaceableItemListSerializer::serialize(
params,
&format!("{}{}", prefix, "Item"),
&obj.items,
);
}
}
#[derive(Default, Debug, Clone, PartialEq)]
pub struct CreateDomainRequest {
pub domain_name: String,
}
struct CreateDomainRequestSerializer;
impl CreateDomainRequestSerializer {
fn serialize(params: &mut Params, name: &str, obj: &CreateDomainRequest) {
let mut prefix = name.to_string();
if prefix != "" {
prefix.push_str(".");
}
params.put(&format!("{}{}", prefix, "DomainName"), &obj.domain_name);
}
}
#[derive(Default, Debug, Clone, PartialEq)]
pub struct DeletableItem {
pub attributes: Option<Vec<Attribute>>,
pub name: String,
}
struct DeletableItemSerializer;
impl DeletableItemSerializer {
fn serialize(params: &mut Params, name: &str, obj: &DeletableItem) {
let mut prefix = name.to_string();
if prefix != "" {
prefix.push_str(".");
}
if let Some(ref field_value) = obj.attributes {
AttributeListSerializer::serialize(
params,
&format!("{}{}", prefix, "Attribute"),
field_value,
);
}
params.put(&format!("{}{}", prefix, "ItemName"), &obj.name);
}
}
struct DeletableItemListSerializer;
impl DeletableItemListSerializer {
fn serialize(params: &mut Params, name: &str, obj: &Vec<DeletableItem>) {
for (index, obj) in obj.iter().enumerate() {
let key = format!("{}.{}", name, index + 1);
DeletableItemSerializer::serialize(params, &key, obj);
}
}
}
#[derive(Default, Debug, Clone, PartialEq)]
pub struct DeleteAttributesRequest {
pub attributes: Option<Vec<Attribute>>,
pub domain_name: String,
pub expected: Option<UpdateCondition>,
pub item_name: String,
}
struct DeleteAttributesRequestSerializer;
impl DeleteAttributesRequestSerializer {
fn serialize(params: &mut Params, name: &str, obj: &DeleteAttributesRequest) {
let mut prefix = name.to_string();
if prefix != "" {
prefix.push_str(".");
}
if let Some(ref field_value) = obj.attributes {
AttributeListSerializer::serialize(
params,
&format!("{}{}", prefix, "Attribute"),
field_value,
);
}
params.put(&format!("{}{}", prefix, "DomainName"), &obj.domain_name);
if let Some(ref field_value) = obj.expected {
UpdateConditionSerializer::serialize(
params,
&format!("{}{}", prefix, "Expected"),
field_value,
);
}
params.put(&format!("{}{}", prefix, "ItemName"), &obj.item_name);
}
}
#[derive(Default, Debug, Clone, PartialEq)]
pub struct DeleteDomainRequest {
pub domain_name: String,
}
struct DeleteDomainRequestSerializer;
impl DeleteDomainRequestSerializer {
fn serialize(params: &mut Params, name: &str, obj: &DeleteDomainRequest) {
let mut prefix = name.to_string();
if prefix != "" {
prefix.push_str(".");
}
params.put(&format!("{}{}", prefix, "DomainName"), &obj.domain_name);
}
}
#[derive(Default, Debug, Clone, PartialEq)]
pub struct DomainMetadataRequest {
pub domain_name: String,
}
struct DomainMetadataRequestSerializer;
impl DomainMetadataRequestSerializer {
fn serialize(params: &mut Params, name: &str, obj: &DomainMetadataRequest) {
let mut prefix = name.to_string();
if prefix != "" {
prefix.push_str(".");
}
params.put(&format!("{}{}", prefix, "DomainName"), &obj.domain_name);
}
}
#[derive(Default, Debug, Clone, PartialEq)]
pub struct DomainMetadataResult {
pub attribute_name_count: Option<i64>,
pub attribute_names_size_bytes: Option<i64>,
pub attribute_value_count: Option<i64>,
pub attribute_values_size_bytes: Option<i64>,
pub item_count: Option<i64>,
pub item_names_size_bytes: Option<i64>,
pub timestamp: Option<i64>,
}
struct DomainMetadataResultDeserializer;
impl DomainMetadataResultDeserializer {
#[allow(unused_variables)]
fn deserialize<T: Peek + Next>(
tag_name: &str,
stack: &mut T,
) -> Result<DomainMetadataResult, XmlParseError> {
deserialize_elements::<_, DomainMetadataResult, _>(tag_name, stack, |name, stack, obj| {
match name {
"AttributeNameCount" => {
obj.attribute_name_count = Some(IntegerDeserializer::deserialize(
"AttributeNameCount",
stack,
)?);
}
"AttributeNamesSizeBytes" => {
obj.attribute_names_size_bytes = Some(LongDeserializer::deserialize(
"AttributeNamesSizeBytes",
stack,
)?);
}
"AttributeValueCount" => {
obj.attribute_value_count = Some(IntegerDeserializer::deserialize(
"AttributeValueCount",
stack,
)?);
}
"AttributeValuesSizeBytes" => {
obj.attribute_values_size_bytes = Some(LongDeserializer::deserialize(
"AttributeValuesSizeBytes",
stack,
)?);
}
"ItemCount" => {
obj.item_count = Some(IntegerDeserializer::deserialize("ItemCount", stack)?);
}
"ItemNamesSizeBytes" => {
obj.item_names_size_bytes =
Some(LongDeserializer::deserialize("ItemNamesSizeBytes", stack)?);
}
"Timestamp" => {
obj.timestamp = Some(IntegerDeserializer::deserialize("Timestamp", stack)?);
}
_ => skip_tree(stack),
}
Ok(())
})
}
}
struct DomainNameListDeserializer;
impl DomainNameListDeserializer {
#[allow(unused_variables)]
fn deserialize<T: Peek + Next>(
tag_name: &str,
stack: &mut T,
) -> Result<Vec<String>, XmlParseError> {
let mut obj = vec![];
loop {
let consume_next_tag = match stack.peek() {
Some(&Ok(xml::reader::XmlEvent::StartElement { ref name, .. })) => {
name.local_name == tag_name
}
_ => false,
};
if consume_next_tag {
obj.push(StringDeserializer::deserialize(tag_name, stack)?);
} else {
break;
}
}
Ok(obj)
}
}
#[derive(Default, Debug, Clone, PartialEq)]
pub struct GetAttributesRequest {
pub attribute_names: Option<Vec<String>>,
pub consistent_read: Option<bool>,
pub domain_name: String,
pub item_name: String,
}
struct GetAttributesRequestSerializer;
impl GetAttributesRequestSerializer {
fn serialize(params: &mut Params, name: &str, obj: &GetAttributesRequest) {
let mut prefix = name.to_string();
if prefix != "" {
prefix.push_str(".");
}
if let Some(ref field_value) = obj.attribute_names {
AttributeNameListSerializer::serialize(
params,
&format!("{}{}", prefix, "AttributeName"),
field_value,
);
}
if let Some(ref field_value) = obj.consistent_read {
params.put(&format!("{}{}", prefix, "ConsistentRead"), &field_value);
}
params.put(&format!("{}{}", prefix, "DomainName"), &obj.domain_name);
params.put(&format!("{}{}", prefix, "ItemName"), &obj.item_name);
}
}
#[derive(Default, Debug, Clone, PartialEq)]
pub struct GetAttributesResult {
pub attributes: Option<Vec<Attribute>>,
}
struct GetAttributesResultDeserializer;
impl GetAttributesResultDeserializer {
#[allow(unused_variables)]
fn deserialize<T: Peek + Next>(
tag_name: &str,
stack: &mut T,
) -> Result<GetAttributesResult, XmlParseError> {
deserialize_elements::<_, GetAttributesResult, _>(tag_name, stack, |name, stack, obj| {
match name {
"Attribute" => {
obj.attributes
.get_or_insert(vec![])
.extend(AttributeListDeserializer::deserialize("Attribute", stack)?);
}
_ => skip_tree(stack),
}
Ok(())
})
}
}
struct IntegerDeserializer;
impl IntegerDeserializer {
#[allow(unused_variables)]
fn deserialize<T: Peek + Next>(tag_name: &str, stack: &mut T) -> Result<i64, XmlParseError> {
start_element(tag_name, stack)?;
let obj = i64::from_str(characters(stack)?.as_ref()).unwrap();
end_element(tag_name, stack)?;
Ok(obj)
}
}
#[derive(Default, Debug, Clone, PartialEq)]
pub struct Item {
pub alternate_name_encoding: Option<String>,
pub attributes: Vec<Attribute>,
pub name: String,
}
struct ItemDeserializer;
impl ItemDeserializer {
#[allow(unused_variables)]
fn deserialize<T: Peek + Next>(tag_name: &str, stack: &mut T) -> Result<Item, XmlParseError> {
deserialize_elements::<_, Item, _>(tag_name, stack, |name, stack, obj| {
match name {
"AlternateNameEncoding" => {
obj.alternate_name_encoding = Some(StringDeserializer::deserialize(
"AlternateNameEncoding",
stack,
)?);
}
"Attribute" => {
obj.attributes
.extend(AttributeListDeserializer::deserialize("Attribute", stack)?);
}
"Name" => {
obj.name = StringDeserializer::deserialize("Name", stack)?;
}
_ => skip_tree(stack),
}
Ok(())
})
}
}
struct ItemListDeserializer;
impl ItemListDeserializer {
#[allow(unused_variables)]
fn deserialize<T: Peek + Next>(
tag_name: &str,
stack: &mut T,
) -> Result<Vec<Item>, XmlParseError> {
let mut obj = vec![];
loop {
let consume_next_tag = match stack.peek() {
Some(&Ok(xml::reader::XmlEvent::StartElement { ref name, .. })) => {
name.local_name == tag_name
}
_ => false,
};
if consume_next_tag {
obj.push(ItemDeserializer::deserialize(tag_name, stack)?);
} else {
break;
}
}
Ok(obj)
}
}
#[derive(Default, Debug, Clone, PartialEq)]
pub struct ListDomainsRequest {
pub max_number_of_domains: Option<i64>,
pub next_token: Option<String>,
}
struct ListDomainsRequestSerializer;
impl ListDomainsRequestSerializer {
fn serialize(params: &mut Params, name: &str, obj: &ListDomainsRequest) {
let mut prefix = name.to_string();
if prefix != "" {
prefix.push_str(".");
}
if let Some(ref field_value) = obj.max_number_of_domains {
params.put(&format!("{}{}", prefix, "MaxNumberOfDomains"), &field_value);
}
if let Some(ref field_value) = obj.next_token {
params.put(&format!("{}{}", prefix, "NextToken"), &field_value);
}
}
}
#[derive(Default, Debug, Clone, PartialEq)]
pub struct ListDomainsResult {
pub domain_names: Option<Vec<String>>,
pub next_token: Option<String>,
}
struct ListDomainsResultDeserializer;
impl ListDomainsResultDeserializer {
#[allow(unused_variables)]
fn deserialize<T: Peek + Next>(
tag_name: &str,
stack: &mut T,
) -> Result<ListDomainsResult, XmlParseError> {
deserialize_elements::<_, ListDomainsResult, _>(tag_name, stack, |name, stack, obj| {
match name {
"DomainName" => {
obj.domain_names.get_or_insert(vec![]).extend(
DomainNameListDeserializer::deserialize("DomainName", stack)?,
);
}
"NextToken" => {
obj.next_token = Some(StringDeserializer::deserialize("NextToken", stack)?);
}
_ => skip_tree(stack),
}
Ok(())
})
}
}
struct LongDeserializer;
impl LongDeserializer {
#[allow(unused_variables)]
fn deserialize<T: Peek + Next>(tag_name: &str, stack: &mut T) -> Result<i64, XmlParseError> {
start_element(tag_name, stack)?;
let obj = i64::from_str(characters(stack)?.as_ref()).unwrap();
end_element(tag_name, stack)?;
Ok(obj)
}
}
#[derive(Default, Debug, Clone, PartialEq)]
pub struct PutAttributesRequest {
pub attributes: Vec<ReplaceableAttribute>,
pub domain_name: String,
pub expected: Option<UpdateCondition>,
pub item_name: String,
}
struct PutAttributesRequestSerializer;
impl PutAttributesRequestSerializer {
fn serialize(params: &mut Params, name: &str, obj: &PutAttributesRequest) {
let mut prefix = name.to_string();
if prefix != "" {
prefix.push_str(".");
}
ReplaceableAttributeListSerializer::serialize(
params,
&format!("{}{}", prefix, "Attribute"),
&obj.attributes,
);
params.put(&format!("{}{}", prefix, "DomainName"), &obj.domain_name);
if let Some(ref field_value) = obj.expected {
UpdateConditionSerializer::serialize(
params,
&format!("{}{}", prefix, "Expected"),
field_value,
);
}
params.put(&format!("{}{}", prefix, "ItemName"), &obj.item_name);
}
}
#[derive(Default, Debug, Clone, PartialEq)]
pub struct ReplaceableAttribute {
pub name: String,
pub replace: Option<bool>,
pub value: String,
}
struct ReplaceableAttributeSerializer;
impl ReplaceableAttributeSerializer {
fn serialize(params: &mut Params, name: &str, obj: &ReplaceableAttribute) {
let mut prefix = name.to_string();
if prefix != "" {
prefix.push_str(".");
}
params.put(&format!("{}{}", prefix, "Name"), &obj.name);
if let Some(ref field_value) = obj.replace {
params.put(&format!("{}{}", prefix, "Replace"), &field_value);
}
params.put(&format!("{}{}", prefix, "Value"), &obj.value);
}
}
struct ReplaceableAttributeListSerializer;
impl ReplaceableAttributeListSerializer {
fn serialize(params: &mut Params, name: &str, obj: &Vec<ReplaceableAttribute>) {
for (index, obj) in obj.iter().enumerate() {
let key = format!("{}.{}", name, index + 1);
ReplaceableAttributeSerializer::serialize(params, &key, obj);
}
}
}
#[derive(Default, Debug, Clone, PartialEq)]
pub struct ReplaceableItem {
pub attributes: Vec<ReplaceableAttribute>,
pub name: String,
}
struct ReplaceableItemSerializer;
impl ReplaceableItemSerializer {
fn serialize(params: &mut Params, name: &str, obj: &ReplaceableItem) {
let mut prefix = name.to_string();
if prefix != "" {
prefix.push_str(".");
}
ReplaceableAttributeListSerializer::serialize(
params,
&format!("{}{}", prefix, "Attribute"),
&obj.attributes,
);
params.put(&format!("{}{}", prefix, "ItemName"), &obj.name);
}
}
struct ReplaceableItemListSerializer;
impl ReplaceableItemListSerializer {
fn serialize(params: &mut Params, name: &str, obj: &Vec<ReplaceableItem>) {
for (index, obj) in obj.iter().enumerate() {
let key = format!("{}.{}", name, index + 1);
ReplaceableItemSerializer::serialize(params, &key, obj);
}
}
}
#[derive(Default, Debug, Clone, PartialEq)]
pub struct SelectRequest {
pub consistent_read: Option<bool>,
pub next_token: Option<String>,
pub select_expression: String,
}
struct SelectRequestSerializer;
impl SelectRequestSerializer {
fn serialize(params: &mut Params, name: &str, obj: &SelectRequest) {
let mut prefix = name.to_string();
if prefix != "" {
prefix.push_str(".");
}
if let Some(ref field_value) = obj.consistent_read {
params.put(&format!("{}{}", prefix, "ConsistentRead"), &field_value);
}
if let Some(ref field_value) = obj.next_token {
params.put(&format!("{}{}", prefix, "NextToken"), &field_value);
}
params.put(
&format!("{}{}", prefix, "SelectExpression"),
&obj.select_expression,
);
}
}
#[derive(Default, Debug, Clone, PartialEq)]
pub struct SelectResult {
pub items: Option<Vec<Item>>,
pub next_token: Option<String>,
}
struct SelectResultDeserializer;
impl SelectResultDeserializer {
#[allow(unused_variables)]
fn deserialize<T: Peek + Next>(
tag_name: &str,
stack: &mut T,
) -> Result<SelectResult, XmlParseError> {
deserialize_elements::<_, SelectResult, _>(tag_name, stack, |name, stack, obj| {
match name {
"Item" => {
obj.items
.get_or_insert(vec![])
.extend(ItemListDeserializer::deserialize("Item", stack)?);
}
"NextToken" => {
obj.next_token = Some(StringDeserializer::deserialize("NextToken", stack)?);
}
_ => skip_tree(stack),
}
Ok(())
})
}
}
struct StringDeserializer;
impl StringDeserializer {
#[allow(unused_variables)]
fn deserialize<T: Peek + Next>(tag_name: &str, stack: &mut T) -> Result<String, XmlParseError> {
start_element(tag_name, stack)?;
let obj = characters(stack)?;
end_element(tag_name, stack)?;
Ok(obj)
}
}
#[derive(Default, Debug, Clone, PartialEq)]
pub struct UpdateCondition {
pub exists: Option<bool>,
pub name: Option<String>,
pub value: Option<String>,
}
struct UpdateConditionSerializer;
impl UpdateConditionSerializer {
fn serialize(params: &mut Params, name: &str, obj: &UpdateCondition) {
let mut prefix = name.to_string();
if prefix != "" {
prefix.push_str(".");
}
if let Some(ref field_value) = obj.exists {
params.put(&format!("{}{}", prefix, "Exists"), &field_value);
}
if let Some(ref field_value) = obj.name {
params.put(&format!("{}{}", prefix, "Name"), &field_value);
}
if let Some(ref field_value) = obj.value {
params.put(&format!("{}{}", prefix, "Value"), &field_value);
}
}
}
#[derive(Debug, PartialEq)]
pub enum BatchDeleteAttributesError {}
impl BatchDeleteAttributesError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<BatchDeleteAttributesError> {
{
let reader = EventReader::new(res.body.as_ref());
let mut stack = XmlResponse::new(reader.into_iter().peekable());
find_start_element(&mut stack);
if let Ok(parsed_error) = Self::deserialize(&mut stack) {
match &parsed_error.code[..] {
_ => {}
}
}
}
RusotoError::Unknown(res)
}
fn deserialize<T>(stack: &mut T) -> Result<XmlError, XmlParseError>
where
T: Peek + Next,
{
start_element("ErrorResponse", stack)?;
XmlErrorDeserializer::deserialize("Error", stack)
}
}
impl fmt::Display for BatchDeleteAttributesError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for BatchDeleteAttributesError {
fn description(&self) -> &str {
match *self {}
}
}
#[derive(Debug, PartialEq)]
pub enum BatchPutAttributesError {
DuplicateItemName(String),
InvalidParameterValue(String),
MissingParameter(String),
NoSuchDomain(String),
NumberDomainAttributesExceeded(String),
NumberDomainBytesExceeded(String),
NumberItemAttributesExceeded(String),
NumberSubmittedAttributesExceeded(String),
NumberSubmittedItemsExceeded(String),
}
impl BatchPutAttributesError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<BatchPutAttributesError> {
{
let reader = EventReader::new(res.body.as_ref());
let mut stack = XmlResponse::new(reader.into_iter().peekable());
find_start_element(&mut stack);
if let Ok(parsed_error) = Self::deserialize(&mut stack) {
match &parsed_error.code[..] {
"DuplicateItemName" => {
return RusotoError::Service(BatchPutAttributesError::DuplicateItemName(
parsed_error.message,
))
}
"InvalidParameterValue" => {
return RusotoError::Service(
BatchPutAttributesError::InvalidParameterValue(parsed_error.message),
)
}
"MissingParameter" => {
return RusotoError::Service(BatchPutAttributesError::MissingParameter(
parsed_error.message,
))
}
"NoSuchDomain" => {
return RusotoError::Service(BatchPutAttributesError::NoSuchDomain(
parsed_error.message,
))
}
"NumberDomainAttributesExceeded" => {
return RusotoError::Service(
BatchPutAttributesError::NumberDomainAttributesExceeded(
parsed_error.message,
),
)
}
"NumberDomainBytesExceeded" => {
return RusotoError::Service(
BatchPutAttributesError::NumberDomainBytesExceeded(
parsed_error.message,
),
)
}
"NumberItemAttributesExceeded" => {
return RusotoError::Service(
BatchPutAttributesError::NumberItemAttributesExceeded(
parsed_error.message,
),
)
}
"NumberSubmittedAttributesExceeded" => {
return RusotoError::Service(
BatchPutAttributesError::NumberSubmittedAttributesExceeded(
parsed_error.message,
),
)
}
"NumberSubmittedItemsExceeded" => {
return RusotoError::Service(
BatchPutAttributesError::NumberSubmittedItemsExceeded(
parsed_error.message,
),
)
}
_ => {}
}
}
}
RusotoError::Unknown(res)
}
fn deserialize<T>(stack: &mut T) -> Result<XmlError, XmlParseError>
where
T: Peek + Next,
{
start_element("ErrorResponse", stack)?;
XmlErrorDeserializer::deserialize("Error", stack)
}
}
impl fmt::Display for BatchPutAttributesError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for BatchPutAttributesError {
fn description(&self) -> &str {
match *self {
BatchPutAttributesError::DuplicateItemName(ref cause) => cause,
BatchPutAttributesError::InvalidParameterValue(ref cause) => cause,
BatchPutAttributesError::MissingParameter(ref cause) => cause,
BatchPutAttributesError::NoSuchDomain(ref cause) => cause,
BatchPutAttributesError::NumberDomainAttributesExceeded(ref cause) => cause,
BatchPutAttributesError::NumberDomainBytesExceeded(ref cause) => cause,
BatchPutAttributesError::NumberItemAttributesExceeded(ref cause) => cause,
BatchPutAttributesError::NumberSubmittedAttributesExceeded(ref cause) => cause,
BatchPutAttributesError::NumberSubmittedItemsExceeded(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum CreateDomainError {
InvalidParameterValue(String),
MissingParameter(String),
NumberDomainsExceeded(String),
}
impl CreateDomainError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<CreateDomainError> {
{
let reader = EventReader::new(res.body.as_ref());
let mut stack = XmlResponse::new(reader.into_iter().peekable());
find_start_element(&mut stack);
if let Ok(parsed_error) = Self::deserialize(&mut stack) {
match &parsed_error.code[..] {
"InvalidParameterValue" => {
return RusotoError::Service(CreateDomainError::InvalidParameterValue(
parsed_error.message,
))
}
"MissingParameter" => {
return RusotoError::Service(CreateDomainError::MissingParameter(
parsed_error.message,
))
}
"NumberDomainsExceeded" => {
return RusotoError::Service(CreateDomainError::NumberDomainsExceeded(
parsed_error.message,
))
}
_ => {}
}
}
}
RusotoError::Unknown(res)
}
fn deserialize<T>(stack: &mut T) -> Result<XmlError, XmlParseError>
where
T: Peek + Next,
{
start_element("ErrorResponse", stack)?;
XmlErrorDeserializer::deserialize("Error", stack)
}
}
impl fmt::Display for CreateDomainError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for CreateDomainError {
fn description(&self) -> &str {
match *self {
CreateDomainError::InvalidParameterValue(ref cause) => cause,
CreateDomainError::MissingParameter(ref cause) => cause,
CreateDomainError::NumberDomainsExceeded(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum DeleteAttributesError {
AttributeDoesNotExist(String),
InvalidParameterValue(String),
MissingParameter(String),
NoSuchDomain(String),
}
impl DeleteAttributesError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<DeleteAttributesError> {
{
let reader = EventReader::new(res.body.as_ref());
let mut stack = XmlResponse::new(reader.into_iter().peekable());
find_start_element(&mut stack);
if let Ok(parsed_error) = Self::deserialize(&mut stack) {
match &parsed_error.code[..] {
"AttributeDoesNotExist" => {
return RusotoError::Service(DeleteAttributesError::AttributeDoesNotExist(
parsed_error.message,
))
}
"InvalidParameterValue" => {
return RusotoError::Service(DeleteAttributesError::InvalidParameterValue(
parsed_error.message,
))
}
"MissingParameter" => {
return RusotoError::Service(DeleteAttributesError::MissingParameter(
parsed_error.message,
))
}
"NoSuchDomain" => {
return RusotoError::Service(DeleteAttributesError::NoSuchDomain(
parsed_error.message,
))
}
_ => {}
}
}
}
RusotoError::Unknown(res)
}
fn deserialize<T>(stack: &mut T) -> Result<XmlError, XmlParseError>
where
T: Peek + Next,
{
start_element("ErrorResponse", stack)?;
XmlErrorDeserializer::deserialize("Error", stack)
}
}
impl fmt::Display for DeleteAttributesError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DeleteAttributesError {
fn description(&self) -> &str {
match *self {
DeleteAttributesError::AttributeDoesNotExist(ref cause) => cause,
DeleteAttributesError::InvalidParameterValue(ref cause) => cause,
DeleteAttributesError::MissingParameter(ref cause) => cause,
DeleteAttributesError::NoSuchDomain(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum DeleteDomainError {
MissingParameter(String),
}
impl DeleteDomainError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<DeleteDomainError> {
{
let reader = EventReader::new(res.body.as_ref());
let mut stack = XmlResponse::new(reader.into_iter().peekable());
find_start_element(&mut stack);
if let Ok(parsed_error) = Self::deserialize(&mut stack) {
match &parsed_error.code[..] {
"MissingParameter" => {
return RusotoError::Service(DeleteDomainError::MissingParameter(
parsed_error.message,
))
}
_ => {}
}
}
}
RusotoError::Unknown(res)
}
fn deserialize<T>(stack: &mut T) -> Result<XmlError, XmlParseError>
where
T: Peek + Next,
{
start_element("ErrorResponse", stack)?;
XmlErrorDeserializer::deserialize("Error", stack)
}
}
impl fmt::Display for DeleteDomainError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DeleteDomainError {
fn description(&self) -> &str {
match *self {
DeleteDomainError::MissingParameter(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum DomainMetadataError {
MissingParameter(String),
NoSuchDomain(String),
}
impl DomainMetadataError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<DomainMetadataError> {
{
let reader = EventReader::new(res.body.as_ref());
let mut stack = XmlResponse::new(reader.into_iter().peekable());
find_start_element(&mut stack);
if let Ok(parsed_error) = Self::deserialize(&mut stack) {
match &parsed_error.code[..] {
"MissingParameter" => {
return RusotoError::Service(DomainMetadataError::MissingParameter(
parsed_error.message,
))
}
"NoSuchDomain" => {
return RusotoError::Service(DomainMetadataError::NoSuchDomain(
parsed_error.message,
))
}
_ => {}
}
}
}
RusotoError::Unknown(res)
}
fn deserialize<T>(stack: &mut T) -> Result<XmlError, XmlParseError>
where
T: Peek + Next,
{
start_element("ErrorResponse", stack)?;
XmlErrorDeserializer::deserialize("Error", stack)
}
}
impl fmt::Display for DomainMetadataError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DomainMetadataError {
fn description(&self) -> &str {
match *self {
DomainMetadataError::MissingParameter(ref cause) => cause,
DomainMetadataError::NoSuchDomain(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum GetAttributesError {
InvalidParameterValue(String),
MissingParameter(String),
NoSuchDomain(String),
}
impl GetAttributesError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<GetAttributesError> {
{
let reader = EventReader::new(res.body.as_ref());
let mut stack = XmlResponse::new(reader.into_iter().peekable());
find_start_element(&mut stack);
if let Ok(parsed_error) = Self::deserialize(&mut stack) {
match &parsed_error.code[..] {
"InvalidParameterValue" => {
return RusotoError::Service(GetAttributesError::InvalidParameterValue(
parsed_error.message,
))
}
"MissingParameter" => {
return RusotoError::Service(GetAttributesError::MissingParameter(
parsed_error.message,
))
}
"NoSuchDomain" => {
return RusotoError::Service(GetAttributesError::NoSuchDomain(
parsed_error.message,
))
}
_ => {}
}
}
}
RusotoError::Unknown(res)
}
fn deserialize<T>(stack: &mut T) -> Result<XmlError, XmlParseError>
where
T: Peek + Next,
{
start_element("ErrorResponse", stack)?;
XmlErrorDeserializer::deserialize("Error", stack)
}
}
impl fmt::Display for GetAttributesError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for GetAttributesError {
fn description(&self) -> &str {
match *self {
GetAttributesError::InvalidParameterValue(ref cause) => cause,
GetAttributesError::MissingParameter(ref cause) => cause,
GetAttributesError::NoSuchDomain(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum ListDomainsError {
InvalidNextToken(String),
InvalidParameterValue(String),
}
impl ListDomainsError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<ListDomainsError> {
{
let reader = EventReader::new(res.body.as_ref());
let mut stack = XmlResponse::new(reader.into_iter().peekable());
find_start_element(&mut stack);
if let Ok(parsed_error) = Self::deserialize(&mut stack) {
match &parsed_error.code[..] {
"InvalidNextToken" => {
return RusotoError::Service(ListDomainsError::InvalidNextToken(
parsed_error.message,
))
}
"InvalidParameterValue" => {
return RusotoError::Service(ListDomainsError::InvalidParameterValue(
parsed_error.message,
))
}
_ => {}
}
}
}
RusotoError::Unknown(res)
}
fn deserialize<T>(stack: &mut T) -> Result<XmlError, XmlParseError>
where
T: Peek + Next,
{
start_element("ErrorResponse", stack)?;
XmlErrorDeserializer::deserialize("Error", stack)
}
}
impl fmt::Display for ListDomainsError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for ListDomainsError {
fn description(&self) -> &str {
match *self {
ListDomainsError::InvalidNextToken(ref cause) => cause,
ListDomainsError::InvalidParameterValue(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum PutAttributesError {
AttributeDoesNotExist(String),
InvalidParameterValue(String),
MissingParameter(String),
NoSuchDomain(String),
NumberDomainAttributesExceeded(String),
NumberDomainBytesExceeded(String),
NumberItemAttributesExceeded(String),
}
impl PutAttributesError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<PutAttributesError> {
{
let reader = EventReader::new(res.body.as_ref());
let mut stack = XmlResponse::new(reader.into_iter().peekable());
find_start_element(&mut stack);
if let Ok(parsed_error) = Self::deserialize(&mut stack) {
match &parsed_error.code[..] {
"AttributeDoesNotExist" => {
return RusotoError::Service(PutAttributesError::AttributeDoesNotExist(
parsed_error.message,
))
}
"InvalidParameterValue" => {
return RusotoError::Service(PutAttributesError::InvalidParameterValue(
parsed_error.message,
))
}
"MissingParameter" => {
return RusotoError::Service(PutAttributesError::MissingParameter(
parsed_error.message,
))
}
"NoSuchDomain" => {
return RusotoError::Service(PutAttributesError::NoSuchDomain(
parsed_error.message,
))
}
"NumberDomainAttributesExceeded" => {
return RusotoError::Service(
PutAttributesError::NumberDomainAttributesExceeded(
parsed_error.message,
),
)
}
"NumberDomainBytesExceeded" => {
return RusotoError::Service(PutAttributesError::NumberDomainBytesExceeded(
parsed_error.message,
))
}
"NumberItemAttributesExceeded" => {
return RusotoError::Service(
PutAttributesError::NumberItemAttributesExceeded(parsed_error.message),
)
}
_ => {}
}
}
}
RusotoError::Unknown(res)
}
fn deserialize<T>(stack: &mut T) -> Result<XmlError, XmlParseError>
where
T: Peek + Next,
{
start_element("ErrorResponse", stack)?;
XmlErrorDeserializer::deserialize("Error", stack)
}
}
impl fmt::Display for PutAttributesError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for PutAttributesError {
fn description(&self) -> &str {
match *self {
PutAttributesError::AttributeDoesNotExist(ref cause) => cause,
PutAttributesError::InvalidParameterValue(ref cause) => cause,
PutAttributesError::MissingParameter(ref cause) => cause,
PutAttributesError::NoSuchDomain(ref cause) => cause,
PutAttributesError::NumberDomainAttributesExceeded(ref cause) => cause,
PutAttributesError::NumberDomainBytesExceeded(ref cause) => cause,
PutAttributesError::NumberItemAttributesExceeded(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum SelectError {
InvalidNextToken(String),
InvalidNumberPredicates(String),
InvalidNumberValueTests(String),
InvalidParameterValue(String),
InvalidQueryExpression(String),
MissingParameter(String),
NoSuchDomain(String),
RequestTimeout(String),
TooManyRequestedAttributes(String),
}
impl SelectError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<SelectError> {
{
let reader = EventReader::new(res.body.as_ref());
let mut stack = XmlResponse::new(reader.into_iter().peekable());
find_start_element(&mut stack);
if let Ok(parsed_error) = Self::deserialize(&mut stack) {
match &parsed_error.code[..] {
"InvalidNextToken" => {
return RusotoError::Service(SelectError::InvalidNextToken(
parsed_error.message,
))
}
"InvalidNumberPredicates" => {
return RusotoError::Service(SelectError::InvalidNumberPredicates(
parsed_error.message,
))
}
"InvalidNumberValueTests" => {
return RusotoError::Service(SelectError::InvalidNumberValueTests(
parsed_error.message,
))
}
"InvalidParameterValue" => {
return RusotoError::Service(SelectError::InvalidParameterValue(
parsed_error.message,
))
}
"InvalidQueryExpression" => {
return RusotoError::Service(SelectError::InvalidQueryExpression(
parsed_error.message,
))
}
"MissingParameter" => {
return RusotoError::Service(SelectError::MissingParameter(
parsed_error.message,
))
}
"NoSuchDomain" => {
return RusotoError::Service(SelectError::NoSuchDomain(
parsed_error.message,
))
}
"RequestTimeout" => {
return RusotoError::Service(SelectError::RequestTimeout(
parsed_error.message,
))
}
"TooManyRequestedAttributes" => {
return RusotoError::Service(SelectError::TooManyRequestedAttributes(
parsed_error.message,
))
}
_ => {}
}
}
}
RusotoError::Unknown(res)
}
fn deserialize<T>(stack: &mut T) -> Result<XmlError, XmlParseError>
where
T: Peek + Next,
{
start_element("ErrorResponse", stack)?;
XmlErrorDeserializer::deserialize("Error", stack)
}
}
impl fmt::Display for SelectError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for SelectError {
fn description(&self) -> &str {
match *self {
SelectError::InvalidNextToken(ref cause) => cause,
SelectError::InvalidNumberPredicates(ref cause) => cause,
SelectError::InvalidNumberValueTests(ref cause) => cause,
SelectError::InvalidParameterValue(ref cause) => cause,
SelectError::InvalidQueryExpression(ref cause) => cause,
SelectError::MissingParameter(ref cause) => cause,
SelectError::NoSuchDomain(ref cause) => cause,
SelectError::RequestTimeout(ref cause) => cause,
SelectError::TooManyRequestedAttributes(ref cause) => cause,
}
}
}
pub trait SimpleDb {
fn batch_delete_attributes(
&self,
input: BatchDeleteAttributesRequest,
) -> RusotoFuture<(), BatchDeleteAttributesError>;
fn batch_put_attributes(
&self,
input: BatchPutAttributesRequest,
) -> RusotoFuture<(), BatchPutAttributesError>;
fn create_domain(&self, input: CreateDomainRequest) -> RusotoFuture<(), CreateDomainError>;
fn delete_attributes(
&self,
input: DeleteAttributesRequest,
) -> RusotoFuture<(), DeleteAttributesError>;
fn delete_domain(&self, input: DeleteDomainRequest) -> RusotoFuture<(), DeleteDomainError>;
fn domain_metadata(
&self,
input: DomainMetadataRequest,
) -> RusotoFuture<DomainMetadataResult, DomainMetadataError>;
fn get_attributes(
&self,
input: GetAttributesRequest,
) -> RusotoFuture<GetAttributesResult, GetAttributesError>;
fn list_domains(
&self,
input: ListDomainsRequest,
) -> RusotoFuture<ListDomainsResult, ListDomainsError>;
fn put_attributes(&self, input: PutAttributesRequest) -> RusotoFuture<(), PutAttributesError>;
fn select(&self, input: SelectRequest) -> RusotoFuture<SelectResult, SelectError>;
}
#[derive(Clone)]
pub struct SimpleDbClient {
client: Client,
region: region::Region,
}
impl SimpleDbClient {
pub fn new(region: region::Region) -> SimpleDbClient {
SimpleDbClient {
client: Client::shared(),
region,
}
}
pub fn new_with<P, D>(
request_dispatcher: D,
credentials_provider: P,
region: region::Region,
) -> SimpleDbClient
where
P: ProvideAwsCredentials + Send + Sync + 'static,
P::Future: Send,
D: DispatchSignedRequest + Send + Sync + 'static,
D::Future: Send,
{
SimpleDbClient {
client: Client::new_with(credentials_provider, request_dispatcher),
region,
}
}
}
impl SimpleDb for SimpleDbClient {
fn batch_delete_attributes(
&self,
input: BatchDeleteAttributesRequest,
) -> RusotoFuture<(), BatchDeleteAttributesError> {
let mut request = SignedRequest::new("POST", "sdb", &self.region, "/");
let mut params = Params::new();
params.put("Action", "BatchDeleteAttributes");
params.put("Version", "2009-04-15");
BatchDeleteAttributesRequestSerializer::serialize(&mut params, "", &input);
request.set_payload(Some(serde_urlencoded::to_string(¶ms).unwrap()));
request.set_content_type("application/x-www-form-urlencoded".to_owned());
self.client.sign_and_dispatch(request, |response| {
if !response.status.is_success() {
return Box::new(response.buffer().from_err().and_then(|response| {
Err(BatchDeleteAttributesError::from_response(response))
}));
}
Box::new(future::ok(::std::mem::drop(response)))
})
}
fn batch_put_attributes(
&self,
input: BatchPutAttributesRequest,
) -> RusotoFuture<(), BatchPutAttributesError> {
let mut request = SignedRequest::new("POST", "sdb", &self.region, "/");
let mut params = Params::new();
params.put("Action", "BatchPutAttributes");
params.put("Version", "2009-04-15");
BatchPutAttributesRequestSerializer::serialize(&mut params, "", &input);
request.set_payload(Some(serde_urlencoded::to_string(¶ms).unwrap()));
request.set_content_type("application/x-www-form-urlencoded".to_owned());
self.client.sign_and_dispatch(request, |response| {
if !response.status.is_success() {
return Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(BatchPutAttributesError::from_response(response))),
);
}
Box::new(future::ok(::std::mem::drop(response)))
})
}
fn create_domain(&self, input: CreateDomainRequest) -> RusotoFuture<(), CreateDomainError> {
let mut request = SignedRequest::new("POST", "sdb", &self.region, "/");
let mut params = Params::new();
params.put("Action", "CreateDomain");
params.put("Version", "2009-04-15");
CreateDomainRequestSerializer::serialize(&mut params, "", &input);
request.set_payload(Some(serde_urlencoded::to_string(¶ms).unwrap()));
request.set_content_type("application/x-www-form-urlencoded".to_owned());
self.client.sign_and_dispatch(request, |response| {
if !response.status.is_success() {
return Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(CreateDomainError::from_response(response))),
);
}
Box::new(future::ok(::std::mem::drop(response)))
})
}
fn delete_attributes(
&self,
input: DeleteAttributesRequest,
) -> RusotoFuture<(), DeleteAttributesError> {
let mut request = SignedRequest::new("POST", "sdb", &self.region, "/");
let mut params = Params::new();
params.put("Action", "DeleteAttributes");
params.put("Version", "2009-04-15");
DeleteAttributesRequestSerializer::serialize(&mut params, "", &input);
request.set_payload(Some(serde_urlencoded::to_string(¶ms).unwrap()));
request.set_content_type("application/x-www-form-urlencoded".to_owned());
self.client.sign_and_dispatch(request, |response| {
if !response.status.is_success() {
return Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DeleteAttributesError::from_response(response))),
);
}
Box::new(future::ok(::std::mem::drop(response)))
})
}
fn delete_domain(&self, input: DeleteDomainRequest) -> RusotoFuture<(), DeleteDomainError> {
let mut request = SignedRequest::new("POST", "sdb", &self.region, "/");
let mut params = Params::new();
params.put("Action", "DeleteDomain");
params.put("Version", "2009-04-15");
DeleteDomainRequestSerializer::serialize(&mut params, "", &input);
request.set_payload(Some(serde_urlencoded::to_string(¶ms).unwrap()));
request.set_content_type("application/x-www-form-urlencoded".to_owned());
self.client.sign_and_dispatch(request, |response| {
if !response.status.is_success() {
return Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DeleteDomainError::from_response(response))),
);
}
Box::new(future::ok(::std::mem::drop(response)))
})
}
fn domain_metadata(
&self,
input: DomainMetadataRequest,
) -> RusotoFuture<DomainMetadataResult, DomainMetadataError> {
let mut request = SignedRequest::new("POST", "sdb", &self.region, "/");
let mut params = Params::new();
params.put("Action", "DomainMetadata");
params.put("Version", "2009-04-15");
DomainMetadataRequestSerializer::serialize(&mut params, "", &input);
request.set_payload(Some(serde_urlencoded::to_string(¶ms).unwrap()));
request.set_content_type("application/x-www-form-urlencoded".to_owned());
self.client.sign_and_dispatch(request, |response| {
if !response.status.is_success() {
return Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DomainMetadataError::from_response(response))),
);
}
Box::new(response.buffer().from_err().and_then(move |response| {
let result;
if response.body.is_empty() {
result = DomainMetadataResult::default();
} else {
let reader = EventReader::new_with_config(
response.body.as_ref(),
ParserConfig::new().trim_whitespace(true),
);
let mut stack = XmlResponse::new(reader.into_iter().peekable());
let _start_document = stack.next();
let actual_tag_name = peek_at_name(&mut stack)?;
start_element(&actual_tag_name, &mut stack)?;
result = DomainMetadataResultDeserializer::deserialize(
"DomainMetadataResult",
&mut stack,
)?;
skip_tree(&mut stack);
end_element(&actual_tag_name, &mut stack)?;
}
Ok(result)
}))
})
}
fn get_attributes(
&self,
input: GetAttributesRequest,
) -> RusotoFuture<GetAttributesResult, GetAttributesError> {
let mut request = SignedRequest::new("POST", "sdb", &self.region, "/");
let mut params = Params::new();
params.put("Action", "GetAttributes");
params.put("Version", "2009-04-15");
GetAttributesRequestSerializer::serialize(&mut params, "", &input);
request.set_payload(Some(serde_urlencoded::to_string(¶ms).unwrap()));
request.set_content_type("application/x-www-form-urlencoded".to_owned());
self.client.sign_and_dispatch(request, |response| {
if !response.status.is_success() {
return Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(GetAttributesError::from_response(response))),
);
}
Box::new(response.buffer().from_err().and_then(move |response| {
let result;
if response.body.is_empty() {
result = GetAttributesResult::default();
} else {
let reader = EventReader::new_with_config(
response.body.as_ref(),
ParserConfig::new().trim_whitespace(true),
);
let mut stack = XmlResponse::new(reader.into_iter().peekable());
let _start_document = stack.next();
let actual_tag_name = peek_at_name(&mut stack)?;
start_element(&actual_tag_name, &mut stack)?;
result = GetAttributesResultDeserializer::deserialize(
"GetAttributesResult",
&mut stack,
)?;
skip_tree(&mut stack);
end_element(&actual_tag_name, &mut stack)?;
}
Ok(result)
}))
})
}
fn list_domains(
&self,
input: ListDomainsRequest,
) -> RusotoFuture<ListDomainsResult, ListDomainsError> {
let mut request = SignedRequest::new("POST", "sdb", &self.region, "/");
let mut params = Params::new();
params.put("Action", "ListDomains");
params.put("Version", "2009-04-15");
ListDomainsRequestSerializer::serialize(&mut params, "", &input);
request.set_payload(Some(serde_urlencoded::to_string(¶ms).unwrap()));
request.set_content_type("application/x-www-form-urlencoded".to_owned());
self.client.sign_and_dispatch(request, |response| {
if !response.status.is_success() {
return Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(ListDomainsError::from_response(response))),
);
}
Box::new(response.buffer().from_err().and_then(move |response| {
let result;
if response.body.is_empty() {
result = ListDomainsResult::default();
} else {
let reader = EventReader::new_with_config(
response.body.as_ref(),
ParserConfig::new().trim_whitespace(true),
);
let mut stack = XmlResponse::new(reader.into_iter().peekable());
let _start_document = stack.next();
let actual_tag_name = peek_at_name(&mut stack)?;
start_element(&actual_tag_name, &mut stack)?;
result = ListDomainsResultDeserializer::deserialize(
"ListDomainsResult",
&mut stack,
)?;
skip_tree(&mut stack);
end_element(&actual_tag_name, &mut stack)?;
}
Ok(result)
}))
})
}
fn put_attributes(&self, input: PutAttributesRequest) -> RusotoFuture<(), PutAttributesError> {
let mut request = SignedRequest::new("POST", "sdb", &self.region, "/");
let mut params = Params::new();
params.put("Action", "PutAttributes");
params.put("Version", "2009-04-15");
PutAttributesRequestSerializer::serialize(&mut params, "", &input);
request.set_payload(Some(serde_urlencoded::to_string(¶ms).unwrap()));
request.set_content_type("application/x-www-form-urlencoded".to_owned());
self.client.sign_and_dispatch(request, |response| {
if !response.status.is_success() {
return Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(PutAttributesError::from_response(response))),
);
}
Box::new(future::ok(::std::mem::drop(response)))
})
}
fn select(&self, input: SelectRequest) -> RusotoFuture<SelectResult, SelectError> {
let mut request = SignedRequest::new("POST", "sdb", &self.region, "/");
let mut params = Params::new();
params.put("Action", "Select");
params.put("Version", "2009-04-15");
SelectRequestSerializer::serialize(&mut params, "", &input);
request.set_payload(Some(serde_urlencoded::to_string(¶ms).unwrap()));
request.set_content_type("application/x-www-form-urlencoded".to_owned());
self.client.sign_and_dispatch(request, |response| {
if !response.status.is_success() {
return Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(SelectError::from_response(response))),
);
}
Box::new(response.buffer().from_err().and_then(move |response| {
let result;
if response.body.is_empty() {
result = SelectResult::default();
} else {
let reader = EventReader::new_with_config(
response.body.as_ref(),
ParserConfig::new().trim_whitespace(true),
);
let mut stack = XmlResponse::new(reader.into_iter().peekable());
let _start_document = stack.next();
let actual_tag_name = peek_at_name(&mut stack)?;
start_element(&actual_tag_name, &mut stack)?;
result = SelectResultDeserializer::deserialize("SelectResult", &mut stack)?;
skip_tree(&mut stack);
end_element(&actual_tag_name, &mut stack)?;
}
Ok(result)
}))
})
}
}