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::proto;
use rusoto_core::signature::SignedRequest;
use serde_json;
#[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 = "AccessLoggingEnabled")]
#[serde(skip_serializing_if = "Option::is_none")]
pub access_logging_enabled: Option<bool>,
#[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(Default, Debug, Clone, PartialEq, Serialize)]
pub struct StartAccessLoggingInput {
#[serde(rename = "ContainerName")]
pub container_name: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct StartAccessLoggingOutput {}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct StopAccessLoggingInput {
#[serde(rename = "ContainerName")]
pub container_name: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct StopAccessLoggingOutput {}
#[derive(Debug, PartialEq)]
pub enum CreateContainerError {
ContainerInUse(String),
InternalServerError(String),
LimitExceeded(String),
}
impl CreateContainerError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<CreateContainerError> {
if let Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"ContainerInUseException" => {
return RusotoError::Service(CreateContainerError::ContainerInUse(err.msg))
}
"InternalServerError" => {
return RusotoError::Service(CreateContainerError::InternalServerError(err.msg))
}
"LimitExceededException" => {
return RusotoError::Service(CreateContainerError::LimitExceeded(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
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 Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"ContainerInUseException" => {
return RusotoError::Service(DeleteContainerError::ContainerInUse(err.msg))
}
"ContainerNotFoundException" => {
return RusotoError::Service(DeleteContainerError::ContainerNotFound(err.msg))
}
"InternalServerError" => {
return RusotoError::Service(DeleteContainerError::InternalServerError(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
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 Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"ContainerInUseException" => {
return RusotoError::Service(DeleteContainerPolicyError::ContainerInUse(
err.msg,
))
}
"ContainerNotFoundException" => {
return RusotoError::Service(DeleteContainerPolicyError::ContainerNotFound(
err.msg,
))
}
"InternalServerError" => {
return RusotoError::Service(DeleteContainerPolicyError::InternalServerError(
err.msg,
))
}
"PolicyNotFoundException" => {
return RusotoError::Service(DeleteContainerPolicyError::PolicyNotFound(
err.msg,
))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
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 Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"ContainerInUseException" => {
return RusotoError::Service(DeleteCorsPolicyError::ContainerInUse(err.msg))
}
"ContainerNotFoundException" => {
return RusotoError::Service(DeleteCorsPolicyError::ContainerNotFound(err.msg))
}
"CorsPolicyNotFoundException" => {
return RusotoError::Service(DeleteCorsPolicyError::CorsPolicyNotFound(err.msg))
}
"InternalServerError" => {
return RusotoError::Service(DeleteCorsPolicyError::InternalServerError(
err.msg,
))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
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 Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"ContainerInUseException" => {
return RusotoError::Service(DeleteLifecyclePolicyError::ContainerInUse(
err.msg,
))
}
"ContainerNotFoundException" => {
return RusotoError::Service(DeleteLifecyclePolicyError::ContainerNotFound(
err.msg,
))
}
"InternalServerError" => {
return RusotoError::Service(DeleteLifecyclePolicyError::InternalServerError(
err.msg,
))
}
"PolicyNotFoundException" => {
return RusotoError::Service(DeleteLifecyclePolicyError::PolicyNotFound(
err.msg,
))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
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 Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"ContainerNotFoundException" => {
return RusotoError::Service(DescribeContainerError::ContainerNotFound(err.msg))
}
"InternalServerError" => {
return RusotoError::Service(DescribeContainerError::InternalServerError(
err.msg,
))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
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 Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"ContainerInUseException" => {
return RusotoError::Service(GetContainerPolicyError::ContainerInUse(err.msg))
}
"ContainerNotFoundException" => {
return RusotoError::Service(GetContainerPolicyError::ContainerNotFound(
err.msg,
))
}
"InternalServerError" => {
return RusotoError::Service(GetContainerPolicyError::InternalServerError(
err.msg,
))
}
"PolicyNotFoundException" => {
return RusotoError::Service(GetContainerPolicyError::PolicyNotFound(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
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 Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"ContainerInUseException" => {
return RusotoError::Service(GetCorsPolicyError::ContainerInUse(err.msg))
}
"ContainerNotFoundException" => {
return RusotoError::Service(GetCorsPolicyError::ContainerNotFound(err.msg))
}
"CorsPolicyNotFoundException" => {
return RusotoError::Service(GetCorsPolicyError::CorsPolicyNotFound(err.msg))
}
"InternalServerError" => {
return RusotoError::Service(GetCorsPolicyError::InternalServerError(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
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 Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"ContainerInUseException" => {
return RusotoError::Service(GetLifecyclePolicyError::ContainerInUse(err.msg))
}
"ContainerNotFoundException" => {
return RusotoError::Service(GetLifecyclePolicyError::ContainerNotFound(
err.msg,
))
}
"InternalServerError" => {
return RusotoError::Service(GetLifecyclePolicyError::InternalServerError(
err.msg,
))
}
"PolicyNotFoundException" => {
return RusotoError::Service(GetLifecyclePolicyError::PolicyNotFound(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
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 Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"InternalServerError" => {
return RusotoError::Service(ListContainersError::InternalServerError(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
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 Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"ContainerInUseException" => {
return RusotoError::Service(PutContainerPolicyError::ContainerInUse(err.msg))
}
"ContainerNotFoundException" => {
return RusotoError::Service(PutContainerPolicyError::ContainerNotFound(
err.msg,
))
}
"InternalServerError" => {
return RusotoError::Service(PutContainerPolicyError::InternalServerError(
err.msg,
))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
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 Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"ContainerInUseException" => {
return RusotoError::Service(PutCorsPolicyError::ContainerInUse(err.msg))
}
"ContainerNotFoundException" => {
return RusotoError::Service(PutCorsPolicyError::ContainerNotFound(err.msg))
}
"InternalServerError" => {
return RusotoError::Service(PutCorsPolicyError::InternalServerError(err.msg))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
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 Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"ContainerInUseException" => {
return RusotoError::Service(PutLifecyclePolicyError::ContainerInUse(err.msg))
}
"ContainerNotFoundException" => {
return RusotoError::Service(PutLifecyclePolicyError::ContainerNotFound(
err.msg,
))
}
"InternalServerError" => {
return RusotoError::Service(PutLifecyclePolicyError::InternalServerError(
err.msg,
))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
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,
}
}
}
#[derive(Debug, PartialEq)]
pub enum StartAccessLoggingError {
ContainerInUse(String),
ContainerNotFound(String),
InternalServerError(String),
}
impl StartAccessLoggingError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<StartAccessLoggingError> {
if let Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"ContainerInUseException" => {
return RusotoError::Service(StartAccessLoggingError::ContainerInUse(err.msg))
}
"ContainerNotFoundException" => {
return RusotoError::Service(StartAccessLoggingError::ContainerNotFound(
err.msg,
))
}
"InternalServerError" => {
return RusotoError::Service(StartAccessLoggingError::InternalServerError(
err.msg,
))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for StartAccessLoggingError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for StartAccessLoggingError {
fn description(&self) -> &str {
match *self {
StartAccessLoggingError::ContainerInUse(ref cause) => cause,
StartAccessLoggingError::ContainerNotFound(ref cause) => cause,
StartAccessLoggingError::InternalServerError(ref cause) => cause,
}
}
}
#[derive(Debug, PartialEq)]
pub enum StopAccessLoggingError {
ContainerInUse(String),
ContainerNotFound(String),
InternalServerError(String),
}
impl StopAccessLoggingError {
pub fn from_response(res: BufferedHttpResponse) -> RusotoError<StopAccessLoggingError> {
if let Some(err) = proto::json::Error::parse(&res) {
match err.typ.as_str() {
"ContainerInUseException" => {
return RusotoError::Service(StopAccessLoggingError::ContainerInUse(err.msg))
}
"ContainerNotFoundException" => {
return RusotoError::Service(StopAccessLoggingError::ContainerNotFound(err.msg))
}
"InternalServerError" => {
return RusotoError::Service(StopAccessLoggingError::InternalServerError(
err.msg,
))
}
"ValidationException" => return RusotoError::Validation(err.msg),
_ => {}
}
}
return RusotoError::Unknown(res);
}
}
impl fmt::Display for StopAccessLoggingError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for StopAccessLoggingError {
fn description(&self) -> &str {
match *self {
StopAccessLoggingError::ContainerInUse(ref cause) => cause,
StopAccessLoggingError::ContainerNotFound(ref cause) => cause,
StopAccessLoggingError::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>;
fn start_access_logging(
&self,
input: StartAccessLoggingInput,
) -> RusotoFuture<StartAccessLoggingOutput, StartAccessLoggingError>;
fn stop_access_logging(
&self,
input: StopAccessLoggingInput,
) -> RusotoFuture<StopAccessLoggingOutput, StopAccessLoggingError>;
}
#[derive(Clone)]
pub struct MediaStoreClient {
client: Client,
region: region::Region,
}
impl MediaStoreClient {
pub fn new(region: region::Region) -> MediaStoreClient {
MediaStoreClient {
client: Client::shared(),
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,
}
}
}
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));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().and_then(|response| {
proto::json::ResponsePayload::new(&response)
.deserialize::<CreateContainerOutput, _>()
}))
} 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));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().and_then(|response| {
proto::json::ResponsePayload::new(&response)
.deserialize::<DeleteContainerOutput, _>()
}))
} 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));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().and_then(|response| {
proto::json::ResponsePayload::new(&response)
.deserialize::<DeleteContainerPolicyOutput, _>()
}))
} 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));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().and_then(|response| {
proto::json::ResponsePayload::new(&response)
.deserialize::<DeleteCorsPolicyOutput, _>()
}))
} 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));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().and_then(|response| {
proto::json::ResponsePayload::new(&response)
.deserialize::<DeleteLifecyclePolicyOutput, _>()
}))
} 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));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().and_then(|response| {
proto::json::ResponsePayload::new(&response)
.deserialize::<DescribeContainerOutput, _>()
}))
} 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));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().and_then(|response| {
proto::json::ResponsePayload::new(&response)
.deserialize::<GetContainerPolicyOutput, _>()
}))
} 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));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().and_then(|response| {
proto::json::ResponsePayload::new(&response)
.deserialize::<GetCorsPolicyOutput, _>()
}))
} 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));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().and_then(|response| {
proto::json::ResponsePayload::new(&response)
.deserialize::<GetLifecyclePolicyOutput, _>()
}))
} 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));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().and_then(|response| {
proto::json::ResponsePayload::new(&response)
.deserialize::<ListContainersOutput, _>()
}))
} 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));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().and_then(|response| {
proto::json::ResponsePayload::new(&response)
.deserialize::<PutContainerPolicyOutput, _>()
}))
} 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));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().and_then(|response| {
proto::json::ResponsePayload::new(&response)
.deserialize::<PutCorsPolicyOutput, _>()
}))
} 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));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().and_then(|response| {
proto::json::ResponsePayload::new(&response)
.deserialize::<PutLifecyclePolicyOutput, _>()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(PutLifecyclePolicyError::from_response(response))),
)
}
})
}
fn start_access_logging(
&self,
input: StartAccessLoggingInput,
) -> RusotoFuture<StartAccessLoggingOutput, StartAccessLoggingError> {
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.StartAccessLogging");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().and_then(|response| {
proto::json::ResponsePayload::new(&response)
.deserialize::<StartAccessLoggingOutput, _>()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(StartAccessLoggingError::from_response(response))),
)
}
})
}
fn stop_access_logging(
&self,
input: StopAccessLoggingInput,
) -> RusotoFuture<StopAccessLoggingOutput, StopAccessLoggingError> {
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.StopAccessLogging");
let encoded = serde_json::to_string(&input).unwrap();
request.set_payload(Some(encoded));
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().and_then(|response| {
proto::json::ResponsePayload::new(&response)
.deserialize::<StopAccessLoggingOutput, _>()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(StopAccessLoggingError::from_response(response))),
)
}
})
}
}