use std::error::Error;
use std::fmt;
use std::io;
#[allow(warnings)]
use futures::future;
use futures::Future;
use rusoto_core::region;
use rusoto_core::request::{BufferedHttpResponse, DispatchSignedRequest};
use rusoto_core::{Client, RusotoFuture};
use rusoto_core::credential::{CredentialsError, ProvideAwsCredentials};
use rusoto_core::request::HttpDispatchError;
use rusoto_core::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 AccountAttribute {
#[serde(rename = "Maximum")]
#[serde(skip_serializing_if = "Option::is_none")]
pub maximum: Option<i64>,
#[serde(rename = "Name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(rename = "Used")]
#[serde(skip_serializing_if = "Option::is_none")]
pub used: Option<i64>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct AssociateNodeRequest {
#[serde(rename = "EngineAttributes")]
pub engine_attributes: Vec<EngineAttribute>,
#[serde(rename = "NodeName")]
pub node_name: String,
#[serde(rename = "ServerName")]
pub server_name: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct AssociateNodeResponse {
#[serde(rename = "NodeAssociationStatusToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub node_association_status_token: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct Backup {
#[serde(rename = "BackupArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub backup_arn: Option<String>,
#[serde(rename = "BackupId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub backup_id: Option<String>,
#[serde(rename = "BackupType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub backup_type: Option<String>,
#[serde(rename = "CreatedAt")]
#[serde(skip_serializing_if = "Option::is_none")]
pub created_at: Option<f64>,
#[serde(rename = "Description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "Engine")]
#[serde(skip_serializing_if = "Option::is_none")]
pub engine: Option<String>,
#[serde(rename = "EngineModel")]
#[serde(skip_serializing_if = "Option::is_none")]
pub engine_model: Option<String>,
#[serde(rename = "EngineVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub engine_version: Option<String>,
#[serde(rename = "InstanceProfileArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub instance_profile_arn: Option<String>,
#[serde(rename = "InstanceType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub instance_type: Option<String>,
#[serde(rename = "KeyPair")]
#[serde(skip_serializing_if = "Option::is_none")]
pub key_pair: Option<String>,
#[serde(rename = "PreferredBackupWindow")]
#[serde(skip_serializing_if = "Option::is_none")]
pub preferred_backup_window: Option<String>,
#[serde(rename = "PreferredMaintenanceWindow")]
#[serde(skip_serializing_if = "Option::is_none")]
pub preferred_maintenance_window: Option<String>,
#[serde(rename = "S3LogUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub s3_log_url: Option<String>,
#[serde(rename = "SecurityGroupIds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub security_group_ids: Option<Vec<String>>,
#[serde(rename = "ServerName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub server_name: Option<String>,
#[serde(rename = "ServiceRoleArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub service_role_arn: Option<String>,
#[serde(rename = "Status")]
#[serde(skip_serializing_if = "Option::is_none")]
pub status: Option<String>,
#[serde(rename = "StatusDescription")]
#[serde(skip_serializing_if = "Option::is_none")]
pub status_description: Option<String>,
#[serde(rename = "SubnetIds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub subnet_ids: Option<Vec<String>>,
#[serde(rename = "ToolsVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub tools_version: Option<String>,
#[serde(rename = "UserArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_arn: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct CreateBackupRequest {
#[serde(rename = "Description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "ServerName")]
pub server_name: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct CreateBackupResponse {
#[serde(rename = "Backup")]
#[serde(skip_serializing_if = "Option::is_none")]
pub backup: Option<Backup>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct CreateServerRequest {
#[serde(rename = "AssociatePublicIpAddress")]
#[serde(skip_serializing_if = "Option::is_none")]
pub associate_public_ip_address: Option<bool>,
#[serde(rename = "BackupId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub backup_id: Option<String>,
#[serde(rename = "BackupRetentionCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub backup_retention_count: Option<i64>,
#[serde(rename = "DisableAutomatedBackup")]
#[serde(skip_serializing_if = "Option::is_none")]
pub disable_automated_backup: Option<bool>,
#[serde(rename = "Engine")]
#[serde(skip_serializing_if = "Option::is_none")]
pub engine: Option<String>,
#[serde(rename = "EngineAttributes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub engine_attributes: Option<Vec<EngineAttribute>>,
#[serde(rename = "EngineModel")]
#[serde(skip_serializing_if = "Option::is_none")]
pub engine_model: Option<String>,
#[serde(rename = "EngineVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub engine_version: Option<String>,
#[serde(rename = "InstanceProfileArn")]
pub instance_profile_arn: String,
#[serde(rename = "InstanceType")]
pub instance_type: String,
#[serde(rename = "KeyPair")]
#[serde(skip_serializing_if = "Option::is_none")]
pub key_pair: Option<String>,
#[serde(rename = "PreferredBackupWindow")]
#[serde(skip_serializing_if = "Option::is_none")]
pub preferred_backup_window: Option<String>,
#[serde(rename = "PreferredMaintenanceWindow")]
#[serde(skip_serializing_if = "Option::is_none")]
pub preferred_maintenance_window: Option<String>,
#[serde(rename = "SecurityGroupIds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub security_group_ids: Option<Vec<String>>,
#[serde(rename = "ServerName")]
pub server_name: String,
#[serde(rename = "ServiceRoleArn")]
pub service_role_arn: String,
#[serde(rename = "SubnetIds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub subnet_ids: Option<Vec<String>>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct CreateServerResponse {
#[serde(rename = "Server")]
#[serde(skip_serializing_if = "Option::is_none")]
pub server: Option<Server>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DeleteBackupRequest {
#[serde(rename = "BackupId")]
pub backup_id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DeleteBackupResponse {}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DeleteServerRequest {
#[serde(rename = "ServerName")]
pub server_name: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DeleteServerResponse {}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DescribeAccountAttributesRequest {}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DescribeAccountAttributesResponse {
#[serde(rename = "Attributes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub attributes: Option<Vec<AccountAttribute>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DescribeBackupsRequest {
#[serde(rename = "BackupId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub backup_id: Option<String>,
#[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>,
#[serde(rename = "ServerName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub server_name: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DescribeBackupsResponse {
#[serde(rename = "Backups")]
#[serde(skip_serializing_if = "Option::is_none")]
pub backups: Option<Vec<Backup>>,
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DescribeEventsRequest {
#[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>,
#[serde(rename = "ServerName")]
pub server_name: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DescribeEventsResponse {
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
#[serde(rename = "ServerEvents")]
#[serde(skip_serializing_if = "Option::is_none")]
pub server_events: Option<Vec<ServerEvent>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DescribeNodeAssociationStatusRequest {
#[serde(rename = "NodeAssociationStatusToken")]
pub node_association_status_token: String,
#[serde(rename = "ServerName")]
pub server_name: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DescribeNodeAssociationStatusResponse {
#[serde(rename = "EngineAttributes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub engine_attributes: Option<Vec<EngineAttribute>>,
#[serde(rename = "NodeAssociationStatus")]
#[serde(skip_serializing_if = "Option::is_none")]
pub node_association_status: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DescribeServersRequest {
#[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>,
#[serde(rename = "ServerName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub server_name: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DescribeServersResponse {
#[serde(rename = "NextToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_token: Option<String>,
#[serde(rename = "Servers")]
#[serde(skip_serializing_if = "Option::is_none")]
pub servers: Option<Vec<Server>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DisassociateNodeRequest {
#[serde(rename = "EngineAttributes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub engine_attributes: Option<Vec<EngineAttribute>>,
#[serde(rename = "NodeName")]
pub node_name: String,
#[serde(rename = "ServerName")]
pub server_name: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct DisassociateNodeResponse {
#[serde(rename = "NodeAssociationStatusToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub node_association_status_token: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct EngineAttribute {
#[serde(rename = "Name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(rename = "Value")]
#[serde(skip_serializing_if = "Option::is_none")]
pub value: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct ExportServerEngineAttributeRequest {
#[serde(rename = "ExportAttributeName")]
pub export_attribute_name: String,
#[serde(rename = "InputAttributes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub input_attributes: Option<Vec<EngineAttribute>>,
#[serde(rename = "ServerName")]
pub server_name: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct ExportServerEngineAttributeResponse {
#[serde(rename = "EngineAttribute")]
#[serde(skip_serializing_if = "Option::is_none")]
pub engine_attribute: Option<EngineAttribute>,
#[serde(rename = "ServerName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub server_name: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct RestoreServerRequest {
#[serde(rename = "BackupId")]
pub backup_id: String,
#[serde(rename = "InstanceType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub instance_type: Option<String>,
#[serde(rename = "KeyPair")]
#[serde(skip_serializing_if = "Option::is_none")]
pub key_pair: Option<String>,
#[serde(rename = "ServerName")]
pub server_name: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct RestoreServerResponse {}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct Server {
#[serde(rename = "AssociatePublicIpAddress")]
#[serde(skip_serializing_if = "Option::is_none")]
pub associate_public_ip_address: Option<bool>,
#[serde(rename = "BackupRetentionCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub backup_retention_count: Option<i64>,
#[serde(rename = "CloudFormationStackArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub cloud_formation_stack_arn: Option<String>,
#[serde(rename = "CreatedAt")]
#[serde(skip_serializing_if = "Option::is_none")]
pub created_at: Option<f64>,
#[serde(rename = "DisableAutomatedBackup")]
#[serde(skip_serializing_if = "Option::is_none")]
pub disable_automated_backup: Option<bool>,
#[serde(rename = "Endpoint")]
#[serde(skip_serializing_if = "Option::is_none")]
pub endpoint: Option<String>,
#[serde(rename = "Engine")]
#[serde(skip_serializing_if = "Option::is_none")]
pub engine: Option<String>,
#[serde(rename = "EngineAttributes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub engine_attributes: Option<Vec<EngineAttribute>>,
#[serde(rename = "EngineModel")]
#[serde(skip_serializing_if = "Option::is_none")]
pub engine_model: Option<String>,
#[serde(rename = "EngineVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub engine_version: Option<String>,
#[serde(rename = "InstanceProfileArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub instance_profile_arn: Option<String>,
#[serde(rename = "InstanceType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub instance_type: Option<String>,
#[serde(rename = "KeyPair")]
#[serde(skip_serializing_if = "Option::is_none")]
pub key_pair: Option<String>,
#[serde(rename = "MaintenanceStatus")]
#[serde(skip_serializing_if = "Option::is_none")]
pub maintenance_status: Option<String>,
#[serde(rename = "PreferredBackupWindow")]
#[serde(skip_serializing_if = "Option::is_none")]
pub preferred_backup_window: Option<String>,
#[serde(rename = "PreferredMaintenanceWindow")]
#[serde(skip_serializing_if = "Option::is_none")]
pub preferred_maintenance_window: Option<String>,
#[serde(rename = "SecurityGroupIds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub security_group_ids: Option<Vec<String>>,
#[serde(rename = "ServerArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub server_arn: Option<String>,
#[serde(rename = "ServerName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub server_name: Option<String>,
#[serde(rename = "ServiceRoleArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub service_role_arn: Option<String>,
#[serde(rename = "Status")]
#[serde(skip_serializing_if = "Option::is_none")]
pub status: Option<String>,
#[serde(rename = "StatusReason")]
#[serde(skip_serializing_if = "Option::is_none")]
pub status_reason: Option<String>,
#[serde(rename = "SubnetIds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub subnet_ids: Option<Vec<String>>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct ServerEvent {
#[serde(rename = "CreatedAt")]
#[serde(skip_serializing_if = "Option::is_none")]
pub created_at: Option<f64>,
#[serde(rename = "LogUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub log_url: Option<String>,
#[serde(rename = "Message")]
#[serde(skip_serializing_if = "Option::is_none")]
pub message: Option<String>,
#[serde(rename = "ServerName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub server_name: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct StartMaintenanceRequest {
#[serde(rename = "EngineAttributes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub engine_attributes: Option<Vec<EngineAttribute>>,
#[serde(rename = "ServerName")]
pub server_name: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct StartMaintenanceResponse {
#[serde(rename = "Server")]
#[serde(skip_serializing_if = "Option::is_none")]
pub server: Option<Server>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct UpdateServerEngineAttributesRequest {
#[serde(rename = "AttributeName")]
pub attribute_name: String,
#[serde(rename = "AttributeValue")]
#[serde(skip_serializing_if = "Option::is_none")]
pub attribute_value: Option<String>,
#[serde(rename = "ServerName")]
pub server_name: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct UpdateServerEngineAttributesResponse {
#[serde(rename = "Server")]
#[serde(skip_serializing_if = "Option::is_none")]
pub server: Option<Server>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct UpdateServerRequest {
#[serde(rename = "BackupRetentionCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub backup_retention_count: Option<i64>,
#[serde(rename = "DisableAutomatedBackup")]
#[serde(skip_serializing_if = "Option::is_none")]
pub disable_automated_backup: Option<bool>,
#[serde(rename = "PreferredBackupWindow")]
#[serde(skip_serializing_if = "Option::is_none")]
pub preferred_backup_window: Option<String>,
#[serde(rename = "PreferredMaintenanceWindow")]
#[serde(skip_serializing_if = "Option::is_none")]
pub preferred_maintenance_window: Option<String>,
#[serde(rename = "ServerName")]
pub server_name: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct UpdateServerResponse {
#[serde(rename = "Server")]
#[serde(skip_serializing_if = "Option::is_none")]
pub server: Option<Server>,
}
#[derive(Debug, PartialEq)]
pub enum AssociateNodeError {
InvalidState(String),
ResourceNotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl AssociateNodeError {
pub fn from_response(res: BufferedHttpResponse) -> AssociateNodeError {
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 {
"InvalidStateException" => {
return AssociateNodeError::InvalidState(String::from(error_message));
}
"ResourceNotFoundException" => {
return AssociateNodeError::ResourceNotFound(String::from(error_message));
}
"ValidationException" => {
return AssociateNodeError::Validation(error_message.to_string());
}
_ => {}
}
}
return AssociateNodeError::Unknown(res);
}
}
impl From<serde_json::error::Error> for AssociateNodeError {
fn from(err: serde_json::error::Error) -> AssociateNodeError {
AssociateNodeError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for AssociateNodeError {
fn from(err: CredentialsError) -> AssociateNodeError {
AssociateNodeError::Credentials(err)
}
}
impl From<HttpDispatchError> for AssociateNodeError {
fn from(err: HttpDispatchError) -> AssociateNodeError {
AssociateNodeError::HttpDispatch(err)
}
}
impl From<io::Error> for AssociateNodeError {
fn from(err: io::Error) -> AssociateNodeError {
AssociateNodeError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for AssociateNodeError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for AssociateNodeError {
fn description(&self) -> &str {
match *self {
AssociateNodeError::InvalidState(ref cause) => cause,
AssociateNodeError::ResourceNotFound(ref cause) => cause,
AssociateNodeError::Validation(ref cause) => cause,
AssociateNodeError::Credentials(ref err) => err.description(),
AssociateNodeError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
AssociateNodeError::ParseError(ref cause) => cause,
AssociateNodeError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum CreateBackupError {
InvalidState(String),
LimitExceeded(String),
ResourceNotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl CreateBackupError {
pub fn from_response(res: BufferedHttpResponse) -> CreateBackupError {
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 {
"InvalidStateException" => {
return CreateBackupError::InvalidState(String::from(error_message));
}
"LimitExceededException" => {
return CreateBackupError::LimitExceeded(String::from(error_message));
}
"ResourceNotFoundException" => {
return CreateBackupError::ResourceNotFound(String::from(error_message));
}
"ValidationException" => {
return CreateBackupError::Validation(error_message.to_string());
}
_ => {}
}
}
return CreateBackupError::Unknown(res);
}
}
impl From<serde_json::error::Error> for CreateBackupError {
fn from(err: serde_json::error::Error) -> CreateBackupError {
CreateBackupError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for CreateBackupError {
fn from(err: CredentialsError) -> CreateBackupError {
CreateBackupError::Credentials(err)
}
}
impl From<HttpDispatchError> for CreateBackupError {
fn from(err: HttpDispatchError) -> CreateBackupError {
CreateBackupError::HttpDispatch(err)
}
}
impl From<io::Error> for CreateBackupError {
fn from(err: io::Error) -> CreateBackupError {
CreateBackupError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for CreateBackupError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for CreateBackupError {
fn description(&self) -> &str {
match *self {
CreateBackupError::InvalidState(ref cause) => cause,
CreateBackupError::LimitExceeded(ref cause) => cause,
CreateBackupError::ResourceNotFound(ref cause) => cause,
CreateBackupError::Validation(ref cause) => cause,
CreateBackupError::Credentials(ref err) => err.description(),
CreateBackupError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
CreateBackupError::ParseError(ref cause) => cause,
CreateBackupError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum CreateServerError {
LimitExceeded(String),
ResourceAlreadyExists(String),
ResourceNotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl CreateServerError {
pub fn from_response(res: BufferedHttpResponse) -> CreateServerError {
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 {
"LimitExceededException" => {
return CreateServerError::LimitExceeded(String::from(error_message));
}
"ResourceAlreadyExistsException" => {
return CreateServerError::ResourceAlreadyExists(String::from(error_message));
}
"ResourceNotFoundException" => {
return CreateServerError::ResourceNotFound(String::from(error_message));
}
"ValidationException" => {
return CreateServerError::Validation(error_message.to_string());
}
_ => {}
}
}
return CreateServerError::Unknown(res);
}
}
impl From<serde_json::error::Error> for CreateServerError {
fn from(err: serde_json::error::Error) -> CreateServerError {
CreateServerError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for CreateServerError {
fn from(err: CredentialsError) -> CreateServerError {
CreateServerError::Credentials(err)
}
}
impl From<HttpDispatchError> for CreateServerError {
fn from(err: HttpDispatchError) -> CreateServerError {
CreateServerError::HttpDispatch(err)
}
}
impl From<io::Error> for CreateServerError {
fn from(err: io::Error) -> CreateServerError {
CreateServerError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for CreateServerError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for CreateServerError {
fn description(&self) -> &str {
match *self {
CreateServerError::LimitExceeded(ref cause) => cause,
CreateServerError::ResourceAlreadyExists(ref cause) => cause,
CreateServerError::ResourceNotFound(ref cause) => cause,
CreateServerError::Validation(ref cause) => cause,
CreateServerError::Credentials(ref err) => err.description(),
CreateServerError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
CreateServerError::ParseError(ref cause) => cause,
CreateServerError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DeleteBackupError {
InvalidState(String),
ResourceNotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DeleteBackupError {
pub fn from_response(res: BufferedHttpResponse) -> DeleteBackupError {
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 {
"InvalidStateException" => {
return DeleteBackupError::InvalidState(String::from(error_message));
}
"ResourceNotFoundException" => {
return DeleteBackupError::ResourceNotFound(String::from(error_message));
}
"ValidationException" => {
return DeleteBackupError::Validation(error_message.to_string());
}
_ => {}
}
}
return DeleteBackupError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DeleteBackupError {
fn from(err: serde_json::error::Error) -> DeleteBackupError {
DeleteBackupError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DeleteBackupError {
fn from(err: CredentialsError) -> DeleteBackupError {
DeleteBackupError::Credentials(err)
}
}
impl From<HttpDispatchError> for DeleteBackupError {
fn from(err: HttpDispatchError) -> DeleteBackupError {
DeleteBackupError::HttpDispatch(err)
}
}
impl From<io::Error> for DeleteBackupError {
fn from(err: io::Error) -> DeleteBackupError {
DeleteBackupError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DeleteBackupError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DeleteBackupError {
fn description(&self) -> &str {
match *self {
DeleteBackupError::InvalidState(ref cause) => cause,
DeleteBackupError::ResourceNotFound(ref cause) => cause,
DeleteBackupError::Validation(ref cause) => cause,
DeleteBackupError::Credentials(ref err) => err.description(),
DeleteBackupError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
DeleteBackupError::ParseError(ref cause) => cause,
DeleteBackupError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DeleteServerError {
InvalidState(String),
ResourceNotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DeleteServerError {
pub fn from_response(res: BufferedHttpResponse) -> DeleteServerError {
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 {
"InvalidStateException" => {
return DeleteServerError::InvalidState(String::from(error_message));
}
"ResourceNotFoundException" => {
return DeleteServerError::ResourceNotFound(String::from(error_message));
}
"ValidationException" => {
return DeleteServerError::Validation(error_message.to_string());
}
_ => {}
}
}
return DeleteServerError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DeleteServerError {
fn from(err: serde_json::error::Error) -> DeleteServerError {
DeleteServerError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DeleteServerError {
fn from(err: CredentialsError) -> DeleteServerError {
DeleteServerError::Credentials(err)
}
}
impl From<HttpDispatchError> for DeleteServerError {
fn from(err: HttpDispatchError) -> DeleteServerError {
DeleteServerError::HttpDispatch(err)
}
}
impl From<io::Error> for DeleteServerError {
fn from(err: io::Error) -> DeleteServerError {
DeleteServerError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DeleteServerError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DeleteServerError {
fn description(&self) -> &str {
match *self {
DeleteServerError::InvalidState(ref cause) => cause,
DeleteServerError::ResourceNotFound(ref cause) => cause,
DeleteServerError::Validation(ref cause) => cause,
DeleteServerError::Credentials(ref err) => err.description(),
DeleteServerError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
DeleteServerError::ParseError(ref cause) => cause,
DeleteServerError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DescribeAccountAttributesError {
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DescribeAccountAttributesError {
pub fn from_response(res: BufferedHttpResponse) -> DescribeAccountAttributesError {
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 {
"ValidationException" => {
return DescribeAccountAttributesError::Validation(error_message.to_string());
}
_ => {}
}
}
return DescribeAccountAttributesError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DescribeAccountAttributesError {
fn from(err: serde_json::error::Error) -> DescribeAccountAttributesError {
DescribeAccountAttributesError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DescribeAccountAttributesError {
fn from(err: CredentialsError) -> DescribeAccountAttributesError {
DescribeAccountAttributesError::Credentials(err)
}
}
impl From<HttpDispatchError> for DescribeAccountAttributesError {
fn from(err: HttpDispatchError) -> DescribeAccountAttributesError {
DescribeAccountAttributesError::HttpDispatch(err)
}
}
impl From<io::Error> for DescribeAccountAttributesError {
fn from(err: io::Error) -> DescribeAccountAttributesError {
DescribeAccountAttributesError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DescribeAccountAttributesError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DescribeAccountAttributesError {
fn description(&self) -> &str {
match *self {
DescribeAccountAttributesError::Validation(ref cause) => cause,
DescribeAccountAttributesError::Credentials(ref err) => err.description(),
DescribeAccountAttributesError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
DescribeAccountAttributesError::ParseError(ref cause) => cause,
DescribeAccountAttributesError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DescribeBackupsError {
InvalidNextToken(String),
ResourceNotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DescribeBackupsError {
pub fn from_response(res: BufferedHttpResponse) -> DescribeBackupsError {
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 {
"InvalidNextTokenException" => {
return DescribeBackupsError::InvalidNextToken(String::from(error_message));
}
"ResourceNotFoundException" => {
return DescribeBackupsError::ResourceNotFound(String::from(error_message));
}
"ValidationException" => {
return DescribeBackupsError::Validation(error_message.to_string());
}
_ => {}
}
}
return DescribeBackupsError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DescribeBackupsError {
fn from(err: serde_json::error::Error) -> DescribeBackupsError {
DescribeBackupsError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DescribeBackupsError {
fn from(err: CredentialsError) -> DescribeBackupsError {
DescribeBackupsError::Credentials(err)
}
}
impl From<HttpDispatchError> for DescribeBackupsError {
fn from(err: HttpDispatchError) -> DescribeBackupsError {
DescribeBackupsError::HttpDispatch(err)
}
}
impl From<io::Error> for DescribeBackupsError {
fn from(err: io::Error) -> DescribeBackupsError {
DescribeBackupsError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DescribeBackupsError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DescribeBackupsError {
fn description(&self) -> &str {
match *self {
DescribeBackupsError::InvalidNextToken(ref cause) => cause,
DescribeBackupsError::ResourceNotFound(ref cause) => cause,
DescribeBackupsError::Validation(ref cause) => cause,
DescribeBackupsError::Credentials(ref err) => err.description(),
DescribeBackupsError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
DescribeBackupsError::ParseError(ref cause) => cause,
DescribeBackupsError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DescribeEventsError {
InvalidNextToken(String),
ResourceNotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DescribeEventsError {
pub fn from_response(res: BufferedHttpResponse) -> DescribeEventsError {
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 {
"InvalidNextTokenException" => {
return DescribeEventsError::InvalidNextToken(String::from(error_message));
}
"ResourceNotFoundException" => {
return DescribeEventsError::ResourceNotFound(String::from(error_message));
}
"ValidationException" => {
return DescribeEventsError::Validation(error_message.to_string());
}
_ => {}
}
}
return DescribeEventsError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DescribeEventsError {
fn from(err: serde_json::error::Error) -> DescribeEventsError {
DescribeEventsError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DescribeEventsError {
fn from(err: CredentialsError) -> DescribeEventsError {
DescribeEventsError::Credentials(err)
}
}
impl From<HttpDispatchError> for DescribeEventsError {
fn from(err: HttpDispatchError) -> DescribeEventsError {
DescribeEventsError::HttpDispatch(err)
}
}
impl From<io::Error> for DescribeEventsError {
fn from(err: io::Error) -> DescribeEventsError {
DescribeEventsError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DescribeEventsError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DescribeEventsError {
fn description(&self) -> &str {
match *self {
DescribeEventsError::InvalidNextToken(ref cause) => cause,
DescribeEventsError::ResourceNotFound(ref cause) => cause,
DescribeEventsError::Validation(ref cause) => cause,
DescribeEventsError::Credentials(ref err) => err.description(),
DescribeEventsError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
DescribeEventsError::ParseError(ref cause) => cause,
DescribeEventsError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DescribeNodeAssociationStatusError {
ResourceNotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DescribeNodeAssociationStatusError {
pub fn from_response(res: BufferedHttpResponse) -> DescribeNodeAssociationStatusError {
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 {
"ResourceNotFoundException" => {
return DescribeNodeAssociationStatusError::ResourceNotFound(String::from(
error_message,
));
}
"ValidationException" => {
return DescribeNodeAssociationStatusError::Validation(error_message.to_string());
}
_ => {}
}
}
return DescribeNodeAssociationStatusError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DescribeNodeAssociationStatusError {
fn from(err: serde_json::error::Error) -> DescribeNodeAssociationStatusError {
DescribeNodeAssociationStatusError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DescribeNodeAssociationStatusError {
fn from(err: CredentialsError) -> DescribeNodeAssociationStatusError {
DescribeNodeAssociationStatusError::Credentials(err)
}
}
impl From<HttpDispatchError> for DescribeNodeAssociationStatusError {
fn from(err: HttpDispatchError) -> DescribeNodeAssociationStatusError {
DescribeNodeAssociationStatusError::HttpDispatch(err)
}
}
impl From<io::Error> for DescribeNodeAssociationStatusError {
fn from(err: io::Error) -> DescribeNodeAssociationStatusError {
DescribeNodeAssociationStatusError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DescribeNodeAssociationStatusError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DescribeNodeAssociationStatusError {
fn description(&self) -> &str {
match *self {
DescribeNodeAssociationStatusError::ResourceNotFound(ref cause) => cause,
DescribeNodeAssociationStatusError::Validation(ref cause) => cause,
DescribeNodeAssociationStatusError::Credentials(ref err) => err.description(),
DescribeNodeAssociationStatusError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
DescribeNodeAssociationStatusError::ParseError(ref cause) => cause,
DescribeNodeAssociationStatusError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DescribeServersError {
InvalidNextToken(String),
ResourceNotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DescribeServersError {
pub fn from_response(res: BufferedHttpResponse) -> DescribeServersError {
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 {
"InvalidNextTokenException" => {
return DescribeServersError::InvalidNextToken(String::from(error_message));
}
"ResourceNotFoundException" => {
return DescribeServersError::ResourceNotFound(String::from(error_message));
}
"ValidationException" => {
return DescribeServersError::Validation(error_message.to_string());
}
_ => {}
}
}
return DescribeServersError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DescribeServersError {
fn from(err: serde_json::error::Error) -> DescribeServersError {
DescribeServersError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DescribeServersError {
fn from(err: CredentialsError) -> DescribeServersError {
DescribeServersError::Credentials(err)
}
}
impl From<HttpDispatchError> for DescribeServersError {
fn from(err: HttpDispatchError) -> DescribeServersError {
DescribeServersError::HttpDispatch(err)
}
}
impl From<io::Error> for DescribeServersError {
fn from(err: io::Error) -> DescribeServersError {
DescribeServersError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DescribeServersError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DescribeServersError {
fn description(&self) -> &str {
match *self {
DescribeServersError::InvalidNextToken(ref cause) => cause,
DescribeServersError::ResourceNotFound(ref cause) => cause,
DescribeServersError::Validation(ref cause) => cause,
DescribeServersError::Credentials(ref err) => err.description(),
DescribeServersError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
DescribeServersError::ParseError(ref cause) => cause,
DescribeServersError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DisassociateNodeError {
InvalidState(String),
ResourceNotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DisassociateNodeError {
pub fn from_response(res: BufferedHttpResponse) -> DisassociateNodeError {
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 {
"InvalidStateException" => {
return DisassociateNodeError::InvalidState(String::from(error_message));
}
"ResourceNotFoundException" => {
return DisassociateNodeError::ResourceNotFound(String::from(error_message));
}
"ValidationException" => {
return DisassociateNodeError::Validation(error_message.to_string());
}
_ => {}
}
}
return DisassociateNodeError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DisassociateNodeError {
fn from(err: serde_json::error::Error) -> DisassociateNodeError {
DisassociateNodeError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DisassociateNodeError {
fn from(err: CredentialsError) -> DisassociateNodeError {
DisassociateNodeError::Credentials(err)
}
}
impl From<HttpDispatchError> for DisassociateNodeError {
fn from(err: HttpDispatchError) -> DisassociateNodeError {
DisassociateNodeError::HttpDispatch(err)
}
}
impl From<io::Error> for DisassociateNodeError {
fn from(err: io::Error) -> DisassociateNodeError {
DisassociateNodeError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DisassociateNodeError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DisassociateNodeError {
fn description(&self) -> &str {
match *self {
DisassociateNodeError::InvalidState(ref cause) => cause,
DisassociateNodeError::ResourceNotFound(ref cause) => cause,
DisassociateNodeError::Validation(ref cause) => cause,
DisassociateNodeError::Credentials(ref err) => err.description(),
DisassociateNodeError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
DisassociateNodeError::ParseError(ref cause) => cause,
DisassociateNodeError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum ExportServerEngineAttributeError {
InvalidState(String),
ResourceNotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl ExportServerEngineAttributeError {
pub fn from_response(res: BufferedHttpResponse) -> ExportServerEngineAttributeError {
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 {
"InvalidStateException" => {
return ExportServerEngineAttributeError::InvalidState(String::from(
error_message,
));
}
"ResourceNotFoundException" => {
return ExportServerEngineAttributeError::ResourceNotFound(String::from(
error_message,
));
}
"ValidationException" => {
return ExportServerEngineAttributeError::Validation(error_message.to_string());
}
_ => {}
}
}
return ExportServerEngineAttributeError::Unknown(res);
}
}
impl From<serde_json::error::Error> for ExportServerEngineAttributeError {
fn from(err: serde_json::error::Error) -> ExportServerEngineAttributeError {
ExportServerEngineAttributeError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for ExportServerEngineAttributeError {
fn from(err: CredentialsError) -> ExportServerEngineAttributeError {
ExportServerEngineAttributeError::Credentials(err)
}
}
impl From<HttpDispatchError> for ExportServerEngineAttributeError {
fn from(err: HttpDispatchError) -> ExportServerEngineAttributeError {
ExportServerEngineAttributeError::HttpDispatch(err)
}
}
impl From<io::Error> for ExportServerEngineAttributeError {
fn from(err: io::Error) -> ExportServerEngineAttributeError {
ExportServerEngineAttributeError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for ExportServerEngineAttributeError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for ExportServerEngineAttributeError {
fn description(&self) -> &str {
match *self {
ExportServerEngineAttributeError::InvalidState(ref cause) => cause,
ExportServerEngineAttributeError::ResourceNotFound(ref cause) => cause,
ExportServerEngineAttributeError::Validation(ref cause) => cause,
ExportServerEngineAttributeError::Credentials(ref err) => err.description(),
ExportServerEngineAttributeError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
ExportServerEngineAttributeError::ParseError(ref cause) => cause,
ExportServerEngineAttributeError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum RestoreServerError {
InvalidState(String),
ResourceNotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl RestoreServerError {
pub fn from_response(res: BufferedHttpResponse) -> RestoreServerError {
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 {
"InvalidStateException" => {
return RestoreServerError::InvalidState(String::from(error_message));
}
"ResourceNotFoundException" => {
return RestoreServerError::ResourceNotFound(String::from(error_message));
}
"ValidationException" => {
return RestoreServerError::Validation(error_message.to_string());
}
_ => {}
}
}
return RestoreServerError::Unknown(res);
}
}
impl From<serde_json::error::Error> for RestoreServerError {
fn from(err: serde_json::error::Error) -> RestoreServerError {
RestoreServerError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for RestoreServerError {
fn from(err: CredentialsError) -> RestoreServerError {
RestoreServerError::Credentials(err)
}
}
impl From<HttpDispatchError> for RestoreServerError {
fn from(err: HttpDispatchError) -> RestoreServerError {
RestoreServerError::HttpDispatch(err)
}
}
impl From<io::Error> for RestoreServerError {
fn from(err: io::Error) -> RestoreServerError {
RestoreServerError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for RestoreServerError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for RestoreServerError {
fn description(&self) -> &str {
match *self {
RestoreServerError::InvalidState(ref cause) => cause,
RestoreServerError::ResourceNotFound(ref cause) => cause,
RestoreServerError::Validation(ref cause) => cause,
RestoreServerError::Credentials(ref err) => err.description(),
RestoreServerError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
RestoreServerError::ParseError(ref cause) => cause,
RestoreServerError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum StartMaintenanceError {
InvalidState(String),
ResourceNotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl StartMaintenanceError {
pub fn from_response(res: BufferedHttpResponse) -> StartMaintenanceError {
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 {
"InvalidStateException" => {
return StartMaintenanceError::InvalidState(String::from(error_message));
}
"ResourceNotFoundException" => {
return StartMaintenanceError::ResourceNotFound(String::from(error_message));
}
"ValidationException" => {
return StartMaintenanceError::Validation(error_message.to_string());
}
_ => {}
}
}
return StartMaintenanceError::Unknown(res);
}
}
impl From<serde_json::error::Error> for StartMaintenanceError {
fn from(err: serde_json::error::Error) -> StartMaintenanceError {
StartMaintenanceError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for StartMaintenanceError {
fn from(err: CredentialsError) -> StartMaintenanceError {
StartMaintenanceError::Credentials(err)
}
}
impl From<HttpDispatchError> for StartMaintenanceError {
fn from(err: HttpDispatchError) -> StartMaintenanceError {
StartMaintenanceError::HttpDispatch(err)
}
}
impl From<io::Error> for StartMaintenanceError {
fn from(err: io::Error) -> StartMaintenanceError {
StartMaintenanceError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for StartMaintenanceError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for StartMaintenanceError {
fn description(&self) -> &str {
match *self {
StartMaintenanceError::InvalidState(ref cause) => cause,
StartMaintenanceError::ResourceNotFound(ref cause) => cause,
StartMaintenanceError::Validation(ref cause) => cause,
StartMaintenanceError::Credentials(ref err) => err.description(),
StartMaintenanceError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
StartMaintenanceError::ParseError(ref cause) => cause,
StartMaintenanceError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum UpdateServerError {
InvalidState(String),
ResourceNotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl UpdateServerError {
pub fn from_response(res: BufferedHttpResponse) -> UpdateServerError {
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 {
"InvalidStateException" => {
return UpdateServerError::InvalidState(String::from(error_message));
}
"ResourceNotFoundException" => {
return UpdateServerError::ResourceNotFound(String::from(error_message));
}
"ValidationException" => {
return UpdateServerError::Validation(error_message.to_string());
}
_ => {}
}
}
return UpdateServerError::Unknown(res);
}
}
impl From<serde_json::error::Error> for UpdateServerError {
fn from(err: serde_json::error::Error) -> UpdateServerError {
UpdateServerError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for UpdateServerError {
fn from(err: CredentialsError) -> UpdateServerError {
UpdateServerError::Credentials(err)
}
}
impl From<HttpDispatchError> for UpdateServerError {
fn from(err: HttpDispatchError) -> UpdateServerError {
UpdateServerError::HttpDispatch(err)
}
}
impl From<io::Error> for UpdateServerError {
fn from(err: io::Error) -> UpdateServerError {
UpdateServerError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for UpdateServerError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for UpdateServerError {
fn description(&self) -> &str {
match *self {
UpdateServerError::InvalidState(ref cause) => cause,
UpdateServerError::ResourceNotFound(ref cause) => cause,
UpdateServerError::Validation(ref cause) => cause,
UpdateServerError::Credentials(ref err) => err.description(),
UpdateServerError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
UpdateServerError::ParseError(ref cause) => cause,
UpdateServerError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum UpdateServerEngineAttributesError {
InvalidState(String),
ResourceNotFound(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl UpdateServerEngineAttributesError {
pub fn from_response(res: BufferedHttpResponse) -> UpdateServerEngineAttributesError {
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 {
"InvalidStateException" => {
return UpdateServerEngineAttributesError::InvalidState(String::from(
error_message,
));
}
"ResourceNotFoundException" => {
return UpdateServerEngineAttributesError::ResourceNotFound(String::from(
error_message,
));
}
"ValidationException" => {
return UpdateServerEngineAttributesError::Validation(error_message.to_string());
}
_ => {}
}
}
return UpdateServerEngineAttributesError::Unknown(res);
}
}
impl From<serde_json::error::Error> for UpdateServerEngineAttributesError {
fn from(err: serde_json::error::Error) -> UpdateServerEngineAttributesError {
UpdateServerEngineAttributesError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for UpdateServerEngineAttributesError {
fn from(err: CredentialsError) -> UpdateServerEngineAttributesError {
UpdateServerEngineAttributesError::Credentials(err)
}
}
impl From<HttpDispatchError> for UpdateServerEngineAttributesError {
fn from(err: HttpDispatchError) -> UpdateServerEngineAttributesError {
UpdateServerEngineAttributesError::HttpDispatch(err)
}
}
impl From<io::Error> for UpdateServerEngineAttributesError {
fn from(err: io::Error) -> UpdateServerEngineAttributesError {
UpdateServerEngineAttributesError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for UpdateServerEngineAttributesError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for UpdateServerEngineAttributesError {
fn description(&self) -> &str {
match *self {
UpdateServerEngineAttributesError::InvalidState(ref cause) => cause,
UpdateServerEngineAttributesError::ResourceNotFound(ref cause) => cause,
UpdateServerEngineAttributesError::Validation(ref cause) => cause,
UpdateServerEngineAttributesError::Credentials(ref err) => err.description(),
UpdateServerEngineAttributesError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
UpdateServerEngineAttributesError::ParseError(ref cause) => cause,
UpdateServerEngineAttributesError::Unknown(_) => "unknown error",
}
}
}
pub trait OpsWorksCM {
fn associate_node(
&self,
input: AssociateNodeRequest,
) -> RusotoFuture<AssociateNodeResponse, AssociateNodeError>;
fn create_backup(
&self,
input: CreateBackupRequest,
) -> RusotoFuture<CreateBackupResponse, CreateBackupError>;
fn create_server(
&self,
input: CreateServerRequest,
) -> RusotoFuture<CreateServerResponse, CreateServerError>;
fn delete_backup(
&self,
input: DeleteBackupRequest,
) -> RusotoFuture<DeleteBackupResponse, DeleteBackupError>;
fn delete_server(
&self,
input: DeleteServerRequest,
) -> RusotoFuture<DeleteServerResponse, DeleteServerError>;
fn describe_account_attributes(
&self,
) -> RusotoFuture<DescribeAccountAttributesResponse, DescribeAccountAttributesError>;
fn describe_backups(
&self,
input: DescribeBackupsRequest,
) -> RusotoFuture<DescribeBackupsResponse, DescribeBackupsError>;
fn describe_events(
&self,
input: DescribeEventsRequest,
) -> RusotoFuture<DescribeEventsResponse, DescribeEventsError>;
fn describe_node_association_status(
&self,
input: DescribeNodeAssociationStatusRequest,
) -> RusotoFuture<DescribeNodeAssociationStatusResponse, DescribeNodeAssociationStatusError>;
fn describe_servers(
&self,
input: DescribeServersRequest,
) -> RusotoFuture<DescribeServersResponse, DescribeServersError>;
fn disassociate_node(
&self,
input: DisassociateNodeRequest,
) -> RusotoFuture<DisassociateNodeResponse, DisassociateNodeError>;
fn export_server_engine_attribute(
&self,
input: ExportServerEngineAttributeRequest,
) -> RusotoFuture<ExportServerEngineAttributeResponse, ExportServerEngineAttributeError>;
fn restore_server(
&self,
input: RestoreServerRequest,
) -> RusotoFuture<RestoreServerResponse, RestoreServerError>;
fn start_maintenance(
&self,
input: StartMaintenanceRequest,
) -> RusotoFuture<StartMaintenanceResponse, StartMaintenanceError>;
fn update_server(
&self,
input: UpdateServerRequest,
) -> RusotoFuture<UpdateServerResponse, UpdateServerError>;
fn update_server_engine_attributes(
&self,
input: UpdateServerEngineAttributesRequest,
) -> RusotoFuture<UpdateServerEngineAttributesResponse, UpdateServerEngineAttributesError>;
}
#[derive(Clone)]
pub struct OpsWorksCMClient {
client: Client,
region: region::Region,
}
impl OpsWorksCMClient {
pub fn new(region: region::Region) -> OpsWorksCMClient {
OpsWorksCMClient {
client: Client::shared(),
region: region,
}
}
pub fn new_with<P, D>(
request_dispatcher: D,
credentials_provider: P,
region: region::Region,
) -> OpsWorksCMClient
where
P: ProvideAwsCredentials + Send + Sync + 'static,
P::Future: Send,
D: DispatchSignedRequest + Send + Sync + 'static,
D::Future: Send,
{
OpsWorksCMClient {
client: Client::new_with(credentials_provider, request_dispatcher),
region: region,
}
}
}
impl OpsWorksCM for OpsWorksCMClient {
fn associate_node(
&self,
input: AssociateNodeRequest,
) -> RusotoFuture<AssociateNodeResponse, AssociateNodeError> {
let mut request = SignedRequest::new("POST", "opsworks-cm", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "OpsWorksCM_V2016_11_01.AssociateNode");
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::<AssociateNodeResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(AssociateNodeError::from_response(response))),
)
}
})
}
fn create_backup(
&self,
input: CreateBackupRequest,
) -> RusotoFuture<CreateBackupResponse, CreateBackupError> {
let mut request = SignedRequest::new("POST", "opsworks-cm", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "OpsWorksCM_V2016_11_01.CreateBackup");
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::<CreateBackupResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(CreateBackupError::from_response(response))),
)
}
})
}
fn create_server(
&self,
input: CreateServerRequest,
) -> RusotoFuture<CreateServerResponse, CreateServerError> {
let mut request = SignedRequest::new("POST", "opsworks-cm", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "OpsWorksCM_V2016_11_01.CreateServer");
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::<CreateServerResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(CreateServerError::from_response(response))),
)
}
})
}
fn delete_backup(
&self,
input: DeleteBackupRequest,
) -> RusotoFuture<DeleteBackupResponse, DeleteBackupError> {
let mut request = SignedRequest::new("POST", "opsworks-cm", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "OpsWorksCM_V2016_11_01.DeleteBackup");
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::<DeleteBackupResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DeleteBackupError::from_response(response))),
)
}
})
}
fn delete_server(
&self,
input: DeleteServerRequest,
) -> RusotoFuture<DeleteServerResponse, DeleteServerError> {
let mut request = SignedRequest::new("POST", "opsworks-cm", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "OpsWorksCM_V2016_11_01.DeleteServer");
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::<DeleteServerResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DeleteServerError::from_response(response))),
)
}
})
}
fn describe_account_attributes(
&self,
) -> RusotoFuture<DescribeAccountAttributesResponse, DescribeAccountAttributesError> {
let mut request = SignedRequest::new("POST", "opsworks-cm", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header(
"x-amz-target",
"OpsWorksCM_V2016_11_01.DescribeAccountAttributes",
);
request.set_payload(Some(b"{}".to_vec()));
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::<DescribeAccountAttributesResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(DescribeAccountAttributesError::from_response(response))
}))
}
})
}
fn describe_backups(
&self,
input: DescribeBackupsRequest,
) -> RusotoFuture<DescribeBackupsResponse, DescribeBackupsError> {
let mut request = SignedRequest::new("POST", "opsworks-cm", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "OpsWorksCM_V2016_11_01.DescribeBackups");
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::<DescribeBackupsResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DescribeBackupsError::from_response(response))),
)
}
})
}
fn describe_events(
&self,
input: DescribeEventsRequest,
) -> RusotoFuture<DescribeEventsResponse, DescribeEventsError> {
let mut request = SignedRequest::new("POST", "opsworks-cm", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "OpsWorksCM_V2016_11_01.DescribeEvents");
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::<DescribeEventsResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DescribeEventsError::from_response(response))),
)
}
})
}
fn describe_node_association_status(
&self,
input: DescribeNodeAssociationStatusRequest,
) -> RusotoFuture<DescribeNodeAssociationStatusResponse, DescribeNodeAssociationStatusError>
{
let mut request = SignedRequest::new("POST", "opsworks-cm", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header(
"x-amz-target",
"OpsWorksCM_V2016_11_01.DescribeNodeAssociationStatus",
);
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::<DescribeNodeAssociationStatusResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(DescribeNodeAssociationStatusError::from_response(response))
}))
}
})
}
fn describe_servers(
&self,
input: DescribeServersRequest,
) -> RusotoFuture<DescribeServersResponse, DescribeServersError> {
let mut request = SignedRequest::new("POST", "opsworks-cm", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "OpsWorksCM_V2016_11_01.DescribeServers");
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::<DescribeServersResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DescribeServersError::from_response(response))),
)
}
})
}
fn disassociate_node(
&self,
input: DisassociateNodeRequest,
) -> RusotoFuture<DisassociateNodeResponse, DisassociateNodeError> {
let mut request = SignedRequest::new("POST", "opsworks-cm", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "OpsWorksCM_V2016_11_01.DisassociateNode");
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::<DisassociateNodeResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DisassociateNodeError::from_response(response))),
)
}
})
}
fn export_server_engine_attribute(
&self,
input: ExportServerEngineAttributeRequest,
) -> RusotoFuture<ExportServerEngineAttributeResponse, ExportServerEngineAttributeError> {
let mut request = SignedRequest::new("POST", "opsworks-cm", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header(
"x-amz-target",
"OpsWorksCM_V2016_11_01.ExportServerEngineAttribute",
);
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::<ExportServerEngineAttributeResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(ExportServerEngineAttributeError::from_response(response))
}))
}
})
}
fn restore_server(
&self,
input: RestoreServerRequest,
) -> RusotoFuture<RestoreServerResponse, RestoreServerError> {
let mut request = SignedRequest::new("POST", "opsworks-cm", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "OpsWorksCM_V2016_11_01.RestoreServer");
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::<RestoreServerResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(RestoreServerError::from_response(response))),
)
}
})
}
fn start_maintenance(
&self,
input: StartMaintenanceRequest,
) -> RusotoFuture<StartMaintenanceResponse, StartMaintenanceError> {
let mut request = SignedRequest::new("POST", "opsworks-cm", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "OpsWorksCM_V2016_11_01.StartMaintenance");
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::<StartMaintenanceResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(StartMaintenanceError::from_response(response))),
)
}
})
}
fn update_server(
&self,
input: UpdateServerRequest,
) -> RusotoFuture<UpdateServerResponse, UpdateServerError> {
let mut request = SignedRequest::new("POST", "opsworks-cm", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header("x-amz-target", "OpsWorksCM_V2016_11_01.UpdateServer");
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::<UpdateServerResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(UpdateServerError::from_response(response))),
)
}
})
}
fn update_server_engine_attributes(
&self,
input: UpdateServerEngineAttributesRequest,
) -> RusotoFuture<UpdateServerEngineAttributesResponse, UpdateServerEngineAttributesError> {
let mut request = SignedRequest::new("POST", "opsworks-cm", &self.region, "/");
request.set_content_type("application/x-amz-json-1.1".to_owned());
request.add_header(
"x-amz-target",
"OpsWorksCM_V2016_11_01.UpdateServerEngineAttributes",
);
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::<UpdateServerEngineAttributesResponse>(
String::from_utf8_lossy(body.as_ref()).as_ref(),
)
.unwrap()
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(UpdateServerEngineAttributesError::from_response(response))
}))
}
})
}
}
#[cfg(test)]
mod protocol_tests {}