use std::error::Error;
use std::fmt;
#[allow(warnings)]
use futures::future;
use futures::Future;
use rusoto_core::credential::ProvideAwsCredentials;
use rusoto_core::region;
use rusoto_core::request::{BufferedHttpResponse, DispatchSignedRequest};
use rusoto_core::{Client, RusotoError, RusotoFuture};
use rusoto_core::param::{Params, ServiceParams};
use rusoto_core::proto::xml::error::*;
use rusoto_core::proto::xml::util::{
characters, deserialize_elements, end_element, find_start_element, peek_at_name, skip_tree,
start_element,
};
use rusoto_core::proto::xml::util::{Next, Peek, XmlParseError, XmlResponse};
use rusoto_core::signature::SignedRequest;
use serde_urlencoded;
use std::str::FromStr;
use xml::reader::ParserConfig;
use xml::EventReader;
#[derive(Default, Debug, Clone, PartialEq)]
pub struct Artifact {
pub description: Option<String>,
pub url: Option<String>,
}
struct ArtifactDeserializer;
impl ArtifactDeserializer {
#[allow(unused_variables)]
fn deserialize<T: Peek + Next>(
tag_name: &str,
stack: &mut T,
) -> Result<Artifact, XmlParseError> {
deserialize_elements::<_, Artifact, _>(tag_name, stack, |name, stack, obj| {
match name {
"Description" => {
obj.description =
Some(DescriptionDeserializer::deserialize("Description", stack)?);
}
"URL" => {
obj.url = Some(URLDeserializer::deserialize("URL", stack)?);
}
_ => skip_tree(stack),
}
Ok(())
})
}
}
struct ArtifactListDeserializer;
impl ArtifactListDeserializer {
#[allow(unused_variables)]
fn deserialize<T: Peek + Next>(
tag_name: &str,
stack: &mut T,
) -> Result<Vec<Artifact>, XmlParseError> {
deserialize_elements::<_, Vec<_>, _>(tag_name, stack, |name, stack, obj| {
if name == "member" {
obj.push(ArtifactDeserializer::deserialize("member", stack)?);
} else {
skip_tree(stack);
}
Ok(())
})
}
}
#[derive(Default, Debug, Clone, PartialEq)]
pub struct CancelJobInput {
pub api_version: Option<String>,
pub job_id: String,
}
struct CancelJobInputSerializer;
impl CancelJobInputSerializer {
fn serialize(params: &mut Params, name: &str, obj: &CancelJobInput) {
let mut prefix = name.to_string();
if prefix != "" {
prefix.push_str(".");
}
if let Some(ref field_value) = obj.api_version {
params.put(&format!("{}{}", prefix, "APIVersion"), &field_value);
}
params.put(&format!("{}{}", prefix, "JobId"), &obj.job_id);
}
}
#[derive(Default, Debug, Clone, PartialEq)]
pub struct CancelJobOutput {
pub success: Option<bool>,
}
struct CancelJobOutputDeserializer;
impl CancelJobOutputDeserializer {
#[allow(unused_variables)]
fn deserialize<T: Peek + Next>(
tag_name: &str,
stack: &mut T,
) -> Result<CancelJobOutput, XmlParseError> {
deserialize_elements::<_, CancelJobOutput, _>(tag_name, stack, |name, stack, obj| {
match name {
"Success" => {
obj.success = Some(SuccessDeserializer::deserialize("Success", stack)?);
}
_ => skip_tree(stack),
}
Ok(())
})
}
}
struct CarrierDeserializer;
impl CarrierDeserializer {
#[allow(unused_variables)]
fn deserialize<T: Peek + Next>(tag_name: &str, stack: &mut T) -> Result<String, XmlParseError> {
start_element(tag_name, stack)?;
let obj = characters(stack)?;
end_element(tag_name, stack)?;
Ok(obj)
}
}
#[derive(Default, Debug, Clone, PartialEq)]
pub struct CreateJobInput {
pub api_version: Option<String>,
pub job_type: String,
pub manifest: String,
pub manifest_addendum: Option<String>,
pub validate_only: bool,
}
struct CreateJobInputSerializer;
impl CreateJobInputSerializer {
fn serialize(params: &mut Params, name: &str, obj: &CreateJobInput) {
let mut prefix = name.to_string();
if prefix != "" {
prefix.push_str(".");
}
if let Some(ref field_value) = obj.api_version {
params.put(&format!("{}{}", prefix, "APIVersion"), &field_value);
}
params.put(&format!("{}{}", prefix, "JobType"), &obj.job_type);
params.put(&format!("{}{}", prefix, "Manifest"), &obj.manifest);
if let Some(ref field_value) = obj.manifest_addendum {
params.put(&format!("{}{}", prefix, "ManifestAddendum"), &field_value);
}
params.put(&format!("{}{}", prefix, "ValidateOnly"), &obj.validate_only);
}
}
#[derive(Default, Debug, Clone, PartialEq)]
pub struct CreateJobOutput {
pub artifact_list: Option<Vec<Artifact>>,
pub job_id: Option<String>,
pub job_type: Option<String>,
pub signature: Option<String>,
pub signature_file_contents: Option<String>,
pub warning_message: Option<String>,
}
struct CreateJobOutputDeserializer;
impl CreateJobOutputDeserializer {
#[allow(unused_variables)]
fn deserialize<T: Peek + Next>(
tag_name: &str,
stack: &mut T,
) -> Result<CreateJobOutput, XmlParseError> {
deserialize_elements::<_, CreateJobOutput, _>(tag_name, stack, |name, stack, obj| {
match name {
"ArtifactList" => {
obj.artifact_list.get_or_insert(vec![]).extend(
ArtifactListDeserializer::deserialize("ArtifactList", stack)?,
);
}
"JobId" => {
obj.job_id = Some(JobIdDeserializer::deserialize("JobId", stack)?);
}
"JobType" => {
obj.job_type = Some(JobTypeDeserializer::deserialize("JobType", stack)?);
}
"Signature" => {
obj.signature = Some(SignatureDeserializer::deserialize("Signature", stack)?);
}
"SignatureFileContents" => {
obj.signature_file_contents =
Some(SignatureFileContentsDeserializer::deserialize(
"SignatureFileContents",
stack,
)?);
}
"WarningMessage" => {
obj.warning_message = Some(WarningMessageDeserializer::deserialize(
"WarningMessage",
stack,
)?);
}
_ => skip_tree(stack),
}
Ok(())
})
}
}
struct CreationDateDeserializer;
impl CreationDateDeserializer {
#[allow(unused_variables)]
fn deserialize<T: Peek + Next>(tag_name: &str, stack: &mut T) -> Result<String, XmlParseError> {
start_element(tag_name, stack)?;
let obj = characters(stack)?;
end_element(tag_name, stack)?;
Ok(obj)
}
}
struct CurrentManifestDeserializer;
impl CurrentManifestDeserializer {
#[allow(unused_variables)]
fn deserialize<T: Peek + Next>(tag_name: &str, stack: &mut T) -> Result<String, XmlParseError> {
start_element(tag_name, stack)?;
let obj = characters(stack)?;
end_element(tag_name, stack)?;
Ok(obj)
}
}
struct DescriptionDeserializer;
impl DescriptionDeserializer {
#[allow(unused_variables)]
fn deserialize<T: Peek + Next>(tag_name: &str, stack: &mut T) -> Result<String, XmlParseError> {
start_element(tag_name, stack)?;
let obj = characters(stack)?;
end_element(tag_name, stack)?;
Ok(obj)
}
}
struct ErrorCountDeserializer;
impl ErrorCountDeserializer {
#[allow(unused_variables)]
fn deserialize<T: Peek + Next>(tag_name: &str, stack: &mut T) -> Result<i64, XmlParseError> {
start_element(tag_name, stack)?;
let obj = i64::from_str(characters(stack)?.as_ref()).unwrap();
end_element(tag_name, stack)?;
Ok(obj)
}
}
struct GenericStringDeserializer;
impl GenericStringDeserializer {
#[allow(unused_variables)]
fn deserialize<T: Peek + Next>(tag_name: &str, stack: &mut T) -> Result<String, XmlParseError> {
start_element(tag_name, stack)?;
let obj = characters(stack)?;
end_element(tag_name, stack)?;
Ok(obj)
}
}
#[derive(Default, Debug, Clone, PartialEq)]
pub struct GetShippingLabelInput {
pub api_version: Option<String>,
pub city: Option<String>,
pub company: Option<String>,
pub country: Option<String>,
pub job_ids: Vec<String>,
pub name: Option<String>,
pub phone_number: Option<String>,
pub postal_code: Option<String>,
pub state_or_province: Option<String>,
pub street_1: Option<String>,
pub street_2: Option<String>,
pub street_3: Option<String>,
}
struct GetShippingLabelInputSerializer;
impl GetShippingLabelInputSerializer {
fn serialize(params: &mut Params, name: &str, obj: &GetShippingLabelInput) {
let mut prefix = name.to_string();
if prefix != "" {
prefix.push_str(".");
}
if let Some(ref field_value) = obj.api_version {
params.put(&format!("{}{}", prefix, "APIVersion"), &field_value);
}
if let Some(ref field_value) = obj.city {
params.put(&format!("{}{}", prefix, "city"), &field_value);
}
if let Some(ref field_value) = obj.company {
params.put(&format!("{}{}", prefix, "company"), &field_value);
}
if let Some(ref field_value) = obj.country {
params.put(&format!("{}{}", prefix, "country"), &field_value);
}
JobIdListSerializer::serialize(params, &format!("{}{}", prefix, "jobIds"), &obj.job_ids);
if let Some(ref field_value) = obj.name {
params.put(&format!("{}{}", prefix, "name"), &field_value);
}
if let Some(ref field_value) = obj.phone_number {
params.put(&format!("{}{}", prefix, "phoneNumber"), &field_value);
}
if let Some(ref field_value) = obj.postal_code {
params.put(&format!("{}{}", prefix, "postalCode"), &field_value);
}
if let Some(ref field_value) = obj.state_or_province {
params.put(&format!("{}{}", prefix, "stateOrProvince"), &field_value);
}
if let Some(ref field_value) = obj.street_1 {
params.put(&format!("{}{}", prefix, "street1"), &field_value);
}
if let Some(ref field_value) = obj.street_2 {
params.put(&format!("{}{}", prefix, "street2"), &field_value);
}
if let Some(ref field_value) = obj.street_3 {
params.put(&format!("{}{}", prefix, "street3"), &field_value);
}
}
}
#[derive(Default, Debug, Clone, PartialEq)]
pub struct GetShippingLabelOutput {
pub shipping_label_url: Option<String>,
pub warning: Option<String>,
}
struct GetShippingLabelOutputDeserializer;
impl GetShippingLabelOutputDeserializer {
#[allow(unused_variables)]
fn deserialize<T: Peek + Next>(
tag_name: &str,
stack: &mut T,
) -> Result<GetShippingLabelOutput, XmlParseError> {
deserialize_elements::<_, GetShippingLabelOutput, _>(tag_name, stack, |name, stack, obj| {
match name {
"ShippingLabelURL" => {
obj.shipping_label_url = Some(GenericStringDeserializer::deserialize(
"ShippingLabelURL",
stack,
)?);
}
"Warning" => {
obj.warning = Some(GenericStringDeserializer::deserialize("Warning", stack)?);
}
_ => skip_tree(stack),
}
Ok(())
})
}
}
#[derive(Default, Debug, Clone, PartialEq)]
pub struct GetStatusInput {
pub api_version: Option<String>,
pub job_id: String,
}
struct GetStatusInputSerializer;
impl GetStatusInputSerializer {
fn serialize(params: &mut Params, name: &str, obj: &GetStatusInput) {
let mut prefix = name.to_string();
if prefix != "" {
prefix.push_str(".");
}
if let Some(ref field_value) = obj.api_version {
params.put(&format!("{}{}", prefix, "APIVersion"), &field_value);
}
params.put(&format!("{}{}", prefix, "JobId"), &obj.job_id);
}
}
#[derive(Default, Debug, Clone, PartialEq)]
pub struct GetStatusOutput {
pub artifact_list: Option<Vec<Artifact>>,
pub carrier: Option<String>,
pub creation_date: Option<String>,
pub current_manifest: Option<String>,
pub error_count: Option<i64>,
pub job_id: Option<String>,
pub job_type: Option<String>,
pub location_code: Option<String>,
pub location_message: Option<String>,
pub log_bucket: Option<String>,
pub log_key: Option<String>,
pub progress_code: Option<String>,
pub progress_message: Option<String>,
pub signature: Option<String>,
pub signature_file_contents: Option<String>,
pub tracking_number: Option<String>,
}
struct GetStatusOutputDeserializer;
impl GetStatusOutputDeserializer {
#[allow(unused_variables)]
fn deserialize<T: Peek + Next>(
tag_name: &str,
stack: &mut T,
) -> Result<GetStatusOutput, XmlParseError> {
deserialize_elements::<_, GetStatusOutput, _>(tag_name, stack, |name, stack, obj| {
match name {
"ArtifactList" => {
obj.artifact_list.get_or_insert(vec![]).extend(
ArtifactListDeserializer::deserialize("ArtifactList", stack)?,
);
}
"Carrier" => {
obj.carrier = Some(CarrierDeserializer::deserialize("Carrier", stack)?);
}
"CreationDate" => {
obj.creation_date = Some(CreationDateDeserializer::deserialize(
"CreationDate",
stack,
)?);
}
"CurrentManifest" => {
obj.current_manifest = Some(CurrentManifestDeserializer::deserialize(
"CurrentManifest",
stack,
)?);
}
"ErrorCount" => {
obj.error_count =
Some(ErrorCountDeserializer::deserialize("ErrorCount", stack)?);
}
"JobId" => {
obj.job_id = Some(JobIdDeserializer::deserialize("JobId", stack)?);
}
"JobType" => {
obj.job_type = Some(JobTypeDeserializer::deserialize("JobType", stack)?);
}
"LocationCode" => {
obj.location_code = Some(LocationCodeDeserializer::deserialize(
"LocationCode",
stack,
)?);
}
"LocationMessage" => {
obj.location_message = Some(LocationMessageDeserializer::deserialize(
"LocationMessage",
stack,
)?);
}
"LogBucket" => {
obj.log_bucket = Some(LogBucketDeserializer::deserialize("LogBucket", stack)?);
}
"LogKey" => {
obj.log_key = Some(LogKeyDeserializer::deserialize("LogKey", stack)?);
}
"ProgressCode" => {
obj.progress_code = Some(ProgressCodeDeserializer::deserialize(
"ProgressCode",
stack,
)?);
}
"ProgressMessage" => {
obj.progress_message = Some(ProgressMessageDeserializer::deserialize(
"ProgressMessage",
stack,
)?);
}
"Signature" => {
obj.signature = Some(SignatureDeserializer::deserialize("Signature", stack)?);
}
"SignatureFileContents" => {
obj.signature_file_contents = Some(SignatureDeserializer::deserialize(
"SignatureFileContents",
stack,
)?);
}
"TrackingNumber" => {
obj.tracking_number = Some(TrackingNumberDeserializer::deserialize(
"TrackingNumber",
stack,
)?);
}
_ => skip_tree(stack),
}
Ok(())
})
}
}
struct IsCanceledDeserializer;
impl IsCanceledDeserializer {
#[allow(unused_variables)]
fn deserialize<T: Peek + Next>(tag_name: &str, stack: &mut T) -> Result<bool, XmlParseError> {
start_element(tag_name, stack)?;
let obj = bool::from_str(characters(stack)?.as_ref()).unwrap();
end_element(tag_name, stack)?;
Ok(obj)
}
}
struct IsTruncatedDeserializer;
impl IsTruncatedDeserializer {
#[allow(unused_variables)]
fn deserialize<T: Peek + Next>(tag_name: &str, stack: &mut T) -> Result<bool, XmlParseError> {
start_element(tag_name, stack)?;
let obj = bool::from_str(characters(stack)?.as_ref()).unwrap();
end_element(tag_name, stack)?;
Ok(obj)
}
}
#[derive(Default, Debug, Clone, PartialEq)]
pub struct Job {
pub creation_date: Option<String>,
pub is_canceled: Option<bool>,
pub job_id: Option<String>,
pub job_type: Option<String>,
}
struct JobDeserializer;
impl JobDeserializer {
#[allow(unused_variables)]
fn deserialize<T: Peek + Next>(tag_name: &str, stack: &mut T) -> Result<Job, XmlParseError> {
deserialize_elements::<_, Job, _>(tag_name, stack, |name, stack, obj| {
match name {
"CreationDate" => {
obj.creation_date = Some(CreationDateDeserializer::deserialize(
"CreationDate",
stack,
)?);
}
"IsCanceled" => {
obj.is_canceled =
Some(IsCanceledDeserializer::deserialize("IsCanceled", stack)?);
}
"JobId" => {
obj.job_id = Some(JobIdDeserializer::deserialize("JobId", stack)?);
}
"JobType" => {
obj.job_type = Some(JobTypeDeserializer::deserialize("JobType", stack)?);
}
_ => skip_tree(stack),
}
Ok(())
})
}
}
struct JobIdDeserializer;
impl JobIdDeserializer {
#[allow(unused_variables)]
fn deserialize<T: Peek + Next>(tag_name: &str, stack: &mut T) -> Result<String, XmlParseError> {
start_element(tag_name, stack)?;
let obj = characters(stack)?;
end_element(tag_name, stack)?;
Ok(obj)
}
}
struct JobIdListSerializer;
impl JobIdListSerializer {
fn serialize(params: &mut Params, name: &str, obj: &Vec<String>) {
for (index, obj) in obj.iter().enumerate() {
let key = format!("{}.member.{}", name, index + 1);
params.put(&key, &obj);
}
}
}
struct JobTypeDeserializer;
impl JobTypeDeserializer {
#[allow(unused_variables)]
fn deserialize<T: Peek + Next>(tag_name: &str, stack: &mut T) -> Result<String, XmlParseError> {
start_element(tag_name, stack)?;
let obj = characters(stack)?;
end_element(tag_name, stack)?;
Ok(obj)
}
}
struct JobsListDeserializer;
impl JobsListDeserializer {
#[allow(unused_variables)]
fn deserialize<T: Peek + Next>(
tag_name: &str,
stack: &mut T,
) -> Result<Vec<Job>, XmlParseError> {
deserialize_elements::<_, Vec<_>, _>(tag_name, stack, |name, stack, obj| {
if name == "member" {
obj.push(JobDeserializer::deserialize("member", stack)?);
} else {
skip_tree(stack);
}
Ok(())
})
}
}
#[derive(Default, Debug, Clone, PartialEq)]
pub struct ListJobsInput {
pub api_version: Option<String>,
pub marker: Option<String>,
pub max_jobs: Option<i64>,
}
struct ListJobsInputSerializer;
impl ListJobsInputSerializer {
fn serialize(params: &mut Params, name: &str, obj: &ListJobsInput) {
let mut prefix = name.to_string();
if prefix != "" {
prefix.push_str(".");
}
if let Some(ref field_value) = obj.api_version {
params.put(&format!("{}{}", prefix, "APIVersion"), &field_value);
}
if let Some(ref field_value) = obj.marker {
params.put(&format!("{}{}", prefix, "Marker"), &field_value);
}
if let Some(ref field_value) = obj.max_jobs {
params.put(&format!("{}{}", prefix, "MaxJobs"), &field_value);
}
}
}
#[derive(Default, Debug, Clone, PartialEq)]
pub struct ListJobsOutput {
pub is_truncated: Option<bool>,
pub jobs: Option<Vec<Job>>,
}
struct ListJobsOutputDeserializer;
impl ListJobsOutputDeserializer {
#[allow(unused_variables)]
fn deserialize<T: Peek + Next>(
tag_name: &str,
stack: &mut T,
) -> Result<ListJobsOutput, XmlParseError> {
deserialize_elements::<_, ListJobsOutput, _>(tag_name, stack, |name, stack, obj| {
match name {
"IsTruncated" => {
obj.is_truncated =
Some(IsTruncatedDeserializer::deserialize("IsTruncated", stack)?);
}
"Jobs" => {
obj.jobs
.get_or_insert(vec![])
.extend(JobsListDeserializer::deserialize("Jobs", stack)?);
}
_ => skip_tree(stack),
}
Ok(())
})
}
}
struct LocationCodeDeserializer;
impl LocationCodeDeserializer {
#[allow(unused_variables)]
fn deserialize<T: Peek + Next>(tag_name: &str, stack: &mut T) -> Result<String, XmlParseError> {
start_element(tag_name, stack)?;
let obj = characters(stack)?;
end_element(tag_name, stack)?;
Ok(obj)
}
}
struct LocationMessageDeserializer;
impl LocationMessageDeserializer {
#[allow(unused_variables)]
fn deserialize<T: Peek + Next>(tag_name: &str, stack: &mut T) -> Result<String, XmlParseError> {
start_element(tag_name, stack)?;
let obj = characters(stack)?;
end_element(tag_name, stack)?;
Ok(obj)
}
}
struct LogBucketDeserializer;
impl LogBucketDeserializer {
#[allow(unused_variables)]
fn deserialize<T: Peek + Next>(tag_name: &str, stack: &mut T) -> Result<String, XmlParseError> {
start_element(tag_name, stack)?;
let obj = characters(stack)?;
end_element(tag_name, stack)?;
Ok(obj)
}
}
struct LogKeyDeserializer;
impl LogKeyDeserializer {
#[allow(unused_variables)]
fn deserialize<T: Peek + Next>(tag_name: &str, stack: &mut T) -> Result<String, XmlParseError> {
start_element(tag_name, stack)?;
let obj = characters(stack)?;
end_element(tag_name, stack)?;
Ok(obj)
}
}
struct ProgressCodeDeserializer;
impl ProgressCodeDeserializer {
#[allow(unused_variables)]
fn deserialize<T: Peek + Next>(tag_name: &str, stack: &mut T) -> Result<String, XmlParseError> {
start_element(tag_name, stack)?;
let obj = characters(stack)?;
end_element(tag_name, stack)?;
Ok(obj)
}
}
struct ProgressMessageDeserializer;
impl ProgressMessageDeserializer {
#[allow(unused_variables)]
fn deserialize<T: Peek + Next>(tag_name: &str, stack: &mut T) -> Result<String, XmlParseError> {
start_element(tag_name, stack)?;
let obj = characters(stack)?;
end_element(tag_name, stack)?;
Ok(obj)
}
}
struct SignatureDeserializer;
impl SignatureDeserializer {
#[allow(unused_variables)]
fn deserialize<T: Peek + Next>(tag_name: &str, stack: &mut T) -> Result<String, XmlParseError> {
start_element(tag_name, stack)?;
let obj = characters(stack)?;
end_element(tag_name, stack)?;
Ok(obj)
}
}
struct SignatureFileContentsDeserializer;
impl SignatureFileContentsDeserializer {
#[allow(unused_variables)]
fn deserialize<T: Peek + Next>(tag_name: &str, stack: &mut T) -> Result<String, XmlParseError> {
start_element(tag_name, stack)?;
let obj = characters(stack)?;
end_element(tag_name, stack)?;
Ok(obj)
}
}
struct SuccessDeserializer;
impl SuccessDeserializer {
#[allow(unused_variables)]
fn deserialize<T: Peek + Next>(tag_name: &str, stack: &mut T) -> Result<bool, XmlParseError> {
start_element(tag_name, stack)?;
let obj = bool::from_str(characters(stack)?.as_ref()).unwrap();
end_element(tag_name, stack)?;
Ok(obj)
}
}
struct TrackingNumberDeserializer;
impl TrackingNumberDeserializer {
#[allow(unused_variables)]
fn deserialize<T: Peek + Next>(tag_name: &str, stack: &mut T) -> Result<String, XmlParseError> {
start_element(tag_name, stack)?;
let obj = characters(stack)?;
end_element(tag_name, stack)?;
Ok(obj)
}
}
struct URLDeserializer;
impl URLDeserializer {
#[allow(unused_variables)]
fn deserialize<T: Peek + Next>(tag_name: &str, stack: &mut T) -> Result<String, XmlParseError> {
start_element(tag_name, stack)?;
let obj = characters(stack)?;
end_element(tag_name, stack)?;
Ok(obj)
}
}
#[derive(Default, Debug, Clone, PartialEq)]
pub struct UpdateJobInput {
pub api_version: Option<String>,
pub job_id: String,
pub job_type: String,
pub manifest: String,
pub validate_only: bool,
}
struct UpdateJobInputSerializer;
impl UpdateJobInputSerializer {
fn serialize(params: &mut Params, name: &str, obj: &UpdateJobInput) {
let mut prefix = name.to_string();
if prefix != "" {
prefix.push_str(".");
}
if let Some(ref field_value) = obj.api_version {
params.put(&format!("{}{}", prefix, "APIVersion"), &field_value);
}
params.put(&format!("{}{}", prefix, "JobId"), &obj.job_id);
params.put(&format!("{}{}", prefix, "JobType"), &obj.job_type);
params.put(&format!("{}{}", prefix, "Manifest"), &obj.manifest);
params.put(&format!("{}{}", prefix, "ValidateOnly"), &obj.validate_only);
}
}
#[derive(Default, Debug, Clone, PartialEq)]
pub struct UpdateJobOutput {
pub artifact_list: Option<Vec<Artifact>>,
pub success: Option<bool>,
pub warning_message: Option<String>,
}
struct UpdateJobOutputDeserializer;
impl UpdateJobOutputDeserializer {
#[allow(unused_variables)]
fn deserialize<T: Peek + Next>(
tag_name: &str,
stack: &mut T,
) -> Result<UpdateJobOutput, XmlParseError> {
deserialize_elements::<_, UpdateJobOutput, _>(tag_name, stack, |name, stack, obj| {
match name {
"ArtifactList" => {
obj.artifact_list.get_or_insert(vec![]).extend(
ArtifactListDeserializer::deserialize("ArtifactList", stack)?,
);
}
"Success" => {
obj.success = Some(SuccessDeserializer::deserialize("Success", stack)?);
}
"WarningMessage" => {
obj.warning_message = Some(WarningMessageDeserializer::deserialize(
"WarningMessage",
stack,
)?);
}
_ => skip_tree(stack),
}
Ok(())
})
}
}
struct WarningMessageDeserializer;
impl WarningMessageDeserializer {
#[allow(unused_variables)]
fn deserialize<T: Peek + Next>(tag_name: &str, stack: &mut T) -> Result<String, XmlParseError> {
start_element(tag_name, stack)?;
let obj = characters(stack)?;
end_element(tag_name, stack)?;
Ok(obj)
}
}
#[derive(Debug, PartialEq)]
pub enum CancelJobError {
CanceledJobId(String),
ExpiredJobId(String),
InvalidAccessKeyId(String),
InvalidJobId(String),
InvalidVersion(String),
UnableToCancelJobId(String),
}
impl CancelJobError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<CancelJobError> {
{
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[..] {
"CanceledJobIdException" => {
return RusotoError::Service(CancelJobError::CanceledJobId(
parsed_error.message,
))
}
"ExpiredJobIdException" => {
return RusotoError::Service(CancelJobError::ExpiredJobId(
parsed_error.message,
))
}
"InvalidAccessKeyIdException" => {
return RusotoError::Service(CancelJobError::InvalidAccessKeyId(
parsed_error.message,
))
}
"InvalidJobIdException" => {
return RusotoError::Service(CancelJobError::InvalidJobId(
parsed_error.message,
))
}
"InvalidVersionException" => {
return RusotoError::Service(CancelJobError::InvalidVersion(
parsed_error.message,
))
}
"UnableToCancelJobIdException" => {
return RusotoError::Service(CancelJobError::UnableToCancelJobId(
parsed_error.message,
))
}
_ => {}
}
}
}
RusotoError::Unknown(res)
}
fn deserialize<T>(stack: &mut T) -> Result<XmlError, XmlParseError>
where
T: Peek + Next,
{
start_element("ErrorResponse", stack)?;
XmlErrorDeserializer::deserialize("Error", stack)
}
}
impl fmt::Display for CancelJobError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for CancelJobError {
fn description(&self) -> &str {
match *self {
CancelJobError::CanceledJobId(ref cause) => cause,
CancelJobError::ExpiredJobId(ref cause) => cause,
CancelJobError::InvalidAccessKeyId(ref cause) => cause,
CancelJobError::InvalidJobId(ref cause) => cause,
CancelJobError::InvalidVersion(ref cause) => cause,
CancelJobError::UnableToCancelJobId(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum CreateJobError {
BucketPermission(String),
CreateJobQuotaExceeded(String),
InvalidAccessKeyId(String),
InvalidAddress(String),
InvalidCustoms(String),
InvalidFileSystem(String),
InvalidJobId(String),
InvalidManifestField(String),
InvalidParameter(String),
InvalidVersion(String),
MalformedManifest(String),
MissingCustoms(String),
MissingManifestField(String),
MissingParameter(String),
MultipleRegions(String),
NoSuchBucket(String),
}
impl CreateJobError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<CreateJobError> {
{
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[..] {
"BucketPermissionException" => {
return RusotoError::Service(CreateJobError::BucketPermission(
parsed_error.message,
))
}
"CreateJobQuotaExceededException" => {
return RusotoError::Service(CreateJobError::CreateJobQuotaExceeded(
parsed_error.message,
))
}
"InvalidAccessKeyIdException" => {
return RusotoError::Service(CreateJobError::InvalidAccessKeyId(
parsed_error.message,
))
}
"InvalidAddressException" => {
return RusotoError::Service(CreateJobError::InvalidAddress(
parsed_error.message,
))
}
"InvalidCustomsException" => {
return RusotoError::Service(CreateJobError::InvalidCustoms(
parsed_error.message,
))
}
"InvalidFileSystemException" => {
return RusotoError::Service(CreateJobError::InvalidFileSystem(
parsed_error.message,
))
}
"InvalidJobIdException" => {
return RusotoError::Service(CreateJobError::InvalidJobId(
parsed_error.message,
))
}
"InvalidManifestFieldException" => {
return RusotoError::Service(CreateJobError::InvalidManifestField(
parsed_error.message,
))
}
"InvalidParameterException" => {
return RusotoError::Service(CreateJobError::InvalidParameter(
parsed_error.message,
))
}
"InvalidVersionException" => {
return RusotoError::Service(CreateJobError::InvalidVersion(
parsed_error.message,
))
}
"MalformedManifestException" => {
return RusotoError::Service(CreateJobError::MalformedManifest(
parsed_error.message,
))
}
"MissingCustomsException" => {
return RusotoError::Service(CreateJobError::MissingCustoms(
parsed_error.message,
))
}
"MissingManifestFieldException" => {
return RusotoError::Service(CreateJobError::MissingManifestField(
parsed_error.message,
))
}
"MissingParameterException" => {
return RusotoError::Service(CreateJobError::MissingParameter(
parsed_error.message,
))
}
"MultipleRegionsException" => {
return RusotoError::Service(CreateJobError::MultipleRegions(
parsed_error.message,
))
}
"NoSuchBucketException" => {
return RusotoError::Service(CreateJobError::NoSuchBucket(
parsed_error.message,
))
}
_ => {}
}
}
}
RusotoError::Unknown(res)
}
fn deserialize<T>(stack: &mut T) -> Result<XmlError, XmlParseError>
where
T: Peek + Next,
{
start_element("ErrorResponse", stack)?;
XmlErrorDeserializer::deserialize("Error", stack)
}
}
impl fmt::Display for CreateJobError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for CreateJobError {
fn description(&self) -> &str {
match *self {
CreateJobError::BucketPermission(ref cause) => cause,
CreateJobError::CreateJobQuotaExceeded(ref cause) => cause,
CreateJobError::InvalidAccessKeyId(ref cause) => cause,
CreateJobError::InvalidAddress(ref cause) => cause,
CreateJobError::InvalidCustoms(ref cause) => cause,
CreateJobError::InvalidFileSystem(ref cause) => cause,
CreateJobError::InvalidJobId(ref cause) => cause,
CreateJobError::InvalidManifestField(ref cause) => cause,
CreateJobError::InvalidParameter(ref cause) => cause,
CreateJobError::InvalidVersion(ref cause) => cause,
CreateJobError::MalformedManifest(ref cause) => cause,
CreateJobError::MissingCustoms(ref cause) => cause,
CreateJobError::MissingManifestField(ref cause) => cause,
CreateJobError::MissingParameter(ref cause) => cause,
CreateJobError::MultipleRegions(ref cause) => cause,
CreateJobError::NoSuchBucket(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum GetShippingLabelError {
CanceledJobId(String),
ExpiredJobId(String),
InvalidAccessKeyId(String),
InvalidAddress(String),
InvalidJobId(String),
InvalidParameter(String),
InvalidVersion(String),
}
impl GetShippingLabelError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<GetShippingLabelError> {
{
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[..] {
"CanceledJobIdException" => {
return RusotoError::Service(GetShippingLabelError::CanceledJobId(
parsed_error.message,
))
}
"ExpiredJobIdException" => {
return RusotoError::Service(GetShippingLabelError::ExpiredJobId(
parsed_error.message,
))
}
"InvalidAccessKeyIdException" => {
return RusotoError::Service(GetShippingLabelError::InvalidAccessKeyId(
parsed_error.message,
))
}
"InvalidAddressException" => {
return RusotoError::Service(GetShippingLabelError::InvalidAddress(
parsed_error.message,
))
}
"InvalidJobIdException" => {
return RusotoError::Service(GetShippingLabelError::InvalidJobId(
parsed_error.message,
))
}
"InvalidParameterException" => {
return RusotoError::Service(GetShippingLabelError::InvalidParameter(
parsed_error.message,
))
}
"InvalidVersionException" => {
return RusotoError::Service(GetShippingLabelError::InvalidVersion(
parsed_error.message,
))
}
_ => {}
}
}
}
RusotoError::Unknown(res)
}
fn deserialize<T>(stack: &mut T) -> Result<XmlError, XmlParseError>
where
T: Peek + Next,
{
start_element("ErrorResponse", stack)?;
XmlErrorDeserializer::deserialize("Error", stack)
}
}
impl fmt::Display for GetShippingLabelError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for GetShippingLabelError {
fn description(&self) -> &str {
match *self {
GetShippingLabelError::CanceledJobId(ref cause) => cause,
GetShippingLabelError::ExpiredJobId(ref cause) => cause,
GetShippingLabelError::InvalidAccessKeyId(ref cause) => cause,
GetShippingLabelError::InvalidAddress(ref cause) => cause,
GetShippingLabelError::InvalidJobId(ref cause) => cause,
GetShippingLabelError::InvalidParameter(ref cause) => cause,
GetShippingLabelError::InvalidVersion(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum GetStatusError {
CanceledJobId(String),
ExpiredJobId(String),
InvalidAccessKeyId(String),
InvalidJobId(String),
InvalidVersion(String),
}
impl GetStatusError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<GetStatusError> {
{
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[..] {
"CanceledJobIdException" => {
return RusotoError::Service(GetStatusError::CanceledJobId(
parsed_error.message,
))
}
"ExpiredJobIdException" => {
return RusotoError::Service(GetStatusError::ExpiredJobId(
parsed_error.message,
))
}
"InvalidAccessKeyIdException" => {
return RusotoError::Service(GetStatusError::InvalidAccessKeyId(
parsed_error.message,
))
}
"InvalidJobIdException" => {
return RusotoError::Service(GetStatusError::InvalidJobId(
parsed_error.message,
))
}
"InvalidVersionException" => {
return RusotoError::Service(GetStatusError::InvalidVersion(
parsed_error.message,
))
}
_ => {}
}
}
}
RusotoError::Unknown(res)
}
fn deserialize<T>(stack: &mut T) -> Result<XmlError, XmlParseError>
where
T: Peek + Next,
{
start_element("ErrorResponse", stack)?;
XmlErrorDeserializer::deserialize("Error", stack)
}
}
impl fmt::Display for GetStatusError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for GetStatusError {
fn description(&self) -> &str {
match *self {
GetStatusError::CanceledJobId(ref cause) => cause,
GetStatusError::ExpiredJobId(ref cause) => cause,
GetStatusError::InvalidAccessKeyId(ref cause) => cause,
GetStatusError::InvalidJobId(ref cause) => cause,
GetStatusError::InvalidVersion(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum ListJobsError {
InvalidAccessKeyId(String),
InvalidParameter(String),
InvalidVersion(String),
}
impl ListJobsError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<ListJobsError> {
{
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[..] {
"InvalidAccessKeyIdException" => {
return RusotoError::Service(ListJobsError::InvalidAccessKeyId(
parsed_error.message,
))
}
"InvalidParameterException" => {
return RusotoError::Service(ListJobsError::InvalidParameter(
parsed_error.message,
))
}
"InvalidVersionException" => {
return RusotoError::Service(ListJobsError::InvalidVersion(
parsed_error.message,
))
}
_ => {}
}
}
}
RusotoError::Unknown(res)
}
fn deserialize<T>(stack: &mut T) -> Result<XmlError, XmlParseError>
where
T: Peek + Next,
{
start_element("ErrorResponse", stack)?;
XmlErrorDeserializer::deserialize("Error", stack)
}
}
impl fmt::Display for ListJobsError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for ListJobsError {
fn description(&self) -> &str {
match *self {
ListJobsError::InvalidAccessKeyId(ref cause) => cause,
ListJobsError::InvalidParameter(ref cause) => cause,
ListJobsError::InvalidVersion(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum UpdateJobError {
BucketPermission(String),
CanceledJobId(String),
ExpiredJobId(String),
InvalidAccessKeyId(String),
InvalidAddress(String),
InvalidCustoms(String),
InvalidFileSystem(String),
InvalidJobId(String),
InvalidManifestField(String),
InvalidParameter(String),
InvalidVersion(String),
MalformedManifest(String),
MissingCustoms(String),
MissingManifestField(String),
MissingParameter(String),
MultipleRegions(String),
NoSuchBucket(String),
UnableToUpdateJobId(String),
}
impl UpdateJobError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<UpdateJobError> {
{
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[..] {
"BucketPermissionException" => {
return RusotoError::Service(UpdateJobError::BucketPermission(
parsed_error.message,
))
}
"CanceledJobIdException" => {
return RusotoError::Service(UpdateJobError::CanceledJobId(
parsed_error.message,
))
}
"ExpiredJobIdException" => {
return RusotoError::Service(UpdateJobError::ExpiredJobId(
parsed_error.message,
))
}
"InvalidAccessKeyIdException" => {
return RusotoError::Service(UpdateJobError::InvalidAccessKeyId(
parsed_error.message,
))
}
"InvalidAddressException" => {
return RusotoError::Service(UpdateJobError::InvalidAddress(
parsed_error.message,
))
}
"InvalidCustomsException" => {
return RusotoError::Service(UpdateJobError::InvalidCustoms(
parsed_error.message,
))
}
"InvalidFileSystemException" => {
return RusotoError::Service(UpdateJobError::InvalidFileSystem(
parsed_error.message,
))
}
"InvalidJobIdException" => {
return RusotoError::Service(UpdateJobError::InvalidJobId(
parsed_error.message,
))
}
"InvalidManifestFieldException" => {
return RusotoError::Service(UpdateJobError::InvalidManifestField(
parsed_error.message,
))
}
"InvalidParameterException" => {
return RusotoError::Service(UpdateJobError::InvalidParameter(
parsed_error.message,
))
}
"InvalidVersionException" => {
return RusotoError::Service(UpdateJobError::InvalidVersion(
parsed_error.message,
))
}
"MalformedManifestException" => {
return RusotoError::Service(UpdateJobError::MalformedManifest(
parsed_error.message,
))
}
"MissingCustomsException" => {
return RusotoError::Service(UpdateJobError::MissingCustoms(
parsed_error.message,
))
}
"MissingManifestFieldException" => {
return RusotoError::Service(UpdateJobError::MissingManifestField(
parsed_error.message,
))
}
"MissingParameterException" => {
return RusotoError::Service(UpdateJobError::MissingParameter(
parsed_error.message,
))
}
"MultipleRegionsException" => {
return RusotoError::Service(UpdateJobError::MultipleRegions(
parsed_error.message,
))
}
"NoSuchBucketException" => {
return RusotoError::Service(UpdateJobError::NoSuchBucket(
parsed_error.message,
))
}
"UnableToUpdateJobIdException" => {
return RusotoError::Service(UpdateJobError::UnableToUpdateJobId(
parsed_error.message,
))
}
_ => {}
}
}
}
RusotoError::Unknown(res)
}
fn deserialize<T>(stack: &mut T) -> Result<XmlError, XmlParseError>
where
T: Peek + Next,
{
start_element("ErrorResponse", stack)?;
XmlErrorDeserializer::deserialize("Error", stack)
}
}
impl fmt::Display for UpdateJobError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for UpdateJobError {
fn description(&self) -> &str {
match *self {
UpdateJobError::BucketPermission(ref cause) => cause,
UpdateJobError::CanceledJobId(ref cause) => cause,
UpdateJobError::ExpiredJobId(ref cause) => cause,
UpdateJobError::InvalidAccessKeyId(ref cause) => cause,
UpdateJobError::InvalidAddress(ref cause) => cause,
UpdateJobError::InvalidCustoms(ref cause) => cause,
UpdateJobError::InvalidFileSystem(ref cause) => cause,
UpdateJobError::InvalidJobId(ref cause) => cause,
UpdateJobError::InvalidManifestField(ref cause) => cause,
UpdateJobError::InvalidParameter(ref cause) => cause,
UpdateJobError::InvalidVersion(ref cause) => cause,
UpdateJobError::MalformedManifest(ref cause) => cause,
UpdateJobError::MissingCustoms(ref cause) => cause,
UpdateJobError::MissingManifestField(ref cause) => cause,
UpdateJobError::MissingParameter(ref cause) => cause,
UpdateJobError::MultipleRegions(ref cause) => cause,
UpdateJobError::NoSuchBucket(ref cause) => cause,
UpdateJobError::UnableToUpdateJobId(ref cause) => cause,
}
}
}
pub trait ImportExport {
fn cancel_job(&self, input: CancelJobInput) -> RusotoFuture<CancelJobOutput, CancelJobError>;
fn create_job(&self, input: CreateJobInput) -> RusotoFuture<CreateJobOutput, CreateJobError>;
fn get_shipping_label(
&self,
input: GetShippingLabelInput,
) -> RusotoFuture<GetShippingLabelOutput, GetShippingLabelError>;
fn get_status(&self, input: GetStatusInput) -> RusotoFuture<GetStatusOutput, GetStatusError>;
fn list_jobs(&self, input: ListJobsInput) -> RusotoFuture<ListJobsOutput, ListJobsError>;
fn update_job(&self, input: UpdateJobInput) -> RusotoFuture<UpdateJobOutput, UpdateJobError>;
}
#[derive(Clone)]
pub struct ImportExportClient {
client: Client,
region: region::Region,
}
impl ImportExportClient {
pub fn new(region: region::Region) -> ImportExportClient {
ImportExportClient {
client: Client::shared(),
region,
}
}
pub fn new_with<P, D>(
request_dispatcher: D,
credentials_provider: P,
region: region::Region,
) -> ImportExportClient
where
P: ProvideAwsCredentials + Send + Sync + 'static,
P::Future: Send,
D: DispatchSignedRequest + Send + Sync + 'static,
D::Future: Send,
{
ImportExportClient {
client: Client::new_with(credentials_provider, request_dispatcher),
region,
}
}
}
impl ImportExport for ImportExportClient {
fn cancel_job(&self, input: CancelJobInput) -> RusotoFuture<CancelJobOutput, CancelJobError> {
let mut request = SignedRequest::new(
"POST",
"importexport",
&self.region,
"/?Operation=CancelJob",
);
let mut params = Params::new();
params.put("Action", "CancelJob");
params.put("Version", "2010-06-01");
CancelJobInputSerializer::serialize(&mut params, "", &input);
request.set_payload(Some(serde_urlencoded::to_string(¶ms).unwrap()));
request.set_content_type("application/x-www-form-urlencoded".to_owned());
self.client.sign_and_dispatch(request, |response| {
if !response.status.is_success() {
return Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(CancelJobError::from_response(response))),
);
}
Box::new(response.buffer().from_err().and_then(move |response| {
let result;
if response.body.is_empty() {
result = CancelJobOutput::default();
} else {
let reader = EventReader::new_with_config(
response.body.as_ref(),
ParserConfig::new().trim_whitespace(true),
);
let mut stack = XmlResponse::new(reader.into_iter().peekable());
let _start_document = stack.next();
let actual_tag_name = peek_at_name(&mut stack)?;
start_element(&actual_tag_name, &mut stack)?;
result =
CancelJobOutputDeserializer::deserialize("CancelJobResult", &mut stack)?;
skip_tree(&mut stack);
end_element(&actual_tag_name, &mut stack)?;
}
Ok(result)
}))
})
}
fn create_job(&self, input: CreateJobInput) -> RusotoFuture<CreateJobOutput, CreateJobError> {
let mut request = SignedRequest::new(
"POST",
"importexport",
&self.region,
"/?Operation=CreateJob",
);
let mut params = Params::new();
params.put("Action", "CreateJob");
params.put("Version", "2010-06-01");
CreateJobInputSerializer::serialize(&mut params, "", &input);
request.set_payload(Some(serde_urlencoded::to_string(¶ms).unwrap()));
request.set_content_type("application/x-www-form-urlencoded".to_owned());
self.client.sign_and_dispatch(request, |response| {
if !response.status.is_success() {
return Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(CreateJobError::from_response(response))),
);
}
Box::new(response.buffer().from_err().and_then(move |response| {
let result;
if response.body.is_empty() {
result = CreateJobOutput::default();
} else {
let reader = EventReader::new_with_config(
response.body.as_ref(),
ParserConfig::new().trim_whitespace(true),
);
let mut stack = XmlResponse::new(reader.into_iter().peekable());
let _start_document = stack.next();
let actual_tag_name = peek_at_name(&mut stack)?;
start_element(&actual_tag_name, &mut stack)?;
result =
CreateJobOutputDeserializer::deserialize("CreateJobResult", &mut stack)?;
skip_tree(&mut stack);
end_element(&actual_tag_name, &mut stack)?;
}
Ok(result)
}))
})
}
fn get_shipping_label(
&self,
input: GetShippingLabelInput,
) -> RusotoFuture<GetShippingLabelOutput, GetShippingLabelError> {
let mut request = SignedRequest::new(
"POST",
"importexport",
&self.region,
"/?Operation=GetShippingLabel",
);
let mut params = Params::new();
params.put("Action", "GetShippingLabel");
params.put("Version", "2010-06-01");
GetShippingLabelInputSerializer::serialize(&mut params, "", &input);
request.set_payload(Some(serde_urlencoded::to_string(¶ms).unwrap()));
request.set_content_type("application/x-www-form-urlencoded".to_owned());
self.client.sign_and_dispatch(request, |response| {
if !response.status.is_success() {
return Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(GetShippingLabelError::from_response(response))),
);
}
Box::new(response.buffer().from_err().and_then(move |response| {
let result;
if response.body.is_empty() {
result = GetShippingLabelOutput::default();
} else {
let reader = EventReader::new_with_config(
response.body.as_ref(),
ParserConfig::new().trim_whitespace(true),
);
let mut stack = XmlResponse::new(reader.into_iter().peekable());
let _start_document = stack.next();
let actual_tag_name = peek_at_name(&mut stack)?;
start_element(&actual_tag_name, &mut stack)?;
result = GetShippingLabelOutputDeserializer::deserialize(
"GetShippingLabelResult",
&mut stack,
)?;
skip_tree(&mut stack);
end_element(&actual_tag_name, &mut stack)?;
}
Ok(result)
}))
})
}
fn get_status(&self, input: GetStatusInput) -> RusotoFuture<GetStatusOutput, GetStatusError> {
let mut request = SignedRequest::new(
"POST",
"importexport",
&self.region,
"/?Operation=GetStatus",
);
let mut params = Params::new();
params.put("Action", "GetStatus");
params.put("Version", "2010-06-01");
GetStatusInputSerializer::serialize(&mut params, "", &input);
request.set_payload(Some(serde_urlencoded::to_string(¶ms).unwrap()));
request.set_content_type("application/x-www-form-urlencoded".to_owned());
self.client.sign_and_dispatch(request, |response| {
if !response.status.is_success() {
return Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(GetStatusError::from_response(response))),
);
}
Box::new(response.buffer().from_err().and_then(move |response| {
let result;
if response.body.is_empty() {
result = GetStatusOutput::default();
} else {
let reader = EventReader::new_with_config(
response.body.as_ref(),
ParserConfig::new().trim_whitespace(true),
);
let mut stack = XmlResponse::new(reader.into_iter().peekable());
let _start_document = stack.next();
let actual_tag_name = peek_at_name(&mut stack)?;
start_element(&actual_tag_name, &mut stack)?;
result =
GetStatusOutputDeserializer::deserialize("GetStatusResult", &mut stack)?;
skip_tree(&mut stack);
end_element(&actual_tag_name, &mut stack)?;
}
Ok(result)
}))
})
}
fn list_jobs(&self, input: ListJobsInput) -> RusotoFuture<ListJobsOutput, ListJobsError> {
let mut request =
SignedRequest::new("POST", "importexport", &self.region, "/?Operation=ListJobs");
let mut params = Params::new();
params.put("Action", "ListJobs");
params.put("Version", "2010-06-01");
ListJobsInputSerializer::serialize(&mut params, "", &input);
request.set_payload(Some(serde_urlencoded::to_string(¶ms).unwrap()));
request.set_content_type("application/x-www-form-urlencoded".to_owned());
self.client.sign_and_dispatch(request, |response| {
if !response.status.is_success() {
return Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(ListJobsError::from_response(response))),
);
}
Box::new(response.buffer().from_err().and_then(move |response| {
let result;
if response.body.is_empty() {
result = ListJobsOutput::default();
} else {
let reader = EventReader::new_with_config(
response.body.as_ref(),
ParserConfig::new().trim_whitespace(true),
);
let mut stack = XmlResponse::new(reader.into_iter().peekable());
let _start_document = stack.next();
let actual_tag_name = peek_at_name(&mut stack)?;
start_element(&actual_tag_name, &mut stack)?;
result = ListJobsOutputDeserializer::deserialize("ListJobsResult", &mut stack)?;
skip_tree(&mut stack);
end_element(&actual_tag_name, &mut stack)?;
}
Ok(result)
}))
})
}
fn update_job(&self, input: UpdateJobInput) -> RusotoFuture<UpdateJobOutput, UpdateJobError> {
let mut request = SignedRequest::new(
"POST",
"importexport",
&self.region,
"/?Operation=UpdateJob",
);
let mut params = Params::new();
params.put("Action", "UpdateJob");
params.put("Version", "2010-06-01");
UpdateJobInputSerializer::serialize(&mut params, "", &input);
request.set_payload(Some(serde_urlencoded::to_string(¶ms).unwrap()));
request.set_content_type("application/x-www-form-urlencoded".to_owned());
self.client.sign_and_dispatch(request, |response| {
if !response.status.is_success() {
return Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(UpdateJobError::from_response(response))),
);
}
Box::new(response.buffer().from_err().and_then(move |response| {
let result;
if response.body.is_empty() {
result = UpdateJobOutput::default();
} else {
let reader = EventReader::new_with_config(
response.body.as_ref(),
ParserConfig::new().trim_whitespace(true),
);
let mut stack = XmlResponse::new(reader.into_iter().peekable());
let _start_document = stack.next();
let actual_tag_name = peek_at_name(&mut stack)?;
start_element(&actual_tag_name, &mut stack)?;
result =
UpdateJobOutputDeserializer::deserialize("UpdateJobResult", &mut stack)?;
skip_tree(&mut stack);
end_element(&actual_tag_name, &mut stack)?;
}
Ok(result)
}))
})
}
}
#[cfg(test)]
mod protocol_tests {
extern crate rusoto_mock;
use self::rusoto_mock::*;
use super::*;
use rusoto_core::Region as rusoto_region;
#[test]
fn test_parse_error_importexport_get_status() {
let mock_response = MockResponseReader::read_response(
"test_resources/generated/error",
"importexport-get-status.xml",
);
let mock = MockRequestDispatcher::with_status(400).with_body(&mock_response);
let client =
ImportExportClient::new_with(mock, MockCredentialsProvider, rusoto_region::UsEast1);
let request = GetStatusInput::default();
let result = client.get_status(request).sync();
assert!(!result.is_ok(), "parse error: {:?}", result);
}
#[test]
fn test_parse_valid_importexport_list_jobs() {
let mock_response = MockResponseReader::read_response(
"test_resources/generated/valid",
"importexport-list-jobs.xml",
);
let mock = MockRequestDispatcher::with_status(200).with_body(&mock_response);
let client =
ImportExportClient::new_with(mock, MockCredentialsProvider, rusoto_region::UsEast1);
let request = ListJobsInput::default();
let result = client.list_jobs(request).sync();
assert!(result.is_ok(), "parse error: {:?}", result);
}
}