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::param::{Params, ServiceParams};
use rusoto_core::signature::SignedRequest;
use rusoto_core::xmlerror::*;
use rusoto_core::xmlutil::{
characters, end_element, find_start_element, peek_at_name, skip_tree, start_element,
};
use rusoto_core::xmlutil::{Next, Peek, XmlParseError, XmlResponse};
use serde_urlencoded;
use std::str::FromStr;
use xml::reader::ParserConfig;
use xml::reader::XmlEvent;
use xml::EventReader;
enum DeserializerNext {
Close,
Skip,
Element(String),
}
#[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<'a, T: Peek + Next>(
tag_name: &str,
stack: &mut T,
) -> Result<Attribute, XmlParseError> {
start_element(tag_name, stack)?;
let mut obj = Attribute::default();
loop {
let next_event = match stack.peek() {
Some(&Ok(XmlEvent::EndElement { ref name, .. })) => DeserializerNext::Close,
Some(&Ok(XmlEvent::StartElement { ref name, .. })) => {
DeserializerNext::Element(name.local_name.to_owned())
}
_ => DeserializerNext::Skip,
};
match next_event {
DeserializerNext::Element(name) => 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),
},
DeserializerNext::Close => break,
DeserializerNext::Skip => {
stack.next();
}
}
}
end_element(tag_name, stack)?;
Ok(obj)
}
}
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<'a, 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(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<'a, T: Peek + Next>(
tag_name: &str,
stack: &mut T,
) -> Result<DomainMetadataResult, XmlParseError> {
start_element(tag_name, stack)?;
let mut obj = DomainMetadataResult::default();
loop {
let next_event = match stack.peek() {
Some(&Ok(XmlEvent::EndElement { ref name, .. })) => DeserializerNext::Close,
Some(&Ok(XmlEvent::StartElement { ref name, .. })) => {
DeserializerNext::Element(name.local_name.to_owned())
}
_ => DeserializerNext::Skip,
};
match next_event {
DeserializerNext::Element(name) => 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),
},
DeserializerNext::Close => break,
DeserializerNext::Skip => {
stack.next();
}
}
}
end_element(tag_name, stack)?;
Ok(obj)
}
}
struct DomainNameListDeserializer;
impl DomainNameListDeserializer {
#[allow(unused_variables)]
fn deserialize<'a, 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(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.to_string(),
);
}
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<'a, T: Peek + Next>(
tag_name: &str,
stack: &mut T,
) -> Result<GetAttributesResult, XmlParseError> {
start_element(tag_name, stack)?;
let mut obj = GetAttributesResult::default();
loop {
let next_event = match stack.peek() {
Some(&Ok(XmlEvent::EndElement { ref name, .. })) => DeserializerNext::Close,
Some(&Ok(XmlEvent::StartElement { ref name, .. })) => {
DeserializerNext::Element(name.local_name.to_owned())
}
_ => DeserializerNext::Skip,
};
match next_event {
DeserializerNext::Element(name) => match &name[..] {
"Attribute" => {
obj.attributes = match obj.attributes {
Some(ref mut existing) => {
existing.extend(AttributeListDeserializer::deserialize(
"Attribute",
stack,
)?);
Some(existing.to_vec())
}
None => {
Some(AttributeListDeserializer::deserialize("Attribute", stack)?)
}
};
}
_ => skip_tree(stack),
},
DeserializerNext::Close => break,
DeserializerNext::Skip => {
stack.next();
}
}
}
end_element(tag_name, stack)?;
Ok(obj)
}
}
struct IntegerDeserializer;
impl IntegerDeserializer {
#[allow(unused_variables)]
fn deserialize<'a, 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<'a, T: Peek + Next>(
tag_name: &str,
stack: &mut T,
) -> Result<Item, XmlParseError> {
start_element(tag_name, stack)?;
let mut obj = Item::default();
loop {
let next_event = match stack.peek() {
Some(&Ok(XmlEvent::EndElement { ref name, .. })) => DeserializerNext::Close,
Some(&Ok(XmlEvent::StartElement { ref name, .. })) => {
DeserializerNext::Element(name.local_name.to_owned())
}
_ => DeserializerNext::Skip,
};
match next_event {
DeserializerNext::Element(name) => 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),
},
DeserializerNext::Close => break,
DeserializerNext::Skip => {
stack.next();
}
}
}
end_element(tag_name, stack)?;
Ok(obj)
}
}
struct ItemListDeserializer;
impl ItemListDeserializer {
#[allow(unused_variables)]
fn deserialize<'a, 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(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.to_string(),
);
}
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<'a, T: Peek + Next>(
tag_name: &str,
stack: &mut T,
) -> Result<ListDomainsResult, XmlParseError> {
start_element(tag_name, stack)?;
let mut obj = ListDomainsResult::default();
loop {
let next_event = match stack.peek() {
Some(&Ok(XmlEvent::EndElement { ref name, .. })) => DeserializerNext::Close,
Some(&Ok(XmlEvent::StartElement { ref name, .. })) => {
DeserializerNext::Element(name.local_name.to_owned())
}
_ => DeserializerNext::Skip,
};
match next_event {
DeserializerNext::Element(name) => match &name[..] {
"DomainName" => {
obj.domain_names = match obj.domain_names {
Some(ref mut existing) => {
existing.extend(DomainNameListDeserializer::deserialize(
"DomainName",
stack,
)?);
Some(existing.to_vec())
}
None => Some(DomainNameListDeserializer::deserialize(
"DomainName",
stack,
)?),
};
}
"NextToken" => {
obj.next_token = Some(StringDeserializer::deserialize("NextToken", stack)?);
}
_ => skip_tree(stack),
},
DeserializerNext::Close => break,
DeserializerNext::Skip => {
stack.next();
}
}
}
end_element(tag_name, stack)?;
Ok(obj)
}
}
struct LongDeserializer;
impl LongDeserializer {
#[allow(unused_variables)]
fn deserialize<'a, 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.to_string(),
);
}
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.to_string(),
);
}
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<'a, T: Peek + Next>(
tag_name: &str,
stack: &mut T,
) -> Result<SelectResult, XmlParseError> {
start_element(tag_name, stack)?;
let mut obj = SelectResult::default();
loop {
let next_event = match stack.peek() {
Some(&Ok(XmlEvent::EndElement { ref name, .. })) => DeserializerNext::Close,
Some(&Ok(XmlEvent::StartElement { ref name, .. })) => {
DeserializerNext::Element(name.local_name.to_owned())
}
_ => DeserializerNext::Skip,
};
match next_event {
DeserializerNext::Element(name) => match &name[..] {
"Item" => {
obj.items = match obj.items {
Some(ref mut existing) => {
existing.extend(ItemListDeserializer::deserialize("Item", stack)?);
Some(existing.to_vec())
}
None => Some(ItemListDeserializer::deserialize("Item", stack)?),
};
}
"NextToken" => {
obj.next_token = Some(StringDeserializer::deserialize("NextToken", stack)?);
}
_ => skip_tree(stack),
},
DeserializerNext::Close => break,
DeserializerNext::Skip => {
stack.next();
}
}
}
end_element(tag_name, stack)?;
Ok(obj)
}
}
struct StringDeserializer;
impl StringDeserializer {
#[allow(unused_variables)]
fn deserialize<'a, 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.to_string());
}
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 {
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl BatchDeleteAttributesError {
pub fn from_response(res: BufferedHttpResponse) -> BatchDeleteAttributesError {
{
let reader = EventReader::new(res.body.as_slice());
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[..] {
_ => {}
}
}
}
BatchDeleteAttributesError::Unknown(res)
}
fn deserialize<T>(stack: &mut T) -> Result<XmlError, XmlParseError>
where
T: Peek + Next,
{
start_element("ErrorResponse", stack)?;
XmlErrorDeserializer::deserialize("Error", stack)
}
}
impl From<XmlParseError> for BatchDeleteAttributesError {
fn from(err: XmlParseError) -> BatchDeleteAttributesError {
let XmlParseError(message) = err;
BatchDeleteAttributesError::ParseError(message.to_string())
}
}
impl From<CredentialsError> for BatchDeleteAttributesError {
fn from(err: CredentialsError) -> BatchDeleteAttributesError {
BatchDeleteAttributesError::Credentials(err)
}
}
impl From<HttpDispatchError> for BatchDeleteAttributesError {
fn from(err: HttpDispatchError) -> BatchDeleteAttributesError {
BatchDeleteAttributesError::HttpDispatch(err)
}
}
impl From<io::Error> for BatchDeleteAttributesError {
fn from(err: io::Error) -> BatchDeleteAttributesError {
BatchDeleteAttributesError::HttpDispatch(HttpDispatchError::from(err))
}
}
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 {
BatchDeleteAttributesError::Validation(ref cause) => cause,
BatchDeleteAttributesError::Credentials(ref err) => err.description(),
BatchDeleteAttributesError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
BatchDeleteAttributesError::ParseError(ref cause) => cause,
BatchDeleteAttributesError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum BatchPutAttributesError {
DuplicateItemName(String),
InvalidParameterValue(String),
MissingParameter(String),
NoSuchDomain(String),
NumberDomainAttributesExceeded(String),
NumberDomainBytesExceeded(String),
NumberItemAttributesExceeded(String),
NumberSubmittedAttributesExceeded(String),
NumberSubmittedItemsExceeded(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl BatchPutAttributesError {
pub fn from_response(res: BufferedHttpResponse) -> BatchPutAttributesError {
{
let reader = EventReader::new(res.body.as_slice());
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 BatchPutAttributesError::DuplicateItemName(String::from(
parsed_error.message,
));
}
"InvalidParameterValue" => {
return BatchPutAttributesError::InvalidParameterValue(String::from(
parsed_error.message,
));
}
"MissingParameter" => {
return BatchPutAttributesError::MissingParameter(String::from(
parsed_error.message,
));
}
"NoSuchDomain" => {
return BatchPutAttributesError::NoSuchDomain(String::from(
parsed_error.message,
));
}
"NumberDomainAttributesExceeded" => {
return BatchPutAttributesError::NumberDomainAttributesExceeded(
String::from(parsed_error.message),
);
}
"NumberDomainBytesExceeded" => {
return BatchPutAttributesError::NumberDomainBytesExceeded(String::from(
parsed_error.message,
));
}
"NumberItemAttributesExceeded" => {
return BatchPutAttributesError::NumberItemAttributesExceeded(String::from(
parsed_error.message,
));
}
"NumberSubmittedAttributesExceeded" => {
return BatchPutAttributesError::NumberSubmittedAttributesExceeded(
String::from(parsed_error.message),
);
}
"NumberSubmittedItemsExceeded" => {
return BatchPutAttributesError::NumberSubmittedItemsExceeded(String::from(
parsed_error.message,
));
}
_ => {}
}
}
}
BatchPutAttributesError::Unknown(res)
}
fn deserialize<T>(stack: &mut T) -> Result<XmlError, XmlParseError>
where
T: Peek + Next,
{
start_element("ErrorResponse", stack)?;
XmlErrorDeserializer::deserialize("Error", stack)
}
}
impl From<XmlParseError> for BatchPutAttributesError {
fn from(err: XmlParseError) -> BatchPutAttributesError {
let XmlParseError(message) = err;
BatchPutAttributesError::ParseError(message.to_string())
}
}
impl From<CredentialsError> for BatchPutAttributesError {
fn from(err: CredentialsError) -> BatchPutAttributesError {
BatchPutAttributesError::Credentials(err)
}
}
impl From<HttpDispatchError> for BatchPutAttributesError {
fn from(err: HttpDispatchError) -> BatchPutAttributesError {
BatchPutAttributesError::HttpDispatch(err)
}
}
impl From<io::Error> for BatchPutAttributesError {
fn from(err: io::Error) -> BatchPutAttributesError {
BatchPutAttributesError::HttpDispatch(HttpDispatchError::from(err))
}
}
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,
BatchPutAttributesError::Validation(ref cause) => cause,
BatchPutAttributesError::Credentials(ref err) => err.description(),
BatchPutAttributesError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
BatchPutAttributesError::ParseError(ref cause) => cause,
BatchPutAttributesError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum CreateDomainError {
InvalidParameterValue(String),
MissingParameter(String),
NumberDomainsExceeded(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl CreateDomainError {
pub fn from_response(res: BufferedHttpResponse) -> CreateDomainError {
{
let reader = EventReader::new(res.body.as_slice());
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 CreateDomainError::InvalidParameterValue(String::from(
parsed_error.message,
));
}
"MissingParameter" => {
return CreateDomainError::MissingParameter(String::from(
parsed_error.message,
));
}
"NumberDomainsExceeded" => {
return CreateDomainError::NumberDomainsExceeded(String::from(
parsed_error.message,
));
}
_ => {}
}
}
}
CreateDomainError::Unknown(res)
}
fn deserialize<T>(stack: &mut T) -> Result<XmlError, XmlParseError>
where
T: Peek + Next,
{
start_element("ErrorResponse", stack)?;
XmlErrorDeserializer::deserialize("Error", stack)
}
}
impl From<XmlParseError> for CreateDomainError {
fn from(err: XmlParseError) -> CreateDomainError {
let XmlParseError(message) = err;
CreateDomainError::ParseError(message.to_string())
}
}
impl From<CredentialsError> for CreateDomainError {
fn from(err: CredentialsError) -> CreateDomainError {
CreateDomainError::Credentials(err)
}
}
impl From<HttpDispatchError> for CreateDomainError {
fn from(err: HttpDispatchError) -> CreateDomainError {
CreateDomainError::HttpDispatch(err)
}
}
impl From<io::Error> for CreateDomainError {
fn from(err: io::Error) -> CreateDomainError {
CreateDomainError::HttpDispatch(HttpDispatchError::from(err))
}
}
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,
CreateDomainError::Validation(ref cause) => cause,
CreateDomainError::Credentials(ref err) => err.description(),
CreateDomainError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
CreateDomainError::ParseError(ref cause) => cause,
CreateDomainError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DeleteAttributesError {
AttributeDoesNotExist(String),
InvalidParameterValue(String),
MissingParameter(String),
NoSuchDomain(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DeleteAttributesError {
pub fn from_response(res: BufferedHttpResponse) -> DeleteAttributesError {
{
let reader = EventReader::new(res.body.as_slice());
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 DeleteAttributesError::AttributeDoesNotExist(String::from(
parsed_error.message,
));
}
"InvalidParameterValue" => {
return DeleteAttributesError::InvalidParameterValue(String::from(
parsed_error.message,
));
}
"MissingParameter" => {
return DeleteAttributesError::MissingParameter(String::from(
parsed_error.message,
));
}
"NoSuchDomain" => {
return DeleteAttributesError::NoSuchDomain(String::from(
parsed_error.message,
));
}
_ => {}
}
}
}
DeleteAttributesError::Unknown(res)
}
fn deserialize<T>(stack: &mut T) -> Result<XmlError, XmlParseError>
where
T: Peek + Next,
{
start_element("ErrorResponse", stack)?;
XmlErrorDeserializer::deserialize("Error", stack)
}
}
impl From<XmlParseError> for DeleteAttributesError {
fn from(err: XmlParseError) -> DeleteAttributesError {
let XmlParseError(message) = err;
DeleteAttributesError::ParseError(message.to_string())
}
}
impl From<CredentialsError> for DeleteAttributesError {
fn from(err: CredentialsError) -> DeleteAttributesError {
DeleteAttributesError::Credentials(err)
}
}
impl From<HttpDispatchError> for DeleteAttributesError {
fn from(err: HttpDispatchError) -> DeleteAttributesError {
DeleteAttributesError::HttpDispatch(err)
}
}
impl From<io::Error> for DeleteAttributesError {
fn from(err: io::Error) -> DeleteAttributesError {
DeleteAttributesError::HttpDispatch(HttpDispatchError::from(err))
}
}
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,
DeleteAttributesError::Validation(ref cause) => cause,
DeleteAttributesError::Credentials(ref err) => err.description(),
DeleteAttributesError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
DeleteAttributesError::ParseError(ref cause) => cause,
DeleteAttributesError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DeleteDomainError {
MissingParameter(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DeleteDomainError {
pub fn from_response(res: BufferedHttpResponse) -> DeleteDomainError {
{
let reader = EventReader::new(res.body.as_slice());
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 DeleteDomainError::MissingParameter(String::from(
parsed_error.message,
));
}
_ => {}
}
}
}
DeleteDomainError::Unknown(res)
}
fn deserialize<T>(stack: &mut T) -> Result<XmlError, XmlParseError>
where
T: Peek + Next,
{
start_element("ErrorResponse", stack)?;
XmlErrorDeserializer::deserialize("Error", stack)
}
}
impl From<XmlParseError> for DeleteDomainError {
fn from(err: XmlParseError) -> DeleteDomainError {
let XmlParseError(message) = err;
DeleteDomainError::ParseError(message.to_string())
}
}
impl From<CredentialsError> for DeleteDomainError {
fn from(err: CredentialsError) -> DeleteDomainError {
DeleteDomainError::Credentials(err)
}
}
impl From<HttpDispatchError> for DeleteDomainError {
fn from(err: HttpDispatchError) -> DeleteDomainError {
DeleteDomainError::HttpDispatch(err)
}
}
impl From<io::Error> for DeleteDomainError {
fn from(err: io::Error) -> DeleteDomainError {
DeleteDomainError::HttpDispatch(HttpDispatchError::from(err))
}
}
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,
DeleteDomainError::Validation(ref cause) => cause,
DeleteDomainError::Credentials(ref err) => err.description(),
DeleteDomainError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
DeleteDomainError::ParseError(ref cause) => cause,
DeleteDomainError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DomainMetadataError {
MissingParameter(String),
NoSuchDomain(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DomainMetadataError {
pub fn from_response(res: BufferedHttpResponse) -> DomainMetadataError {
{
let reader = EventReader::new(res.body.as_slice());
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 DomainMetadataError::MissingParameter(String::from(
parsed_error.message,
));
}
"NoSuchDomain" => {
return DomainMetadataError::NoSuchDomain(String::from(parsed_error.message));
}
_ => {}
}
}
}
DomainMetadataError::Unknown(res)
}
fn deserialize<T>(stack: &mut T) -> Result<XmlError, XmlParseError>
where
T: Peek + Next,
{
start_element("ErrorResponse", stack)?;
XmlErrorDeserializer::deserialize("Error", stack)
}
}
impl From<XmlParseError> for DomainMetadataError {
fn from(err: XmlParseError) -> DomainMetadataError {
let XmlParseError(message) = err;
DomainMetadataError::ParseError(message.to_string())
}
}
impl From<CredentialsError> for DomainMetadataError {
fn from(err: CredentialsError) -> DomainMetadataError {
DomainMetadataError::Credentials(err)
}
}
impl From<HttpDispatchError> for DomainMetadataError {
fn from(err: HttpDispatchError) -> DomainMetadataError {
DomainMetadataError::HttpDispatch(err)
}
}
impl From<io::Error> for DomainMetadataError {
fn from(err: io::Error) -> DomainMetadataError {
DomainMetadataError::HttpDispatch(HttpDispatchError::from(err))
}
}
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,
DomainMetadataError::Validation(ref cause) => cause,
DomainMetadataError::Credentials(ref err) => err.description(),
DomainMetadataError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
DomainMetadataError::ParseError(ref cause) => cause,
DomainMetadataError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum GetAttributesError {
InvalidParameterValue(String),
MissingParameter(String),
NoSuchDomain(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl GetAttributesError {
pub fn from_response(res: BufferedHttpResponse) -> GetAttributesError {
{
let reader = EventReader::new(res.body.as_slice());
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 GetAttributesError::InvalidParameterValue(String::from(
parsed_error.message,
));
}
"MissingParameter" => {
return GetAttributesError::MissingParameter(String::from(
parsed_error.message,
));
}
"NoSuchDomain" => {
return GetAttributesError::NoSuchDomain(String::from(parsed_error.message));
}
_ => {}
}
}
}
GetAttributesError::Unknown(res)
}
fn deserialize<T>(stack: &mut T) -> Result<XmlError, XmlParseError>
where
T: Peek + Next,
{
start_element("ErrorResponse", stack)?;
XmlErrorDeserializer::deserialize("Error", stack)
}
}
impl From<XmlParseError> for GetAttributesError {
fn from(err: XmlParseError) -> GetAttributesError {
let XmlParseError(message) = err;
GetAttributesError::ParseError(message.to_string())
}
}
impl From<CredentialsError> for GetAttributesError {
fn from(err: CredentialsError) -> GetAttributesError {
GetAttributesError::Credentials(err)
}
}
impl From<HttpDispatchError> for GetAttributesError {
fn from(err: HttpDispatchError) -> GetAttributesError {
GetAttributesError::HttpDispatch(err)
}
}
impl From<io::Error> for GetAttributesError {
fn from(err: io::Error) -> GetAttributesError {
GetAttributesError::HttpDispatch(HttpDispatchError::from(err))
}
}
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,
GetAttributesError::Validation(ref cause) => cause,
GetAttributesError::Credentials(ref err) => err.description(),
GetAttributesError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
GetAttributesError::ParseError(ref cause) => cause,
GetAttributesError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum ListDomainsError {
InvalidNextToken(String),
InvalidParameterValue(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl ListDomainsError {
pub fn from_response(res: BufferedHttpResponse) -> ListDomainsError {
{
let reader = EventReader::new(res.body.as_slice());
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 ListDomainsError::InvalidNextToken(String::from(
parsed_error.message,
));
}
"InvalidParameterValue" => {
return ListDomainsError::InvalidParameterValue(String::from(
parsed_error.message,
));
}
_ => {}
}
}
}
ListDomainsError::Unknown(res)
}
fn deserialize<T>(stack: &mut T) -> Result<XmlError, XmlParseError>
where
T: Peek + Next,
{
start_element("ErrorResponse", stack)?;
XmlErrorDeserializer::deserialize("Error", stack)
}
}
impl From<XmlParseError> for ListDomainsError {
fn from(err: XmlParseError) -> ListDomainsError {
let XmlParseError(message) = err;
ListDomainsError::ParseError(message.to_string())
}
}
impl From<CredentialsError> for ListDomainsError {
fn from(err: CredentialsError) -> ListDomainsError {
ListDomainsError::Credentials(err)
}
}
impl From<HttpDispatchError> for ListDomainsError {
fn from(err: HttpDispatchError) -> ListDomainsError {
ListDomainsError::HttpDispatch(err)
}
}
impl From<io::Error> for ListDomainsError {
fn from(err: io::Error) -> ListDomainsError {
ListDomainsError::HttpDispatch(HttpDispatchError::from(err))
}
}
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,
ListDomainsError::Validation(ref cause) => cause,
ListDomainsError::Credentials(ref err) => err.description(),
ListDomainsError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
ListDomainsError::ParseError(ref cause) => cause,
ListDomainsError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum PutAttributesError {
AttributeDoesNotExist(String),
InvalidParameterValue(String),
MissingParameter(String),
NoSuchDomain(String),
NumberDomainAttributesExceeded(String),
NumberDomainBytesExceeded(String),
NumberItemAttributesExceeded(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl PutAttributesError {
pub fn from_response(res: BufferedHttpResponse) -> PutAttributesError {
{
let reader = EventReader::new(res.body.as_slice());
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 PutAttributesError::AttributeDoesNotExist(String::from(
parsed_error.message,
));
}
"InvalidParameterValue" => {
return PutAttributesError::InvalidParameterValue(String::from(
parsed_error.message,
));
}
"MissingParameter" => {
return PutAttributesError::MissingParameter(String::from(
parsed_error.message,
));
}
"NoSuchDomain" => {
return PutAttributesError::NoSuchDomain(String::from(parsed_error.message));
}
"NumberDomainAttributesExceeded" => {
return PutAttributesError::NumberDomainAttributesExceeded(String::from(
parsed_error.message,
));
}
"NumberDomainBytesExceeded" => {
return PutAttributesError::NumberDomainBytesExceeded(String::from(
parsed_error.message,
));
}
"NumberItemAttributesExceeded" => {
return PutAttributesError::NumberItemAttributesExceeded(String::from(
parsed_error.message,
));
}
_ => {}
}
}
}
PutAttributesError::Unknown(res)
}
fn deserialize<T>(stack: &mut T) -> Result<XmlError, XmlParseError>
where
T: Peek + Next,
{
start_element("ErrorResponse", stack)?;
XmlErrorDeserializer::deserialize("Error", stack)
}
}
impl From<XmlParseError> for PutAttributesError {
fn from(err: XmlParseError) -> PutAttributesError {
let XmlParseError(message) = err;
PutAttributesError::ParseError(message.to_string())
}
}
impl From<CredentialsError> for PutAttributesError {
fn from(err: CredentialsError) -> PutAttributesError {
PutAttributesError::Credentials(err)
}
}
impl From<HttpDispatchError> for PutAttributesError {
fn from(err: HttpDispatchError) -> PutAttributesError {
PutAttributesError::HttpDispatch(err)
}
}
impl From<io::Error> for PutAttributesError {
fn from(err: io::Error) -> PutAttributesError {
PutAttributesError::HttpDispatch(HttpDispatchError::from(err))
}
}
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,
PutAttributesError::Validation(ref cause) => cause,
PutAttributesError::Credentials(ref err) => err.description(),
PutAttributesError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
PutAttributesError::ParseError(ref cause) => cause,
PutAttributesError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum SelectError {
InvalidNextToken(String),
InvalidNumberPredicates(String),
InvalidNumberValueTests(String),
InvalidParameterValue(String),
InvalidQueryExpression(String),
MissingParameter(String),
NoSuchDomain(String),
RequestTimeout(String),
TooManyRequestedAttributes(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl SelectError {
pub fn from_response(res: BufferedHttpResponse) -> SelectError {
{
let reader = EventReader::new(res.body.as_slice());
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 SelectError::InvalidNextToken(String::from(parsed_error.message));
}
"InvalidNumberPredicates" => {
return SelectError::InvalidNumberPredicates(String::from(
parsed_error.message,
));
}
"InvalidNumberValueTests" => {
return SelectError::InvalidNumberValueTests(String::from(
parsed_error.message,
));
}
"InvalidParameterValue" => {
return SelectError::InvalidParameterValue(String::from(
parsed_error.message,
));
}
"InvalidQueryExpression" => {
return SelectError::InvalidQueryExpression(String::from(
parsed_error.message,
));
}
"MissingParameter" => {
return SelectError::MissingParameter(String::from(parsed_error.message));
}
"NoSuchDomain" => {
return SelectError::NoSuchDomain(String::from(parsed_error.message));
}
"RequestTimeout" => {
return SelectError::RequestTimeout(String::from(parsed_error.message));
}
"TooManyRequestedAttributes" => {
return SelectError::TooManyRequestedAttributes(String::from(
parsed_error.message,
));
}
_ => {}
}
}
}
SelectError::Unknown(res)
}
fn deserialize<T>(stack: &mut T) -> Result<XmlError, XmlParseError>
where
T: Peek + Next,
{
start_element("ErrorResponse", stack)?;
XmlErrorDeserializer::deserialize("Error", stack)
}
}
impl From<XmlParseError> for SelectError {
fn from(err: XmlParseError) -> SelectError {
let XmlParseError(message) = err;
SelectError::ParseError(message.to_string())
}
}
impl From<CredentialsError> for SelectError {
fn from(err: CredentialsError) -> SelectError {
SelectError::Credentials(err)
}
}
impl From<HttpDispatchError> for SelectError {
fn from(err: HttpDispatchError) -> SelectError {
SelectError::HttpDispatch(err)
}
}
impl From<io::Error> for SelectError {
fn from(err: io::Error) -> SelectError {
SelectError::HttpDispatch(HttpDispatchError::from(err))
}
}
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,
SelectError::Validation(ref cause) => cause,
SelectError::Credentials(ref err) => err.description(),
SelectError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
SelectError::ParseError(ref cause) => cause,
SelectError::Unknown(_) => "unknown error",
}
}
}
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: 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: 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().into_bytes(),
));
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().into_bytes(),
));
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().into_bytes(),
));
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().into_bytes(),
));
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().into_bytes(),
));
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().into_bytes(),
));
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_slice(),
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().into_bytes(),
));
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_slice(),
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().into_bytes(),
));
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_slice(),
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().into_bytes(),
));
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().into_bytes(),
));
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_slice(),
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)
}))
})
}
}
#[cfg(test)]
mod protocol_tests {}