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::signature::SignedRequest;
use serde_json;
use serde_json::from_slice;
use serde_json::Value as SerdeJsonValue;
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct Container {
#[serde(rename = "ARN")]
#[serde(skip_serializing_if = "Option::is_none")]
pub arn: Option<String>,
#[serde(rename = "CreationTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub creation_time: Option<f64>,
#[serde(rename = "Endpoint")]
#[serde(skip_serializing_if = "Option::is_none")]
pub endpoint: Option<String>,
#[serde(rename = "Name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(rename = "Status")]
#[serde(skip_serializing_if = "Option::is_none")]
pub status: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct CorsRule {
#[serde(rename = "AllowedHeaders")]
pub allowed_headers: Vec<String>,
#[serde(rename = "AllowedMethods")]
#[serde(skip_serializing_if = "Option::is_none")]
pub allowed_methods: Option<Vec<String>>,
#[serde(rename = "AllowedOrigins")]
pub allowed_origins: Vec<String>,
#[serde(rename = "ExposeHeaders")]
#[serde(skip_serializing_if = "Option::is_none")]
pub expose_headers: Option<Vec<String>>,
#[serde(rename = "MaxAgeSeconds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub max_age_seconds: Option<i64>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct CreateContainerInput {
#[serde(rename = "ContainerName")]
pub container_name: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct CreateContainerOutput {
#[serde(rename = "Container")]
pub container: Container,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DeleteContainerInput {
#[serde(rename = "ContainerName")]
pub container_name: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DeleteContainerOutput {}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DeleteContainerPolicyInput {
#[serde(rename = "ContainerName")]
pub container_name: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DeleteContainerPolicyOutput {}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DeleteCorsPolicyInput {
#[serde(rename = "ContainerName")]
pub container_name: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DeleteCorsPolicyOutput {}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DeleteLifecyclePolicyInput {
#[serde(rename = "ContainerName")]
pub container_name: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DeleteLifecyclePolicyOutput {}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DescribeContainerInput {
#[serde(rename = "ContainerName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub container_name: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DescribeContainerOutput {
#[serde(rename = "Container")]
#[serde(skip_serializing_if = "Option::is_none")]
pub container: Option<Container>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct GetContainerPolicyInput {
#[serde(rename = "ContainerName")]
pub container_name: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct GetContainerPolicyOutput {
#[serde(rename = "Policy")]
pub policy: String,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct GetCorsPolicyInput {
#[serde(rename = "ContainerName")]
pub container_name: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct GetCorsPolicyOutput {
#[serde(rename = "CorsPolicy")]
pub cors_policy: Vec<CorsRule>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct GetLifecyclePolicyInput {
#[serde(rename = "ContainerName")]
pub container_name: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct GetLifecyclePolicyOutput {
#[serde(rename = "LifecyclePolicy")]
pub lifecycle_policy: String,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct ListContainersInput {
#[serde(rename = "MaxResults")]
#[serde(skip_serializing_if = "Option::is_none")]
pub max_results: Option<i64>,
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct ListContainersOutput {
#[serde(rename = "Containers")]
pub containers: Vec<Container>,
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct PutContainerPolicyInput {
#[serde(rename = "ContainerName")]
pub container_name: String,
#[serde(rename = "Policy")]
pub policy: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct PutContainerPolicyOutput {}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct PutCorsPolicyInput {
#[serde(rename = "ContainerName")]
pub container_name: String,
#[serde(rename = "CorsPolicy")]
pub cors_policy: Vec<CorsRule>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct PutCorsPolicyOutput {}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct PutLifecyclePolicyInput {
#[serde(rename = "ContainerName")]
pub container_name: String,
#[serde(rename = "LifecyclePolicy")]
pub lifecycle_policy: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct PutLifecyclePolicyOutput {}
#[derive(Debug, PartialEq)]
pub enum CreateContainerError {
ContainerInUse(String),
InternalServerError(String),
LimitExceeded(String),
}
impl CreateContainerError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<CreateContainerError> {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"ContainerInUseException" => {
return RusotoError::Service(CreateContainerError::ContainerInUse(
String::from(error_message),
))
}
"InternalServerError" => {
return RusotoError::Service(CreateContainerError::InternalServerError(
String::from(error_message),
))
}
"LimitExceededException" => {
return RusotoError::Service(CreateContainerError::LimitExceeded(String::from(
error_message,
)))
}
"ValidationException" => return RusotoError::Validation(error_message.to_string()),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for CreateContainerError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for CreateContainerError {
fn description(&self) -> &str {
match *self {
CreateContainerError::ContainerInUse(ref cause) => cause,
CreateContainerError::InternalServerError(ref cause) => cause,
CreateContainerError::LimitExceeded(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum DeleteContainerError {
ContainerInUse(String),
ContainerNotFound(String),
InternalServerError(String),
}
impl DeleteContainerError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<DeleteContainerError> {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"ContainerInUseException" => {
return RusotoError::Service(DeleteContainerError::ContainerInUse(
String::from(error_message),
))
}
"ContainerNotFoundException" => {
return RusotoError::Service(DeleteContainerError::ContainerNotFound(
String::from(error_message),
))
}
"InternalServerError" => {
return RusotoError::Service(DeleteContainerError::InternalServerError(
String::from(error_message),
))
}
"ValidationException" => return RusotoError::Validation(error_message.to_string()),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for DeleteContainerError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DeleteContainerError {
fn description(&self) -> &str {
match *self {
DeleteContainerError::ContainerInUse(ref cause) => cause,
DeleteContainerError::ContainerNotFound(ref cause) => cause,
DeleteContainerError::InternalServerError(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum DeleteContainerPolicyError {
ContainerInUse(String),
ContainerNotFound(String),
InternalServerError(String),
PolicyNotFound(String),
}
impl DeleteContainerPolicyError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<DeleteContainerPolicyError> {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"ContainerInUseException" => {
return RusotoError::Service(DeleteContainerPolicyError::ContainerInUse(
String::from(error_message),
))
}
"ContainerNotFoundException" => {
return RusotoError::Service(DeleteContainerPolicyError::ContainerNotFound(
String::from(error_message),
))
}
"InternalServerError" => {
return RusotoError::Service(DeleteContainerPolicyError::InternalServerError(
String::from(error_message),
))
}
"PolicyNotFoundException" => {
return RusotoError::Service(DeleteContainerPolicyError::PolicyNotFound(
String::from(error_message),
))
}
"ValidationException" => return RusotoError::Validation(error_message.to_string()),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for DeleteContainerPolicyError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DeleteContainerPolicyError {
fn description(&self) -> &str {
match *self {
DeleteContainerPolicyError::ContainerInUse(ref cause) => cause,
DeleteContainerPolicyError::ContainerNotFound(ref cause) => cause,
DeleteContainerPolicyError::InternalServerError(ref cause) => cause,
DeleteContainerPolicyError::PolicyNotFound(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum DeleteCorsPolicyError {
ContainerInUse(String),
ContainerNotFound(String),
CorsPolicyNotFound(String),
InternalServerError(String),
}
impl DeleteCorsPolicyError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<DeleteCorsPolicyError> {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"ContainerInUseException" => {
return RusotoError::Service(DeleteCorsPolicyError::ContainerInUse(
String::from(error_message),
))
}
"ContainerNotFoundException" => {
return RusotoError::Service(DeleteCorsPolicyError::ContainerNotFound(
String::from(error_message),
))
}
"CorsPolicyNotFoundException" => {
return RusotoError::Service(DeleteCorsPolicyError::CorsPolicyNotFound(
String::from(error_message),
))
}
"InternalServerError" => {
return RusotoError::Service(DeleteCorsPolicyError::InternalServerError(
String::from(error_message),
))
}
"ValidationException" => return RusotoError::Validation(error_message.to_string()),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for DeleteCorsPolicyError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DeleteCorsPolicyError {
fn description(&self) -> &str {
match *self {
DeleteCorsPolicyError::ContainerInUse(ref cause) => cause,
DeleteCorsPolicyError::ContainerNotFound(ref cause) => cause,
DeleteCorsPolicyError::CorsPolicyNotFound(ref cause) => cause,
DeleteCorsPolicyError::InternalServerError(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum DeleteLifecyclePolicyError {
ContainerInUse(String),
ContainerNotFound(String),
InternalServerError(String),
PolicyNotFound(String),
}
impl DeleteLifecyclePolicyError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<DeleteLifecyclePolicyError> {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"ContainerInUseException" => {
return RusotoError::Service(DeleteLifecyclePolicyError::ContainerInUse(
String::from(error_message),
))
}
"ContainerNotFoundException" => {
return RusotoError::Service(DeleteLifecyclePolicyError::ContainerNotFound(
String::from(error_message),
))
}
"InternalServerError" => {
return RusotoError::Service(DeleteLifecyclePolicyError::InternalServerError(
String::from(error_message),
))
}
"PolicyNotFoundException" => {
return RusotoError::Service(DeleteLifecyclePolicyError::PolicyNotFound(
String::from(error_message),
))
}
"ValidationException" => return RusotoError::Validation(error_message.to_string()),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for DeleteLifecyclePolicyError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DeleteLifecyclePolicyError {
fn description(&self) -> &str {
match *self {
DeleteLifecyclePolicyError::ContainerInUse(ref cause) => cause,
DeleteLifecyclePolicyError::ContainerNotFound(ref cause) => cause,
DeleteLifecyclePolicyError::InternalServerError(ref cause) => cause,
DeleteLifecyclePolicyError::PolicyNotFound(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum DescribeContainerError {
ContainerNotFound(String),
InternalServerError(String),
}
impl DescribeContainerError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<DescribeContainerError> {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"ContainerNotFoundException" => {
return RusotoError::Service(DescribeContainerError::ContainerNotFound(
String::from(error_message),
))
}
"InternalServerError" => {
return RusotoError::Service(DescribeContainerError::InternalServerError(
String::from(error_message),
))
}
"ValidationException" => return RusotoError::Validation(error_message.to_string()),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for DescribeContainerError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DescribeContainerError {
fn description(&self) -> &str {
match *self {
DescribeContainerError::ContainerNotFound(ref cause) => cause,
DescribeContainerError::InternalServerError(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum GetContainerPolicyError {
ContainerInUse(String),
ContainerNotFound(String),
InternalServerError(String),
PolicyNotFound(String),
}
impl GetContainerPolicyError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<GetContainerPolicyError> {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"ContainerInUseException" => {
return RusotoError::Service(GetContainerPolicyError::ContainerInUse(
String::from(error_message),
))
}
"ContainerNotFoundException" => {
return RusotoError::Service(GetContainerPolicyError::ContainerNotFound(
String::from(error_message),
))
}
"InternalServerError" => {
return RusotoError::Service(GetContainerPolicyError::InternalServerError(
String::from(error_message),
))
}
"PolicyNotFoundException" => {
return RusotoError::Service(GetContainerPolicyError::PolicyNotFound(
String::from(error_message),
))
}
"ValidationException" => return RusotoError::Validation(error_message.to_string()),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for GetContainerPolicyError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for GetContainerPolicyError {
fn description(&self) -> &str {
match *self {
GetContainerPolicyError::ContainerInUse(ref cause) => cause,
GetContainerPolicyError::ContainerNotFound(ref cause) => cause,
GetContainerPolicyError::InternalServerError(ref cause) => cause,
GetContainerPolicyError::PolicyNotFound(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum GetCorsPolicyError {
ContainerInUse(String),
ContainerNotFound(String),
CorsPolicyNotFound(String),
InternalServerError(String),
}
impl GetCorsPolicyError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<GetCorsPolicyError> {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"ContainerInUseException" => {
return RusotoError::Service(GetCorsPolicyError::ContainerInUse(String::from(
error_message,
)))
}
"ContainerNotFoundException" => {
return RusotoError::Service(GetCorsPolicyError::ContainerNotFound(
String::from(error_message),
))
}
"CorsPolicyNotFoundException" => {
return RusotoError::Service(GetCorsPolicyError::CorsPolicyNotFound(
String::from(error_message),
))
}
"InternalServerError" => {
return RusotoError::Service(GetCorsPolicyError::InternalServerError(
String::from(error_message),
))
}
"ValidationException" => return RusotoError::Validation(error_message.to_string()),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for GetCorsPolicyError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for GetCorsPolicyError {
fn description(&self) -> &str {
match *self {
GetCorsPolicyError::ContainerInUse(ref cause) => cause,
GetCorsPolicyError::ContainerNotFound(ref cause) => cause,
GetCorsPolicyError::CorsPolicyNotFound(ref cause) => cause,
GetCorsPolicyError::InternalServerError(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum GetLifecyclePolicyError {
ContainerInUse(String),
ContainerNotFound(String),
InternalServerError(String),
PolicyNotFound(String),
}
impl GetLifecyclePolicyError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<GetLifecyclePolicyError> {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"ContainerInUseException" => {
return RusotoError::Service(GetLifecyclePolicyError::ContainerInUse(
String::from(error_message),
))
}
"ContainerNotFoundException" => {
return RusotoError::Service(GetLifecyclePolicyError::ContainerNotFound(
String::from(error_message),
))
}
"InternalServerError" => {
return RusotoError::Service(GetLifecyclePolicyError::InternalServerError(
String::from(error_message),
))
}
"PolicyNotFoundException" => {
return RusotoError::Service(GetLifecyclePolicyError::PolicyNotFound(
String::from(error_message),
))
}
"ValidationException" => return RusotoError::Validation(error_message.to_string()),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for GetLifecyclePolicyError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for GetLifecyclePolicyError {
fn description(&self) -> &str {
match *self {
GetLifecyclePolicyError::ContainerInUse(ref cause) => cause,
GetLifecyclePolicyError::ContainerNotFound(ref cause) => cause,
GetLifecyclePolicyError::InternalServerError(ref cause) => cause,
GetLifecyclePolicyError::PolicyNotFound(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum ListContainersError {
InternalServerError(String),
}
impl ListContainersError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<ListContainersError> {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"InternalServerError" => {
return RusotoError::Service(ListContainersError::InternalServerError(
String::from(error_message),
))
}
"ValidationException" => return RusotoError::Validation(error_message.to_string()),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for ListContainersError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for ListContainersError {
fn description(&self) -> &str {
match *self {
ListContainersError::InternalServerError(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum PutContainerPolicyError {
ContainerInUse(String),
ContainerNotFound(String),
InternalServerError(String),
}
impl PutContainerPolicyError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<PutContainerPolicyError> {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"ContainerInUseException" => {
return RusotoError::Service(PutContainerPolicyError::ContainerInUse(
String::from(error_message),
))
}
"ContainerNotFoundException" => {
return RusotoError::Service(PutContainerPolicyError::ContainerNotFound(
String::from(error_message),
))
}
"InternalServerError" => {
return RusotoError::Service(PutContainerPolicyError::InternalServerError(
String::from(error_message),
))
}
"ValidationException" => return RusotoError::Validation(error_message.to_string()),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for PutContainerPolicyError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for PutContainerPolicyError {
fn description(&self) -> &str {
match *self {
PutContainerPolicyError::ContainerInUse(ref cause) => cause,
PutContainerPolicyError::ContainerNotFound(ref cause) => cause,
PutContainerPolicyError::InternalServerError(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum PutCorsPolicyError {
ContainerInUse(String),
ContainerNotFound(String),
InternalServerError(String),
}
impl PutCorsPolicyError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<PutCorsPolicyError> {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"ContainerInUseException" => {
return RusotoError::Service(PutCorsPolicyError::ContainerInUse(String::from(
error_message,
)))
}
"ContainerNotFoundException" => {
return RusotoError::Service(PutCorsPolicyError::ContainerNotFound(
String::from(error_message),
))
}
"InternalServerError" => {
return RusotoError::Service(PutCorsPolicyError::InternalServerError(
String::from(error_message),
))
}
"ValidationException" => return RusotoError::Validation(error_message.to_string()),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for PutCorsPolicyError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for PutCorsPolicyError {
fn description(&self) -> &str {
match *self {
PutCorsPolicyError::ContainerInUse(ref cause) => cause,
PutCorsPolicyError::ContainerNotFound(ref cause) => cause,
PutCorsPolicyError::InternalServerError(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum PutLifecyclePolicyError {
ContainerInUse(String),
ContainerNotFound(String),
InternalServerError(String),
}
impl PutLifecyclePolicyError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<PutLifecyclePolicyError> {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let raw_error_type = json
.get("__type")
.and_then(|e| e.as_str())
.unwrap_or("Unknown");
let error_message = json.get("message").and_then(|m| m.as_str()).unwrap_or("");
let pieces: Vec<&str> = raw_error_type.split("#").collect();
let error_type = pieces.last().expect("Expected error type");
match *error_type {
"ContainerInUseException" => {
return RusotoError::Service(PutLifecyclePolicyError::ContainerInUse(
String::from(error_message),
))
}
"ContainerNotFoundException" => {
return RusotoError::Service(PutLifecyclePolicyError::ContainerNotFound(
String::from(error_message),
))
}
"InternalServerError" => {
return RusotoError::Service(PutLifecyclePolicyError::InternalServerError(
String::from(error_message),
))
}
"ValidationException" => return RusotoError::Validation(error_message.to_string()),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for PutLifecyclePolicyError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for PutLifecyclePolicyError {
fn description(&self) -> &str {
match *self {
PutLifecyclePolicyError::ContainerInUse(ref cause) => cause,
PutLifecyclePolicyError::ContainerNotFound(ref cause) => cause,
PutLifecyclePolicyError::InternalServerError(ref cause) => cause,
}
}
}
pub trait MediaStore {
fn create_container(
&self,
input: CreateContainerInput,
) -> RusotoFuture<CreateContainerOutput, CreateContainerError>;
fn delete_container(
&self,
input: DeleteContainerInput,
) -> RusotoFuture<DeleteContainerOutput, DeleteContainerError>;
fn delete_container_policy(
&self,
input: DeleteContainerPolicyInput,
) -> RusotoFuture<DeleteContainerPolicyOutput, DeleteContainerPolicyError>;
fn delete_cors_policy(
&self,
input: DeleteCorsPolicyInput,
) -> RusotoFuture<DeleteCorsPolicyOutput, DeleteCorsPolicyError>;
fn delete_lifecycle_policy(
&self,
input: DeleteLifecyclePolicyInput,
) -> RusotoFuture<DeleteLifecyclePolicyOutput, DeleteLifecyclePolicyError>;
fn describe_container(
&self,
input: DescribeContainerInput,
) -> RusotoFuture<DescribeContainerOutput, DescribeContainerError>;
fn get_container_policy(
&self,
input: GetContainerPolicyInput,
) -> RusotoFuture<GetContainerPolicyOutput, GetContainerPolicyError>;
fn get_cors_policy(
&self,
input: GetCorsPolicyInput,
) -> RusotoFuture<GetCorsPolicyOutput, GetCorsPolicyError>;
fn get_lifecycle_policy(
&self,
input: GetLifecyclePolicyInput,
) -> RusotoFuture<GetLifecyclePolicyOutput, GetLifecyclePolicyError>;
fn list_containers(
&self,
input: ListContainersInput,
) -> RusotoFuture<ListContainersOutput, ListContainersError>;
fn put_container_policy(
&self,
input: PutContainerPolicyInput,
) -> RusotoFuture<PutContainerPolicyOutput, PutContainerPolicyError>;
fn put_cors_policy(
&self,
input: PutCorsPolicyInput,
) -> RusotoFuture<PutCorsPolicyOutput, PutCorsPolicyError>;
fn put_lifecycle_policy(
&self,
input: PutLifecyclePolicyInput,
) -> RusotoFuture<PutLifecyclePolicyOutput, PutLifecyclePolicyError>;
}
#[derive(Clone)]
pub struct MediaStoreClient {
client: Client,
region: region::Region,
}
impl MediaStoreClient {
pub fn new(region: region::Region) -> MediaStoreClient {
MediaStoreClient {
client: Client::shared(),
region: region,
}
}
pub fn new_with<P, D>(
request_dispatcher: D,
credentials_provider: P,
region: region::Region,
) -> MediaStoreClient
where
P: ProvideAwsCredentials + Send + Sync + 'static,
P::Future: Send,
D: DispatchSignedRequest + Send + Sync + 'static,
D::Future: Send,
{
MediaStoreClient {
client: Client::new_with(credentials_provider, request_dispatcher),
region: region,
}
}
}
impl MediaStore for MediaStoreClient {
fn create_container(
&self,
input: CreateContainerInput,
) -> RusotoFuture<CreateContainerOutput, CreateContainerError> {
let mut request = SignedRequest::new("POST", "mediastore", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "MediaStore_20170901.CreateContainer");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<CreateContainerOutput>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(CreateContainerError::from_response(response))),
)
}
})
}
fn delete_container(
&self,
input: DeleteContainerInput,
) -> RusotoFuture<DeleteContainerOutput, DeleteContainerError> {
let mut request = SignedRequest::new("POST", "mediastore", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "MediaStore_20170901.DeleteContainer");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<DeleteContainerOutput>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DeleteContainerError::from_response(response))),
)
}
})
}
fn delete_container_policy(
&self,
input: DeleteContainerPolicyInput,
) -> RusotoFuture<DeleteContainerPolicyOutput, DeleteContainerPolicyError> {
let mut request = SignedRequest::new("POST", "mediastore", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "MediaStore_20170901.DeleteContainerPolicy");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<DeleteContainerPolicyOutput>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response.buffer().from_err().and_then(|response| {
Err(DeleteContainerPolicyError::from_response(response))
}),
)
}
})
}
fn delete_cors_policy(
&self,
input: DeleteCorsPolicyInput,
) -> RusotoFuture<DeleteCorsPolicyOutput, DeleteCorsPolicyError> {
let mut request = SignedRequest::new("POST", "mediastore", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "MediaStore_20170901.DeleteCorsPolicy");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<DeleteCorsPolicyOutput>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DeleteCorsPolicyError::from_response(response))),
)
}
})
}
fn delete_lifecycle_policy(
&self,
input: DeleteLifecyclePolicyInput,
) -> RusotoFuture<DeleteLifecyclePolicyOutput, DeleteLifecyclePolicyError> {
let mut request = SignedRequest::new("POST", "mediastore", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "MediaStore_20170901.DeleteLifecyclePolicy");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<DeleteLifecyclePolicyOutput>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response.buffer().from_err().and_then(|response| {
Err(DeleteLifecyclePolicyError::from_response(response))
}),
)
}
})
}
fn describe_container(
&self,
input: DescribeContainerInput,
) -> RusotoFuture<DescribeContainerOutput, DescribeContainerError> {
let mut request = SignedRequest::new("POST", "mediastore", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "MediaStore_20170901.DescribeContainer");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<DescribeContainerOutput>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DescribeContainerError::from_response(response))),
)
}
})
}
fn get_container_policy(
&self,
input: GetContainerPolicyInput,
) -> RusotoFuture<GetContainerPolicyOutput, GetContainerPolicyError> {
let mut request = SignedRequest::new("POST", "mediastore", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "MediaStore_20170901.GetContainerPolicy");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<GetContainerPolicyOutput>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(GetContainerPolicyError::from_response(response))),
)
}
})
}
fn get_cors_policy(
&self,
input: GetCorsPolicyInput,
) -> RusotoFuture<GetCorsPolicyOutput, GetCorsPolicyError> {
let mut request = SignedRequest::new("POST", "mediastore", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "MediaStore_20170901.GetCorsPolicy");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<GetCorsPolicyOutput>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(GetCorsPolicyError::from_response(response))),
)
}
})
}
fn get_lifecycle_policy(
&self,
input: GetLifecyclePolicyInput,
) -> RusotoFuture<GetLifecyclePolicyOutput, GetLifecyclePolicyError> {
let mut request = SignedRequest::new("POST", "mediastore", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "MediaStore_20170901.GetLifecyclePolicy");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<GetLifecyclePolicyOutput>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(GetLifecyclePolicyError::from_response(response))),
)
}
})
}
fn list_containers(
&self,
input: ListContainersInput,
) -> RusotoFuture<ListContainersOutput, ListContainersError> {
let mut request = SignedRequest::new("POST", "mediastore", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "MediaStore_20170901.ListContainers");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<ListContainersOutput>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(ListContainersError::from_response(response))),
)
}
})
}
fn put_container_policy(
&self,
input: PutContainerPolicyInput,
) -> RusotoFuture<PutContainerPolicyOutput, PutContainerPolicyError> {
let mut request = SignedRequest::new("POST", "mediastore", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "MediaStore_20170901.PutContainerPolicy");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<PutContainerPolicyOutput>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(PutContainerPolicyError::from_response(response))),
)
}
})
}
fn put_cors_policy(
&self,
input: PutCorsPolicyInput,
) -> RusotoFuture<PutCorsPolicyOutput, PutCorsPolicyError> {
let mut request = SignedRequest::new("POST", "mediastore", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "MediaStore_20170901.PutCorsPolicy");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<PutCorsPolicyOutput>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(PutCorsPolicyError::from_response(response))),
)
}
})
}
fn put_lifecycle_policy(
&self,
input: PutLifecyclePolicyInput,
) -> RusotoFuture<PutLifecyclePolicyOutput, PutLifecyclePolicyError> {
let mut request = SignedRequest::new("POST", "mediastore", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "MediaStore_20170901.PutLifecyclePolicy");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded.into_bytes()));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body.is_empty() || body == b"null" {
body = b"{}".to_vec();
}
serde_json::from_str::<PutLifecyclePolicyOutput>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(PutLifecyclePolicyError::from_response(response))),
)
}
})
}
}
#[cfg(test)]
mod protocol_tests {}