// =================================================================
//
// * WARNING *
//
// This file is generated!
//
// Changes made to this file will be overwritten. If changes are
// required to the generated code, the service_crategen project
// must be updated to generate the changes.
//
// =================================================================
use std::error::Error;
use std::fmt;
use async_trait::async_trait;
use rusoto_core::credential::ProvideAwsCredentials;
use rusoto_core::region;
use rusoto_core::request::{BufferedHttpResponse, DispatchSignedRequest};
use rusoto_core::{Client, RusotoError};
use rusoto_core::param::{Params, ServiceParams};
use rusoto_core::proto::xml::error::*;
use rusoto_core::proto::xml::util::{
self as xml_util, deserialize_elements, find_start_element, skip_tree,
};
use rusoto_core::proto::xml::util::{Next, Peek, XmlParseError, XmlResponse};
use rusoto_core::request::HttpResponse;
use rusoto_core::signature::SignedRequest;
#[cfg(feature = "deserialize_structs")]
use serde::Deserialize;
#[cfg(feature = "serialize_structs")]
use serde::Serialize;
use serde_urlencoded;
use std::str::FromStr;
use xml::EventReader;
impl SimpleDbClient {
fn new_params(&self, operation_name: &str) -> Params {
let mut params = Params::new();
params.put("Action", operation_name);
params.put("Version", "2009-04-15");
params
}
async fn sign_and_dispatch(
&self,
request: SignedRequest,
from_response: fn(BufferedHttpResponse) -> RusotoError,
) -> Result> {
let mut response = self.client.sign_and_dispatch(request).await?;
if !response.status.is_success() {
let response = response.buffer().await.map_err(RusotoError::HttpDispatch)?;
return Err(from_response(response));
}
Ok(response)
}
}
///
#[derive(Clone, Debug, Default, PartialEq)]
#[cfg_attr(feature = "serialize_structs", derive(Serialize))]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct Attribute {
///
pub alternate_name_encoding: Option,
///
pub alternate_value_encoding: Option,
/// The name of the attribute.
pub name: String,
/// The value of the attribute.
pub value: String,
}
#[allow(dead_code)]
struct AttributeDeserializer;
impl AttributeDeserializer {
#[allow(dead_code, unused_variables)]
fn deserialize(
tag_name: &str,
stack: &mut T,
) -> Result {
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(())
})
}
}
/// Serialize `Attribute` contents to a `SignedRequest`.
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);
}
}
#[allow(dead_code)]
struct AttributeListDeserializer;
impl AttributeListDeserializer {
#[allow(dead_code, unused_variables)]
fn deserialize(
tag_name: &str,
stack: &mut T,
) -> Result, 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)
}
}
/// Serialize `AttributeList` contents to a `SignedRequest`.
struct AttributeListSerializer;
impl AttributeListSerializer {
fn serialize(params: &mut Params, name: &str, obj: &Vec) {
for (index, obj) in obj.iter().enumerate() {
let key = format!("{}.{}", name, index + 1);
AttributeSerializer::serialize(params, &key, obj);
}
}
}
/// Serialize `AttributeNameList` contents to a `SignedRequest`.
struct AttributeNameListSerializer;
impl AttributeNameListSerializer {
fn serialize(params: &mut Params, name: &str, obj: &Vec) {
for (index, obj) in obj.iter().enumerate() {
let key = format!("{}.{}", name, index + 1);
params.put(&key, &obj);
}
}
}
#[derive(Clone, Debug, Default, PartialEq)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct BatchDeleteAttributesRequest {
/// The name of the domain in which the attributes are being deleted.
pub domain_name: String,
/// A list of items on which to perform the operation.
pub items: Vec,
}
/// Serialize `BatchDeleteAttributesRequest` contents to a `SignedRequest`.
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(Clone, Debug, Default, PartialEq)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct BatchPutAttributesRequest {
/// The name of the domain in which the attributes are being stored.
pub domain_name: String,
/// A list of items on which to perform the operation.
pub items: Vec,
}
/// Serialize `BatchPutAttributesRequest` contents to a `SignedRequest`.
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(Clone, Debug, Default, PartialEq)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct CreateDomainRequest {
/// The name of the domain to create. The name can range between 3 and 255 characters and can contain the following characters: a-z, A-Z, 0-9, '_', '-', and '.'.
pub domain_name: String,
}
/// Serialize `CreateDomainRequest` contents to a `SignedRequest`.
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(Clone, Debug, Default, PartialEq)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct DeletableItem {
pub attributes: Option>,
pub name: String,
}
/// Serialize `DeletableItem` contents to a `SignedRequest`.
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);
}
}
/// Serialize `DeletableItemList` contents to a `SignedRequest`.
struct DeletableItemListSerializer;
impl DeletableItemListSerializer {
fn serialize(params: &mut Params, name: &str, obj: &Vec) {
for (index, obj) in obj.iter().enumerate() {
let key = format!("{}.{}", name, index + 1);
DeletableItemSerializer::serialize(params, &key, obj);
}
}
}
#[derive(Clone, Debug, Default, PartialEq)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct DeleteAttributesRequest {
/// A list of Attributes. Similar to columns on a spreadsheet, attributes represent categories of data that can be assigned to items.
pub attributes: Option>,
/// The name of the domain in which to perform the operation.
pub domain_name: String,
/// The update condition which, if specified, determines whether the specified attributes will be deleted or not. The update condition must be satisfied in order for this request to be processed and the attributes to be deleted.
pub expected: Option,
/// The name of the item. Similar to rows on a spreadsheet, items represent individual objects that contain one or more value-attribute pairs.
pub item_name: String,
}
/// Serialize `DeleteAttributesRequest` contents to a `SignedRequest`.
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(Clone, Debug, Default, PartialEq)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct DeleteDomainRequest {
/// The name of the domain to delete.
pub domain_name: String,
}
/// Serialize `DeleteDomainRequest` contents to a `SignedRequest`.
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(Clone, Debug, Default, PartialEq)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct DomainMetadataRequest {
/// The name of the domain for which to display the metadata of.
pub domain_name: String,
}
/// Serialize `DomainMetadataRequest` contents to a `SignedRequest`.
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(Clone, Debug, Default, PartialEq)]
#[cfg_attr(feature = "serialize_structs", derive(Serialize))]
pub struct DomainMetadataResult {
/// The number of unique attribute names in the domain.
pub attribute_name_count: Option,
/// The total size of all unique attribute names in the domain, in bytes.
pub attribute_names_size_bytes: Option,
/// The number of all attribute name/value pairs in the domain.
pub attribute_value_count: Option,
/// The total size of all attribute values in the domain, in bytes.
pub attribute_values_size_bytes: Option,
/// The number of all items in the domain.
pub item_count: Option,
/// The total size of all item names in the domain, in bytes.
pub item_names_size_bytes: Option,
/// The data and time when metadata was calculated, in Epoch (UNIX) seconds.
pub timestamp: Option,
}
#[allow(dead_code)]
struct DomainMetadataResultDeserializer;
impl DomainMetadataResultDeserializer {
#[allow(dead_code, unused_variables)]
fn deserialize(
tag_name: &str,
stack: &mut T,
) -> Result {
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(())
})
}
}
#[allow(dead_code)]
struct DomainNameListDeserializer;
impl DomainNameListDeserializer {
#[allow(dead_code, unused_variables)]
fn deserialize(
tag_name: &str,
stack: &mut T,
) -> Result, 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(Clone, Debug, Default, PartialEq)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct GetAttributesRequest {
/// The names of the attributes.
pub attribute_names: Option>,
/// Determines whether or not strong consistency should be enforced when data is read from SimpleDB. If true
, any data previously written to SimpleDB will be returned. Otherwise, results will be consistent eventually, and the client may not see data that was written immediately before your read.
pub consistent_read: Option,
/// The name of the domain in which to perform the operation.
pub domain_name: String,
/// The name of the item.
pub item_name: String,
}
/// Serialize `GetAttributesRequest` contents to a `SignedRequest`.
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(Clone, Debug, Default, PartialEq)]
#[cfg_attr(feature = "serialize_structs", derive(Serialize))]
pub struct GetAttributesResult {
/// The list of attributes returned by the operation.
pub attributes: Option>,
}
#[allow(dead_code)]
struct GetAttributesResultDeserializer;
impl GetAttributesResultDeserializer {
#[allow(dead_code, unused_variables)]
fn deserialize(
tag_name: &str,
stack: &mut T,
) -> Result {
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(())
})
}
}
#[allow(dead_code)]
struct IntegerDeserializer;
impl IntegerDeserializer {
#[allow(dead_code, unused_variables)]
fn deserialize(tag_name: &str, stack: &mut T) -> Result {
xml_util::deserialize_primitive(tag_name, stack, |s| Ok(i64::from_str(&s).unwrap()))
}
}
///
#[derive(Clone, Debug, Default, PartialEq)]
#[cfg_attr(feature = "serialize_structs", derive(Serialize))]
pub struct Item {
///
pub alternate_name_encoding: Option,
/// A list of attributes.
pub attributes: Vec,
/// The name of the item.
pub name: String,
}
#[allow(dead_code)]
struct ItemDeserializer;
impl ItemDeserializer {
#[allow(dead_code, unused_variables)]
fn deserialize(tag_name: &str, stack: &mut T) -> Result- {
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(())
})
}
}
#[allow(dead_code)]
struct ItemListDeserializer;
impl ItemListDeserializer {
#[allow(dead_code, unused_variables)]
fn deserialize(
tag_name: &str,
stack: &mut T,
) -> Result, 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(Clone, Debug, Default, PartialEq)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct ListDomainsRequest {
///
The maximum number of domain names you want returned. The range is 1 to 100. The default setting is 100.
pub max_number_of_domains: Option,
/// A string informing Amazon SimpleDB where to start the next list of domain names.
pub next_token: Option,
}
/// Serialize `ListDomainsRequest` contents to a `SignedRequest`.
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(Clone, Debug, Default, PartialEq)]
#[cfg_attr(feature = "serialize_structs", derive(Serialize))]
pub struct ListDomainsResult {
/// A list of domain names that match the expression.
pub domain_names: Option>,
/// An opaque token indicating that there are more domains than the specified MaxNumberOfDomains
still available.
pub next_token: Option,
}
#[allow(dead_code)]
struct ListDomainsResultDeserializer;
impl ListDomainsResultDeserializer {
#[allow(dead_code, unused_variables)]
fn deserialize(
tag_name: &str,
stack: &mut T,
) -> Result {
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(())
})
}
}
#[allow(dead_code)]
struct LongDeserializer;
impl LongDeserializer {
#[allow(dead_code, unused_variables)]
fn deserialize(tag_name: &str, stack: &mut T) -> Result {
xml_util::deserialize_primitive(tag_name, stack, |s| Ok(i64::from_str(&s).unwrap()))
}
}
#[derive(Clone, Debug, Default, PartialEq)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct PutAttributesRequest {
/// The list of attributes.
pub attributes: Vec,
/// The name of the domain in which to perform the operation.
pub domain_name: String,
/// The update condition which, if specified, determines whether the specified attributes will be updated or not. The update condition must be satisfied in order for this request to be processed and the attributes to be updated.
pub expected: Option,
/// The name of the item.
pub item_name: String,
}
/// Serialize `PutAttributesRequest` contents to a `SignedRequest`.
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(Clone, Debug, Default, PartialEq)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct ReplaceableAttribute {
/// The name of the replaceable attribute.
pub name: String,
/// A flag specifying whether or not to replace the attribute/value pair or to add a new attribute/value pair. The default setting is false
.
pub replace: Option,
/// The value of the replaceable attribute.
pub value: String,
}
/// Serialize `ReplaceableAttribute` contents to a `SignedRequest`.
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);
}
}
/// Serialize `ReplaceableAttributeList` contents to a `SignedRequest`.
struct ReplaceableAttributeListSerializer;
impl ReplaceableAttributeListSerializer {
fn serialize(params: &mut Params, name: &str, obj: &Vec) {
for (index, obj) in obj.iter().enumerate() {
let key = format!("{}.{}", name, index + 1);
ReplaceableAttributeSerializer::serialize(params, &key, obj);
}
}
}
///
#[derive(Clone, Debug, Default, PartialEq)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct ReplaceableItem {
/// The list of attributes for a replaceable item.
pub attributes: Vec,
/// The name of the replaceable item.
pub name: String,
}
/// Serialize `ReplaceableItem` contents to a `SignedRequest`.
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);
}
}
/// Serialize `ReplaceableItemList` contents to a `SignedRequest`.
struct ReplaceableItemListSerializer;
impl ReplaceableItemListSerializer {
fn serialize(params: &mut Params, name: &str, obj: &Vec) {
for (index, obj) in obj.iter().enumerate() {
let key = format!("{}.{}", name, index + 1);
ReplaceableItemSerializer::serialize(params, &key, obj);
}
}
}
#[derive(Clone, Debug, Default, PartialEq)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct SelectRequest {
/// Determines whether or not strong consistency should be enforced when data is read from SimpleDB. If true
, any data previously written to SimpleDB will be returned. Otherwise, results will be consistent eventually, and the client may not see data that was written immediately before your read.
pub consistent_read: Option,
/// A string informing Amazon SimpleDB where to start the next list of ItemNames
.
pub next_token: Option,
/// The expression used to query the domain.
pub select_expression: String,
}
/// Serialize `SelectRequest` contents to a `SignedRequest`.
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(Clone, Debug, Default, PartialEq)]
#[cfg_attr(feature = "serialize_structs", derive(Serialize))]
pub struct SelectResult {
/// A list of items that match the select expression.
pub items: Option>,
/// An opaque token indicating that more items than MaxNumberOfItems
were matched, the response size exceeded 1 megabyte, or the execution time exceeded 5 seconds.
pub next_token: Option,
}
#[allow(dead_code)]
struct SelectResultDeserializer;
impl SelectResultDeserializer {
#[allow(dead_code, unused_variables)]
fn deserialize(
tag_name: &str,
stack: &mut T,
) -> Result {
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(())
})
}
}
#[allow(dead_code)]
struct StringDeserializer;
impl StringDeserializer {
#[allow(dead_code, unused_variables)]
fn deserialize(tag_name: &str, stack: &mut T) -> Result {
xml_util::deserialize_primitive(tag_name, stack, Ok)
}
}
/// Specifies the conditions under which data should be updated. If an update condition is specified for a request, the data will only be updated if the condition is satisfied. For example, if an attribute with a specific name and value exists, or if a specific attribute doesn't exist.
#[derive(Clone, Debug, Default, PartialEq)]
#[cfg_attr(feature = "deserialize_structs", derive(Deserialize))]
pub struct UpdateCondition {
/// A value specifying whether or not the specified attribute must exist with the specified value in order for the update condition to be satisfied. Specify true
if the attribute must exist for the update condition to be satisfied. Specify false
if the attribute should not exist in order for the update condition to be satisfied.
pub exists: Option,
/// The name of the attribute involved in the condition.
pub name: Option,
/// The value of an attribute. This value can only be specified when the Exists
parameter is equal to true
.
pub value: Option,
}
/// Serialize `UpdateCondition` contents to a `SignedRequest`.
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);
}
}
}
/// Errors returned by BatchDeleteAttributes
#[derive(Debug, PartialEq)]
pub enum BatchDeleteAttributesError {}
impl BatchDeleteAttributesError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError {
{
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(stack: &mut T) -> Result
where
T: Peek + Next,
{
xml_util::start_element("ErrorResponse", stack)?;
XmlErrorDeserializer::deserialize("Error", stack)
}
}
impl fmt::Display for BatchDeleteAttributesError {
#[allow(unused_variables)]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {}
}
}
impl Error for BatchDeleteAttributesError {}
/// Errors returned by BatchPutAttributes
#[derive(Debug, PartialEq)]
pub enum BatchPutAttributesError {
/// The item name was specified more than once.
DuplicateItemName(String),
/// The value for a parameter is invalid.
InvalidParameterValue(String),
/// The request must contain the specified missing parameter.
MissingParameter(String),
/// The specified domain does not exist.
NoSuchDomain(String),
/// Too many attributes in this domain.
NumberDomainAttributesExceeded(String),
/// Too many bytes in this domain.
NumberDomainBytesExceeded(String),
/// Too many attributes in this item.
NumberItemAttributesExceeded(String),
/// Too many attributes exist in a single call.
NumberSubmittedAttributesExceeded(String),
/// Too many items exist in a single call.
NumberSubmittedItemsExceeded(String),
}
impl BatchPutAttributesError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError {
{
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(stack: &mut T) -> Result
where
T: Peek + Next,
{
xml_util::start_element("ErrorResponse", stack)?;
XmlErrorDeserializer::deserialize("Error", stack)
}
}
impl fmt::Display for BatchPutAttributesError {
#[allow(unused_variables)]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
BatchPutAttributesError::DuplicateItemName(ref cause) => write!(f, "{}", cause),
BatchPutAttributesError::InvalidParameterValue(ref cause) => write!(f, "{}", cause),
BatchPutAttributesError::MissingParameter(ref cause) => write!(f, "{}", cause),
BatchPutAttributesError::NoSuchDomain(ref cause) => write!(f, "{}", cause),
BatchPutAttributesError::NumberDomainAttributesExceeded(ref cause) => {
write!(f, "{}", cause)
}
BatchPutAttributesError::NumberDomainBytesExceeded(ref cause) => write!(f, "{}", cause),
BatchPutAttributesError::NumberItemAttributesExceeded(ref cause) => {
write!(f, "{}", cause)
}
BatchPutAttributesError::NumberSubmittedAttributesExceeded(ref cause) => {
write!(f, "{}", cause)
}
BatchPutAttributesError::NumberSubmittedItemsExceeded(ref cause) => {
write!(f, "{}", cause)
}
}
}
}
impl Error for BatchPutAttributesError {}
/// Errors returned by CreateDomain
#[derive(Debug, PartialEq)]
pub enum CreateDomainError {
/// The value for a parameter is invalid.
InvalidParameterValue(String),
/// The request must contain the specified missing parameter.
MissingParameter(String),
/// Too many domains exist per this account.
NumberDomainsExceeded(String),
}
impl CreateDomainError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError {
{
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(stack: &mut T) -> Result
where
T: Peek + Next,
{
xml_util::start_element("ErrorResponse", stack)?;
XmlErrorDeserializer::deserialize("Error", stack)
}
}
impl fmt::Display for CreateDomainError {
#[allow(unused_variables)]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
CreateDomainError::InvalidParameterValue(ref cause) => write!(f, "{}", cause),
CreateDomainError::MissingParameter(ref cause) => write!(f, "{}", cause),
CreateDomainError::NumberDomainsExceeded(ref cause) => write!(f, "{}", cause),
}
}
}
impl Error for CreateDomainError {}
/// Errors returned by DeleteAttributes
#[derive(Debug, PartialEq)]
pub enum DeleteAttributesError {
/// The specified attribute does not exist.
AttributeDoesNotExist(String),
/// The value for a parameter is invalid.
InvalidParameterValue(String),
/// The request must contain the specified missing parameter.
MissingParameter(String),
/// The specified domain does not exist.
NoSuchDomain(String),
}
impl DeleteAttributesError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError {
{
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(stack: &mut T) -> Result
where
T: Peek + Next,
{
xml_util::start_element("ErrorResponse", stack)?;
XmlErrorDeserializer::deserialize("Error", stack)
}
}
impl fmt::Display for DeleteAttributesError {
#[allow(unused_variables)]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
DeleteAttributesError::AttributeDoesNotExist(ref cause) => write!(f, "{}", cause),
DeleteAttributesError::InvalidParameterValue(ref cause) => write!(f, "{}", cause),
DeleteAttributesError::MissingParameter(ref cause) => write!(f, "{}", cause),
DeleteAttributesError::NoSuchDomain(ref cause) => write!(f, "{}", cause),
}
}
}
impl Error for DeleteAttributesError {}
/// Errors returned by DeleteDomain
#[derive(Debug, PartialEq)]
pub enum DeleteDomainError {
/// The request must contain the specified missing parameter.
MissingParameter(String),
}
impl DeleteDomainError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError {
{
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(stack: &mut T) -> Result
where
T: Peek + Next,
{
xml_util::start_element("ErrorResponse", stack)?;
XmlErrorDeserializer::deserialize("Error", stack)
}
}
impl fmt::Display for DeleteDomainError {
#[allow(unused_variables)]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
DeleteDomainError::MissingParameter(ref cause) => write!(f, "{}", cause),
}
}
}
impl Error for DeleteDomainError {}
/// Errors returned by DomainMetadata
#[derive(Debug, PartialEq)]
pub enum DomainMetadataError {
/// The request must contain the specified missing parameter.
MissingParameter(String),
/// The specified domain does not exist.
NoSuchDomain(String),
}
impl DomainMetadataError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError {
{
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(stack: &mut T) -> Result
where
T: Peek + Next,
{
xml_util::start_element("ErrorResponse", stack)?;
XmlErrorDeserializer::deserialize("Error", stack)
}
}
impl fmt::Display for DomainMetadataError {
#[allow(unused_variables)]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
DomainMetadataError::MissingParameter(ref cause) => write!(f, "{}", cause),
DomainMetadataError::NoSuchDomain(ref cause) => write!(f, "{}", cause),
}
}
}
impl Error for DomainMetadataError {}
/// Errors returned by GetAttributes
#[derive(Debug, PartialEq)]
pub enum GetAttributesError {
/// The value for a parameter is invalid.
InvalidParameterValue(String),
/// The request must contain the specified missing parameter.
MissingParameter(String),
/// The specified domain does not exist.
NoSuchDomain(String),
}
impl GetAttributesError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError {
{
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(stack: &mut T) -> Result
where
T: Peek + Next,
{
xml_util::start_element("ErrorResponse", stack)?;
XmlErrorDeserializer::deserialize("Error", stack)
}
}
impl fmt::Display for GetAttributesError {
#[allow(unused_variables)]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
GetAttributesError::InvalidParameterValue(ref cause) => write!(f, "{}", cause),
GetAttributesError::MissingParameter(ref cause) => write!(f, "{}", cause),
GetAttributesError::NoSuchDomain(ref cause) => write!(f, "{}", cause),
}
}
}
impl Error for GetAttributesError {}
/// Errors returned by ListDomains
#[derive(Debug, PartialEq)]
pub enum ListDomainsError {
/// The specified NextToken is not valid.
InvalidNextToken(String),
/// The value for a parameter is invalid.
InvalidParameterValue(String),
}
impl ListDomainsError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError {
{
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(stack: &mut T) -> Result
where
T: Peek + Next,
{
xml_util::start_element("ErrorResponse", stack)?;
XmlErrorDeserializer::deserialize("Error", stack)
}
}
impl fmt::Display for ListDomainsError {
#[allow(unused_variables)]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
ListDomainsError::InvalidNextToken(ref cause) => write!(f, "{}", cause),
ListDomainsError::InvalidParameterValue(ref cause) => write!(f, "{}", cause),
}
}
}
impl Error for ListDomainsError {}
/// Errors returned by PutAttributes
#[derive(Debug, PartialEq)]
pub enum PutAttributesError {
/// The specified attribute does not exist.
AttributeDoesNotExist(String),
/// The value for a parameter is invalid.
InvalidParameterValue(String),
/// The request must contain the specified missing parameter.
MissingParameter(String),
/// The specified domain does not exist.
NoSuchDomain(String),
/// Too many attributes in this domain.
NumberDomainAttributesExceeded(String),
/// Too many bytes in this domain.
NumberDomainBytesExceeded(String),
/// Too many attributes in this item.
NumberItemAttributesExceeded(String),
}
impl PutAttributesError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError {
{
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(stack: &mut T) -> Result
where
T: Peek + Next,
{
xml_util::start_element("ErrorResponse", stack)?;
XmlErrorDeserializer::deserialize("Error", stack)
}
}
impl fmt::Display for PutAttributesError {
#[allow(unused_variables)]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
PutAttributesError::AttributeDoesNotExist(ref cause) => write!(f, "{}", cause),
PutAttributesError::InvalidParameterValue(ref cause) => write!(f, "{}", cause),
PutAttributesError::MissingParameter(ref cause) => write!(f, "{}", cause),
PutAttributesError::NoSuchDomain(ref cause) => write!(f, "{}", cause),
PutAttributesError::NumberDomainAttributesExceeded(ref cause) => write!(f, "{}", cause),
PutAttributesError::NumberDomainBytesExceeded(ref cause) => write!(f, "{}", cause),
PutAttributesError::NumberItemAttributesExceeded(ref cause) => write!(f, "{}", cause),
}
}
}
impl Error for PutAttributesError {}
/// Errors returned by Select
#[derive(Debug, PartialEq)]
pub enum SelectError {
/// The specified NextToken is not valid.
InvalidNextToken(String),
/// Too many predicates exist in the query expression.
InvalidNumberPredicates(String),
/// Too many predicates exist in the query expression.
InvalidNumberValueTests(String),
/// The value for a parameter is invalid.
InvalidParameterValue(String),
/// The specified query expression syntax is not valid.
InvalidQueryExpression(String),
/// The request must contain the specified missing parameter.
MissingParameter(String),
/// The specified domain does not exist.
NoSuchDomain(String),
/// A timeout occurred when attempting to query the specified domain with specified query expression.
RequestTimeout(String),
/// Too many attributes requested.
TooManyRequestedAttributes(String),
}
impl SelectError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError {
{
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(stack: &mut T) -> Result
where
T: Peek + Next,
{
xml_util::start_element("ErrorResponse", stack)?;
XmlErrorDeserializer::deserialize("Error", stack)
}
}
impl fmt::Display for SelectError {
#[allow(unused_variables)]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
SelectError::InvalidNextToken(ref cause) => write!(f, "{}", cause),
SelectError::InvalidNumberPredicates(ref cause) => write!(f, "{}", cause),
SelectError::InvalidNumberValueTests(ref cause) => write!(f, "{}", cause),
SelectError::InvalidParameterValue(ref cause) => write!(f, "{}", cause),
SelectError::InvalidQueryExpression(ref cause) => write!(f, "{}", cause),
SelectError::MissingParameter(ref cause) => write!(f, "{}", cause),
SelectError::NoSuchDomain(ref cause) => write!(f, "{}", cause),
SelectError::RequestTimeout(ref cause) => write!(f, "{}", cause),
SelectError::TooManyRequestedAttributes(ref cause) => write!(f, "{}", cause),
}
}
}
impl Error for SelectError {}
/// Trait representing the capabilities of the Amazon SimpleDB API. Amazon SimpleDB clients implement this trait.
#[async_trait]
pub trait SimpleDb {
/// Performs multiple DeleteAttributes operations in a single call, which reduces round trips and latencies. This enables Amazon SimpleDB to optimize requests, which generally yields better throughput.
The following limitations are enforced for this operation:
- 1 MB request size
- 25 item limit per BatchDeleteAttributes operation
async fn batch_delete_attributes(
&self,
input: BatchDeleteAttributesRequest,
) -> Result<(), RusotoError>;
/// The BatchPutAttributes
operation creates or replaces attributes within one or more items. By using this operation, the client can perform multiple PutAttribute operation with a single call. This helps yield savings in round trips and latencies, enabling Amazon SimpleDB to optimize requests and generally produce better throughput.
The client may specify the item name with the Item.X.ItemName
parameter. The client may specify new attributes using a combination of the Item.X.Attribute.Y.Name
and Item.X.Attribute.Y.Value
parameters. The client may specify the first attribute for the first item using the parameters Item.0.Attribute.0.Name
and Item.0.Attribute.0.Value
, and for the second attribute for the first item by the parameters Item.0.Attribute.1.Name
and Item.0.Attribute.1.Value
, and so on.
Attributes are uniquely identified within an item by their name/value combination. For example, a single item can have the attributes { "first_name", "first_value" }
and { "first_name", "second_value" }
. However, it cannot have two attribute instances where both the Item.X.Attribute.Y.Name
and Item.X.Attribute.Y.Value
are the same.
Optionally, the requester can supply the Replace
parameter for each individual value. Setting this value to true
will cause the new attribute values to replace the existing attribute values. For example, if an item I
has the attributes { 'a', '1' }, { 'b', '2'}
and { 'b', '3' }
and the requester does a BatchPutAttributes of {'I', 'b', '4' }
with the Replace parameter set to true, the final attributes of the item will be { 'a', '1' }
and { 'b', '4' }
, replacing the previous values of the 'b' attribute with the new value.
This operation is vulnerable to exceeding the maximum URL size when making a REST request using the HTTP GET method. This operation does not support conditions using Expected.X.Name
, Expected.X.Value
, or Expected.X.Exists
. You can execute multiple BatchPutAttributes
operations and other operations in parallel. However, large numbers of concurrent BatchPutAttributes
calls can result in Service Unavailable (503) responses.
The following limitations are enforced for this operation:
- 256 attribute name-value pairs per item
- 1 MB request size
- 1 billion attributes per domain
- 10 GB of total user data storage per domain
- 25 item limit per
BatchPutAttributes
operation
async fn batch_put_attributes(
&self,
input: BatchPutAttributesRequest,
) -> Result<(), RusotoError>;
/// The CreateDomain
operation creates a new domain. The domain name should be unique among the domains associated with the Access Key ID provided in the request. The CreateDomain
operation may take 10 or more seconds to complete.
The client can create up to 100 domains per account.
If the client requires additional domains, go to http://aws.amazon.com/contact-us/simpledb-limit-request/.
async fn create_domain(
&self,
input: CreateDomainRequest,
) -> Result<(), RusotoError>;
/// Deletes one or more attributes associated with an item. If all attributes of the item are deleted, the item is deleted.
DeleteAttributes
is an idempotent operation; running it multiple times on the same item or attribute does not result in an error response.
Because Amazon SimpleDB makes multiple copies of item data and uses an eventual consistency update model, performing a GetAttributes or Select operation (read) immediately after a DeleteAttributes
or PutAttributes operation (write) might not return updated item data.
async fn delete_attributes(
&self,
input: DeleteAttributesRequest,
) -> Result<(), RusotoError>;
/// The DeleteDomain
operation deletes a domain. Any items (and their attributes) in the domain are deleted as well. The DeleteDomain
operation might take 10 or more seconds to complete.
async fn delete_domain(
&self,
input: DeleteDomainRequest,
) -> Result<(), RusotoError>;
/// Returns information about the domain, including when the domain was created, the number of items and attributes in the domain, and the size of the attribute names and values.
async fn domain_metadata(
&self,
input: DomainMetadataRequest,
) -> Result>;
/// Returns all of the attributes associated with the specified item. Optionally, the attributes returned can be limited to one or more attributes by specifying an attribute name parameter.
If the item does not exist on the replica that was accessed for this operation, an empty set is returned. The system does not return an error as it cannot guarantee the item does not exist on other replicas.
async fn get_attributes(
&self,
input: GetAttributesRequest,
) -> Result>;
/// The ListDomains
operation lists all domains associated with the Access Key ID. It returns domain names up to the limit set by MaxNumberOfDomains. A NextToken is returned if there are more than MaxNumberOfDomains
domains. Calling ListDomains
successive times with the NextToken
provided by the operation returns up to MaxNumberOfDomains
more domain names with each successive operation call.
async fn list_domains(
&self,
input: ListDomainsRequest,
) -> Result>;
/// The PutAttributes operation creates or replaces attributes in an item. The client may specify new attributes using a combination of the Attribute.X.Name
and Attribute.X.Value
parameters. The client specifies the first attribute by the parameters Attribute.0.Name
and Attribute.0.Value
, the second attribute by the parameters Attribute.1.Name
and Attribute.1.Value
, and so on.
Attributes are uniquely identified in an item by their name/value combination. For example, a single item can have the attributes { "first_name", "first_value" }
and { "first_name", second_value" }
. However, it cannot have two attribute instances where both the Attribute.X.Name
and Attribute.X.Value
are the same.
Optionally, the requestor can supply the Replace
parameter for each individual attribute. Setting this value to true
causes the new attribute value to replace the existing attribute value(s). For example, if an item has the attributes { 'a', '1' }
, { 'b', '2'}
and { 'b', '3' }
and the requestor calls PutAttributes
using the attributes { 'b', '4' }
with the Replace
parameter set to true, the final attributes of the item are changed to { 'a', '1' }
and { 'b', '4' }
, which replaces the previous values of the 'b' attribute with the new value.
You cannot specify an empty string as an attribute name.
Because Amazon SimpleDB makes multiple copies of client data and uses an eventual consistency update model, an immediate GetAttributes or Select operation (read) immediately after a PutAttributes or DeleteAttributes operation (write) might not return the updated data.
The following limitations are enforced for this operation:
- 256 total attribute name-value pairs per item
- One billion attributes per domain
- 10 GB of total user data storage per domain
async fn put_attributes(
&self,
input: PutAttributesRequest,
) -> Result<(), RusotoError>;
/// The Select
operation returns a set of attributes for ItemNames
that match the select expression. Select
is similar to the standard SQL SELECT statement.
The total size of the response cannot exceed 1 MB in total size. Amazon SimpleDB automatically adjusts the number of items returned per page to enforce this limit. For example, if the client asks to retrieve 2500 items, but each individual item is 10 kB in size, the system returns 100 items and an appropriate NextToken
so the client can access the next page of results.
For information on how to construct select expressions, see Using Select to Create Amazon SimpleDB Queries in the Developer Guide.
async fn select(&self, input: SelectRequest) -> Result>;
}
/// A client for the Amazon SimpleDB API.
#[derive(Clone)]
pub struct SimpleDbClient {
client: Client,
region: region::Region,
}
impl SimpleDbClient {
/// Creates a client backed by the default tokio event loop.
///
/// The client will use the default credentials provider and tls client.
pub fn new(region: region::Region) -> SimpleDbClient {
SimpleDbClient {
client: Client::shared(),
region,
}
}
pub fn new_with(
request_dispatcher: D,
credentials_provider: P,
region: region::Region,
) -> SimpleDbClient
where
P: ProvideAwsCredentials + Send + Sync + 'static,
D: DispatchSignedRequest + Send + Sync + 'static,
{
SimpleDbClient {
client: Client::new_with(credentials_provider, request_dispatcher),
region,
}
}
pub fn new_with_client(client: Client, region: region::Region) -> SimpleDbClient {
SimpleDbClient { client, region }
}
}
#[async_trait]
impl SimpleDb for SimpleDbClient {
///
Performs multiple DeleteAttributes operations in a single call, which reduces round trips and latencies. This enables Amazon SimpleDB to optimize requests, which generally yields better throughput.
The following limitations are enforced for this operation:
- 1 MB request size
- 25 item limit per BatchDeleteAttributes operation
async fn batch_delete_attributes(
&self,
input: BatchDeleteAttributesRequest,
) -> Result<(), RusotoError> {
let mut request = SignedRequest::new("POST", "sdb", &self.region, "/");
let params = self.new_params("BatchDeleteAttributes");
let mut params = params;
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());
let response = self
.sign_and_dispatch(request, BatchDeleteAttributesError::from_response)
.await?;
std::mem::drop(response);
Ok(())
}
/// The BatchPutAttributes
operation creates or replaces attributes within one or more items. By using this operation, the client can perform multiple PutAttribute operation with a single call. This helps yield savings in round trips and latencies, enabling Amazon SimpleDB to optimize requests and generally produce better throughput.
The client may specify the item name with the Item.X.ItemName
parameter. The client may specify new attributes using a combination of the Item.X.Attribute.Y.Name
and Item.X.Attribute.Y.Value
parameters. The client may specify the first attribute for the first item using the parameters Item.0.Attribute.0.Name
and Item.0.Attribute.0.Value
, and for the second attribute for the first item by the parameters Item.0.Attribute.1.Name
and Item.0.Attribute.1.Value
, and so on.
Attributes are uniquely identified within an item by their name/value combination. For example, a single item can have the attributes { "first_name", "first_value" }
and { "first_name", "second_value" }
. However, it cannot have two attribute instances where both the Item.X.Attribute.Y.Name
and Item.X.Attribute.Y.Value
are the same.
Optionally, the requester can supply the Replace
parameter for each individual value. Setting this value to true
will cause the new attribute values to replace the existing attribute values. For example, if an item I
has the attributes { 'a', '1' }, { 'b', '2'}
and { 'b', '3' }
and the requester does a BatchPutAttributes of {'I', 'b', '4' }
with the Replace parameter set to true, the final attributes of the item will be { 'a', '1' }
and { 'b', '4' }
, replacing the previous values of the 'b' attribute with the new value.
This operation is vulnerable to exceeding the maximum URL size when making a REST request using the HTTP GET method. This operation does not support conditions using Expected.X.Name
, Expected.X.Value
, or Expected.X.Exists
. You can execute multiple BatchPutAttributes
operations and other operations in parallel. However, large numbers of concurrent BatchPutAttributes
calls can result in Service Unavailable (503) responses.
The following limitations are enforced for this operation:
- 256 attribute name-value pairs per item
- 1 MB request size
- 1 billion attributes per domain
- 10 GB of total user data storage per domain
- 25 item limit per
BatchPutAttributes
operation
async fn batch_put_attributes(
&self,
input: BatchPutAttributesRequest,
) -> Result<(), RusotoError> {
let mut request = SignedRequest::new("POST", "sdb", &self.region, "/");
let params = self.new_params("BatchPutAttributes");
let mut params = params;
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());
let response = self
.sign_and_dispatch(request, BatchPutAttributesError::from_response)
.await?;
std::mem::drop(response);
Ok(())
}
/// The CreateDomain
operation creates a new domain. The domain name should be unique among the domains associated with the Access Key ID provided in the request. The CreateDomain
operation may take 10 or more seconds to complete.
The client can create up to 100 domains per account.
If the client requires additional domains, go to http://aws.amazon.com/contact-us/simpledb-limit-request/.
async fn create_domain(
&self,
input: CreateDomainRequest,
) -> Result<(), RusotoError> {
let mut request = SignedRequest::new("POST", "sdb", &self.region, "/");
let params = self.new_params("CreateDomain");
let mut params = params;
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());
let response = self
.sign_and_dispatch(request, CreateDomainError::from_response)
.await?;
std::mem::drop(response);
Ok(())
}
/// Deletes one or more attributes associated with an item. If all attributes of the item are deleted, the item is deleted.
DeleteAttributes
is an idempotent operation; running it multiple times on the same item or attribute does not result in an error response.
Because Amazon SimpleDB makes multiple copies of item data and uses an eventual consistency update model, performing a GetAttributes or Select operation (read) immediately after a DeleteAttributes
or PutAttributes operation (write) might not return updated item data.
async fn delete_attributes(
&self,
input: DeleteAttributesRequest,
) -> Result<(), RusotoError> {
let mut request = SignedRequest::new("POST", "sdb", &self.region, "/");
let params = self.new_params("DeleteAttributes");
let mut params = params;
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());
let response = self
.sign_and_dispatch(request, DeleteAttributesError::from_response)
.await?;
std::mem::drop(response);
Ok(())
}
/// The DeleteDomain
operation deletes a domain. Any items (and their attributes) in the domain are deleted as well. The DeleteDomain
operation might take 10 or more seconds to complete.
async fn delete_domain(
&self,
input: DeleteDomainRequest,
) -> Result<(), RusotoError> {
let mut request = SignedRequest::new("POST", "sdb", &self.region, "/");
let params = self.new_params("DeleteDomain");
let mut params = params;
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());
let response = self
.sign_and_dispatch(request, DeleteDomainError::from_response)
.await?;
std::mem::drop(response);
Ok(())
}
/// Returns information about the domain, including when the domain was created, the number of items and attributes in the domain, and the size of the attribute names and values.
async fn domain_metadata(
&self,
input: DomainMetadataRequest,
) -> Result> {
let mut request = SignedRequest::new("POST", "sdb", &self.region, "/");
let params = self.new_params("DomainMetadata");
let mut params = params;
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());
let response = self
.sign_and_dispatch(request, DomainMetadataError::from_response)
.await?;
let mut response = response;
let result = xml_util::parse_response(&mut response, |actual_tag_name, stack| {
xml_util::start_element(actual_tag_name, stack)?;
let result =
DomainMetadataResultDeserializer::deserialize("DomainMetadataResult", stack)?;
skip_tree(stack);
xml_util::end_element(actual_tag_name, stack)?;
Ok(result)
})
.await?;
drop(response); // parse non-payload
Ok(result)
}
/// Returns all of the attributes associated with the specified item. Optionally, the attributes returned can be limited to one or more attributes by specifying an attribute name parameter.
If the item does not exist on the replica that was accessed for this operation, an empty set is returned. The system does not return an error as it cannot guarantee the item does not exist on other replicas.
async fn get_attributes(
&self,
input: GetAttributesRequest,
) -> Result> {
let mut request = SignedRequest::new("POST", "sdb", &self.region, "/");
let params = self.new_params("GetAttributes");
let mut params = params;
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());
let response = self
.sign_and_dispatch(request, GetAttributesError::from_response)
.await?;
let mut response = response;
let result = xml_util::parse_response(&mut response, |actual_tag_name, stack| {
xml_util::start_element(actual_tag_name, stack)?;
let result =
GetAttributesResultDeserializer::deserialize("GetAttributesResult", stack)?;
skip_tree(stack);
xml_util::end_element(actual_tag_name, stack)?;
Ok(result)
})
.await?;
drop(response); // parse non-payload
Ok(result)
}
/// The ListDomains
operation lists all domains associated with the Access Key ID. It returns domain names up to the limit set by MaxNumberOfDomains. A NextToken is returned if there are more than MaxNumberOfDomains
domains. Calling ListDomains
successive times with the NextToken
provided by the operation returns up to MaxNumberOfDomains
more domain names with each successive operation call.
async fn list_domains(
&self,
input: ListDomainsRequest,
) -> Result> {
let mut request = SignedRequest::new("POST", "sdb", &self.region, "/");
let params = self.new_params("ListDomains");
let mut params = params;
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());
let response = self
.sign_and_dispatch(request, ListDomainsError::from_response)
.await?;
let mut response = response;
let result = xml_util::parse_response(&mut response, |actual_tag_name, stack| {
xml_util::start_element(actual_tag_name, stack)?;
let result = ListDomainsResultDeserializer::deserialize("ListDomainsResult", stack)?;
skip_tree(stack);
xml_util::end_element(actual_tag_name, stack)?;
Ok(result)
})
.await?;
drop(response); // parse non-payload
Ok(result)
}
/// The PutAttributes operation creates or replaces attributes in an item. The client may specify new attributes using a combination of the Attribute.X.Name
and Attribute.X.Value
parameters. The client specifies the first attribute by the parameters Attribute.0.Name
and Attribute.0.Value
, the second attribute by the parameters Attribute.1.Name
and Attribute.1.Value
, and so on.
Attributes are uniquely identified in an item by their name/value combination. For example, a single item can have the attributes { "first_name", "first_value" }
and { "first_name", second_value" }
. However, it cannot have two attribute instances where both the Attribute.X.Name
and Attribute.X.Value
are the same.
Optionally, the requestor can supply the Replace
parameter for each individual attribute. Setting this value to true
causes the new attribute value to replace the existing attribute value(s). For example, if an item has the attributes { 'a', '1' }
, { 'b', '2'}
and { 'b', '3' }
and the requestor calls PutAttributes
using the attributes { 'b', '4' }
with the Replace
parameter set to true, the final attributes of the item are changed to { 'a', '1' }
and { 'b', '4' }
, which replaces the previous values of the 'b' attribute with the new value.
You cannot specify an empty string as an attribute name.
Because Amazon SimpleDB makes multiple copies of client data and uses an eventual consistency update model, an immediate GetAttributes or Select operation (read) immediately after a PutAttributes or DeleteAttributes operation (write) might not return the updated data.
The following limitations are enforced for this operation:
- 256 total attribute name-value pairs per item
- One billion attributes per domain
- 10 GB of total user data storage per domain
async fn put_attributes(
&self,
input: PutAttributesRequest,
) -> Result<(), RusotoError> {
let mut request = SignedRequest::new("POST", "sdb", &self.region, "/");
let params = self.new_params("PutAttributes");
let mut params = params;
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());
let response = self
.sign_and_dispatch(request, PutAttributesError::from_response)
.await?;
std::mem::drop(response);
Ok(())
}
/// The Select
operation returns a set of attributes for ItemNames
that match the select expression. Select
is similar to the standard SQL SELECT statement.
The total size of the response cannot exceed 1 MB in total size. Amazon SimpleDB automatically adjusts the number of items returned per page to enforce this limit. For example, if the client asks to retrieve 2500 items, but each individual item is 10 kB in size, the system returns 100 items and an appropriate NextToken
so the client can access the next page of results.
For information on how to construct select expressions, see Using Select to Create Amazon SimpleDB Queries in the Developer Guide.
async fn select(&self, input: SelectRequest) -> Result> {
let mut request = SignedRequest::new("POST", "sdb", &self.region, "/");
let params = self.new_params("Select");
let mut params = params;
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());
let response = self
.sign_and_dispatch(request, SelectError::from_response)
.await?;
let mut response = response;
let result = xml_util::parse_response(&mut response, |actual_tag_name, stack| {
xml_util::start_element(actual_tag_name, stack)?;
let result = SelectResultDeserializer::deserialize("SelectResult", stack)?;
skip_tree(stack);
xml_util::end_element(actual_tag_name, stack)?;
Ok(result)
})
.await?;
drop(response); // parse non-payload
Ok(result)
}
}