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::param::{Params, ServiceParams};
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 AccountLimit {
#[serde(rename = "CodeSizeUnzipped")]
#[serde(skip_serializing_if = "Option::is_none")]
pub code_size_unzipped: Option<i64>,
#[serde(rename = "CodeSizeZipped")]
#[serde(skip_serializing_if = "Option::is_none")]
pub code_size_zipped: Option<i64>,
#[serde(rename = "ConcurrentExecutions")]
#[serde(skip_serializing_if = "Option::is_none")]
pub concurrent_executions: Option<i64>,
#[serde(rename = "TotalCodeSize")]
#[serde(skip_serializing_if = "Option::is_none")]
pub total_code_size: Option<i64>,
#[serde(rename = "UnreservedConcurrentExecutions")]
#[serde(skip_serializing_if = "Option::is_none")]
pub unreserved_concurrent_executions: Option<i64>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct AccountUsage {
#[serde(rename = "FunctionCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub function_count: Option<i64>,
#[serde(rename = "TotalCodeSize")]
#[serde(skip_serializing_if = "Option::is_none")]
pub total_code_size: Option<i64>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct AddLayerVersionPermissionRequest {
#[serde(rename = "Action")]
pub action: String,
#[serde(rename = "LayerName")]
pub layer_name: String,
#[serde(rename = "OrganizationId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub organization_id: Option<String>,
#[serde(rename = "Principal")]
pub principal: String,
#[serde(rename = "RevisionId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub revision_id: Option<String>,
#[serde(rename = "StatementId")]
pub statement_id: String,
#[serde(rename = "VersionNumber")]
pub version_number: i64,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct AddLayerVersionPermissionResponse {
#[serde(rename = "RevisionId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub revision_id: Option<String>,
#[serde(rename = "Statement")]
#[serde(skip_serializing_if = "Option::is_none")]
pub statement: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct AddPermissionRequest {
#[serde(rename = "Action")]
pub action: String,
#[serde(rename = "EventSourceToken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub event_source_token: Option<String>,
#[serde(rename = "FunctionName")]
pub function_name: String,
#[serde(rename = "Principal")]
pub principal: String,
#[serde(rename = "Qualifier")]
#[serde(skip_serializing_if = "Option::is_none")]
pub qualifier: Option<String>,
#[serde(rename = "RevisionId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub revision_id: Option<String>,
#[serde(rename = "SourceAccount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub source_account: Option<String>,
#[serde(rename = "SourceArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub source_arn: Option<String>,
#[serde(rename = "StatementId")]
pub statement_id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct AddPermissionResponse {
#[serde(rename = "Statement")]
#[serde(skip_serializing_if = "Option::is_none")]
pub statement: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct AliasConfiguration {
#[serde(rename = "AliasArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub alias_arn: Option<String>,
#[serde(rename = "Description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "FunctionVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub function_version: Option<String>,
#[serde(rename = "Name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(rename = "RevisionId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub revision_id: Option<String>,
#[serde(rename = "RoutingConfig")]
#[serde(skip_serializing_if = "Option::is_none")]
pub routing_config: Option<AliasRoutingConfiguration>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct AliasRoutingConfiguration {
#[serde(rename = "AdditionalVersionWeights")]
#[serde(skip_serializing_if = "Option::is_none")]
pub additional_version_weights: Option<::std::collections::HashMap<String, f64>>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct Concurrency {
#[serde(rename = "ReservedConcurrentExecutions")]
#[serde(skip_serializing_if = "Option::is_none")]
pub reserved_concurrent_executions: Option<i64>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct CreateAliasRequest {
#[serde(rename = "Description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "FunctionName")]
pub function_name: String,
#[serde(rename = "FunctionVersion")]
pub function_version: String,
#[serde(rename = "Name")]
pub name: String,
#[serde(rename = "RoutingConfig")]
#[serde(skip_serializing_if = "Option::is_none")]
pub routing_config: Option<AliasRoutingConfiguration>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct CreateEventSourceMappingRequest {
#[serde(rename = "BatchSize")]
#[serde(skip_serializing_if = "Option::is_none")]
pub batch_size: Option<i64>,
#[serde(rename = "Enabled")]
#[serde(skip_serializing_if = "Option::is_none")]
pub enabled: Option<bool>,
#[serde(rename = "EventSourceArn")]
pub event_source_arn: String,
#[serde(rename = "FunctionName")]
pub function_name: String,
#[serde(rename = "StartingPosition")]
#[serde(skip_serializing_if = "Option::is_none")]
pub starting_position: Option<String>,
#[serde(rename = "StartingPositionTimestamp")]
#[serde(skip_serializing_if = "Option::is_none")]
pub starting_position_timestamp: Option<f64>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct CreateFunctionRequest {
#[serde(rename = "Code")]
pub code: FunctionCode,
#[serde(rename = "DeadLetterConfig")]
#[serde(skip_serializing_if = "Option::is_none")]
pub dead_letter_config: Option<DeadLetterConfig>,
#[serde(rename = "Description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "Environment")]
#[serde(skip_serializing_if = "Option::is_none")]
pub environment: Option<Environment>,
#[serde(rename = "FunctionName")]
pub function_name: String,
#[serde(rename = "Handler")]
pub handler: String,
#[serde(rename = "KMSKeyArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub kms_key_arn: Option<String>,
#[serde(rename = "Layers")]
#[serde(skip_serializing_if = "Option::is_none")]
pub layers: Option<Vec<String>>,
#[serde(rename = "MemorySize")]
#[serde(skip_serializing_if = "Option::is_none")]
pub memory_size: Option<i64>,
#[serde(rename = "Publish")]
#[serde(skip_serializing_if = "Option::is_none")]
pub publish: Option<bool>,
#[serde(rename = "Role")]
pub role: String,
#[serde(rename = "Runtime")]
pub runtime: String,
#[serde(rename = "Tags")]
#[serde(skip_serializing_if = "Option::is_none")]
pub tags: Option<::std::collections::HashMap<String, String>>,
#[serde(rename = "Timeout")]
#[serde(skip_serializing_if = "Option::is_none")]
pub timeout: Option<i64>,
#[serde(rename = "TracingConfig")]
#[serde(skip_serializing_if = "Option::is_none")]
pub tracing_config: Option<TracingConfig>,
#[serde(rename = "VpcConfig")]
#[serde(skip_serializing_if = "Option::is_none")]
pub vpc_config: Option<VpcConfig>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct DeadLetterConfig {
#[serde(rename = "TargetArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub target_arn: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DeleteAliasRequest {
#[serde(rename = "FunctionName")]
pub function_name: String,
#[serde(rename = "Name")]
pub name: String,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DeleteEventSourceMappingRequest {
#[serde(rename = "UUID")]
pub uuid: String,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DeleteFunctionConcurrencyRequest {
#[serde(rename = "FunctionName")]
pub function_name: String,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DeleteFunctionRequest {
#[serde(rename = "FunctionName")]
pub function_name: String,
#[serde(rename = "Qualifier")]
#[serde(skip_serializing_if = "Option::is_none")]
pub qualifier: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct DeleteLayerVersionRequest {
#[serde(rename = "LayerName")]
pub layer_name: String,
#[serde(rename = "VersionNumber")]
pub version_number: i64,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct Environment {
#[serde(rename = "Variables")]
#[serde(skip_serializing_if = "Option::is_none")]
pub variables: Option<::std::collections::HashMap<String, String>>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct EnvironmentError {
#[serde(rename = "ErrorCode")]
#[serde(skip_serializing_if = "Option::is_none")]
pub error_code: Option<String>,
#[serde(rename = "Message")]
#[serde(skip_serializing_if = "Option::is_none")]
pub message: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct EnvironmentResponse {
#[serde(rename = "Error")]
#[serde(skip_serializing_if = "Option::is_none")]
pub error: Option<EnvironmentError>,
#[serde(rename = "Variables")]
#[serde(skip_serializing_if = "Option::is_none")]
pub variables: Option<::std::collections::HashMap<String, String>>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct EventSourceMappingConfiguration {
#[serde(rename = "BatchSize")]
#[serde(skip_serializing_if = "Option::is_none")]
pub batch_size: Option<i64>,
#[serde(rename = "EventSourceArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub event_source_arn: Option<String>,
#[serde(rename = "FunctionArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub function_arn: Option<String>,
#[serde(rename = "LastModified")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_modified: Option<f64>,
#[serde(rename = "LastProcessingResult")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_processing_result: Option<String>,
#[serde(rename = "State")]
#[serde(skip_serializing_if = "Option::is_none")]
pub state: Option<String>,
#[serde(rename = "StateTransitionReason")]
#[serde(skip_serializing_if = "Option::is_none")]
pub state_transition_reason: Option<String>,
#[serde(rename = "UUID")]
#[serde(skip_serializing_if = "Option::is_none")]
pub uuid: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct FunctionCode {
#[serde(rename = "S3Bucket")]
#[serde(skip_serializing_if = "Option::is_none")]
pub s3_bucket: Option<String>,
#[serde(rename = "S3Key")]
#[serde(skip_serializing_if = "Option::is_none")]
pub s3_key: Option<String>,
#[serde(rename = "S3ObjectVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub s3_object_version: Option<String>,
#[serde(rename = "ZipFile")]
#[serde(
deserialize_with = "::rusoto_core::serialization::SerdeBlob::deserialize_blob",
serialize_with = "::rusoto_core::serialization::SerdeBlob::serialize_blob",
default
)]
#[serde(skip_serializing_if = "Option::is_none")]
pub zip_file: Option<Vec<u8>>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct FunctionCodeLocation {
#[serde(rename = "Location")]
#[serde(skip_serializing_if = "Option::is_none")]
pub location: Option<String>,
#[serde(rename = "RepositoryType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub repository_type: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct FunctionConfiguration {
#[serde(rename = "CodeSha256")]
#[serde(skip_serializing_if = "Option::is_none")]
pub code_sha_256: Option<String>,
#[serde(rename = "CodeSize")]
#[serde(skip_serializing_if = "Option::is_none")]
pub code_size: Option<i64>,
#[serde(rename = "DeadLetterConfig")]
#[serde(skip_serializing_if = "Option::is_none")]
pub dead_letter_config: Option<DeadLetterConfig>,
#[serde(rename = "Description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "Environment")]
#[serde(skip_serializing_if = "Option::is_none")]
pub environment: Option<EnvironmentResponse>,
#[serde(rename = "FunctionArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub function_arn: Option<String>,
#[serde(rename = "FunctionName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub function_name: Option<String>,
#[serde(rename = "Handler")]
#[serde(skip_serializing_if = "Option::is_none")]
pub handler: Option<String>,
#[serde(rename = "KMSKeyArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub kms_key_arn: Option<String>,
#[serde(rename = "LastModified")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_modified: Option<String>,
#[serde(rename = "Layers")]
#[serde(skip_serializing_if = "Option::is_none")]
pub layers: Option<Vec<Layer>>,
#[serde(rename = "MasterArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub master_arn: Option<String>,
#[serde(rename = "MemorySize")]
#[serde(skip_serializing_if = "Option::is_none")]
pub memory_size: Option<i64>,
#[serde(rename = "RevisionId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub revision_id: Option<String>,
#[serde(rename = "Role")]
#[serde(skip_serializing_if = "Option::is_none")]
pub role: Option<String>,
#[serde(rename = "Runtime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub runtime: Option<String>,
#[serde(rename = "Timeout")]
#[serde(skip_serializing_if = "Option::is_none")]
pub timeout: Option<i64>,
#[serde(rename = "TracingConfig")]
#[serde(skip_serializing_if = "Option::is_none")]
pub tracing_config: Option<TracingConfigResponse>,
#[serde(rename = "Version")]
#[serde(skip_serializing_if = "Option::is_none")]
pub version: Option<String>,
#[serde(rename = "VpcConfig")]
#[serde(skip_serializing_if = "Option::is_none")]
pub vpc_config: Option<VpcConfigResponse>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct GetAccountSettingsRequest {}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct GetAccountSettingsResponse {
#[serde(rename = "AccountLimit")]
#[serde(skip_serializing_if = "Option::is_none")]
pub account_limit: Option<AccountLimit>,
#[serde(rename = "AccountUsage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub account_usage: Option<AccountUsage>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct GetAliasRequest {
#[serde(rename = "FunctionName")]
pub function_name: String,
#[serde(rename = "Name")]
pub name: String,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct GetEventSourceMappingRequest {
#[serde(rename = "UUID")]
pub uuid: String,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct GetFunctionConfigurationRequest {
#[serde(rename = "FunctionName")]
pub function_name: String,
#[serde(rename = "Qualifier")]
#[serde(skip_serializing_if = "Option::is_none")]
pub qualifier: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct GetFunctionRequest {
#[serde(rename = "FunctionName")]
pub function_name: String,
#[serde(rename = "Qualifier")]
#[serde(skip_serializing_if = "Option::is_none")]
pub qualifier: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct GetFunctionResponse {
#[serde(rename = "Code")]
#[serde(skip_serializing_if = "Option::is_none")]
pub code: Option<FunctionCodeLocation>,
#[serde(rename = "Concurrency")]
#[serde(skip_serializing_if = "Option::is_none")]
pub concurrency: Option<Concurrency>,
#[serde(rename = "Configuration")]
#[serde(skip_serializing_if = "Option::is_none")]
pub configuration: Option<FunctionConfiguration>,
#[serde(rename = "Tags")]
#[serde(skip_serializing_if = "Option::is_none")]
pub tags: Option<::std::collections::HashMap<String, String>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct GetLayerVersionPolicyRequest {
#[serde(rename = "LayerName")]
pub layer_name: String,
#[serde(rename = "VersionNumber")]
pub version_number: i64,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct GetLayerVersionPolicyResponse {
#[serde(rename = "Policy")]
#[serde(skip_serializing_if = "Option::is_none")]
pub policy: Option<String>,
#[serde(rename = "RevisionId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub revision_id: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct GetLayerVersionRequest {
#[serde(rename = "LayerName")]
pub layer_name: String,
#[serde(rename = "VersionNumber")]
pub version_number: i64,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct GetLayerVersionResponse {
#[serde(rename = "CompatibleRuntimes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub compatible_runtimes: Option<Vec<String>>,
#[serde(rename = "Content")]
#[serde(skip_serializing_if = "Option::is_none")]
pub content: Option<LayerVersionContentOutput>,
#[serde(rename = "CreatedDate")]
#[serde(skip_serializing_if = "Option::is_none")]
pub created_date: Option<String>,
#[serde(rename = "Description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "LayerArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub layer_arn: Option<String>,
#[serde(rename = "LayerVersionArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub layer_version_arn: Option<String>,
#[serde(rename = "LicenseInfo")]
#[serde(skip_serializing_if = "Option::is_none")]
pub license_info: Option<String>,
#[serde(rename = "Version")]
#[serde(skip_serializing_if = "Option::is_none")]
pub version: Option<i64>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct GetPolicyRequest {
#[serde(rename = "FunctionName")]
pub function_name: String,
#[serde(rename = "Qualifier")]
#[serde(skip_serializing_if = "Option::is_none")]
pub qualifier: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct GetPolicyResponse {
#[serde(rename = "Policy")]
#[serde(skip_serializing_if = "Option::is_none")]
pub policy: Option<String>,
#[serde(rename = "RevisionId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub revision_id: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct InvocationRequest {
#[serde(rename = "ClientContext")]
#[serde(skip_serializing_if = "Option::is_none")]
pub client_context: Option<String>,
#[serde(rename = "FunctionName")]
pub function_name: String,
#[serde(rename = "InvocationType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub invocation_type: Option<String>,
#[serde(rename = "LogType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub log_type: Option<String>,
#[serde(rename = "Payload")]
#[serde(
deserialize_with = "::rusoto_core::serialization::SerdeBlob::deserialize_blob",
serialize_with = "::rusoto_core::serialization::SerdeBlob::serialize_blob",
default
)]
#[serde(skip_serializing_if = "Option::is_none")]
pub payload: Option<Vec<u8>>,
#[serde(rename = "Qualifier")]
#[serde(skip_serializing_if = "Option::is_none")]
pub qualifier: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq)]
pub struct InvocationResponse {
pub executed_version: Option<String>,
pub function_error: Option<String>,
pub log_result: Option<String>,
pub payload: Option<Vec<u8>>,
pub status_code: Option<i64>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct InvokeAsyncRequest {
#[serde(rename = "FunctionName")]
pub function_name: String,
#[serde(rename = "InvokeArgs")]
#[serde(
deserialize_with = "::rusoto_core::serialization::SerdeBlob::deserialize_blob",
serialize_with = "::rusoto_core::serialization::SerdeBlob::serialize_blob",
default
)]
pub invoke_args: Vec<u8>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct InvokeAsyncResponse {
#[serde(rename = "Status")]
#[serde(skip_serializing_if = "Option::is_none")]
pub status: Option<i64>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct Layer {
#[serde(rename = "Arn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub arn: Option<String>,
#[serde(rename = "CodeSize")]
#[serde(skip_serializing_if = "Option::is_none")]
pub code_size: Option<i64>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct LayerVersionContentInput {
#[serde(rename = "S3Bucket")]
#[serde(skip_serializing_if = "Option::is_none")]
pub s3_bucket: Option<String>,
#[serde(rename = "S3Key")]
#[serde(skip_serializing_if = "Option::is_none")]
pub s3_key: Option<String>,
#[serde(rename = "S3ObjectVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub s3_object_version: Option<String>,
#[serde(rename = "ZipFile")]
#[serde(
deserialize_with = "::rusoto_core::serialization::SerdeBlob::deserialize_blob",
serialize_with = "::rusoto_core::serialization::SerdeBlob::serialize_blob",
default
)]
#[serde(skip_serializing_if = "Option::is_none")]
pub zip_file: Option<Vec<u8>>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct LayerVersionContentOutput {
#[serde(rename = "CodeSha256")]
#[serde(skip_serializing_if = "Option::is_none")]
pub code_sha_256: Option<String>,
#[serde(rename = "CodeSize")]
#[serde(skip_serializing_if = "Option::is_none")]
pub code_size: Option<i64>,
#[serde(rename = "Location")]
#[serde(skip_serializing_if = "Option::is_none")]
pub location: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct LayerVersionsListItem {
#[serde(rename = "CompatibleRuntimes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub compatible_runtimes: Option<Vec<String>>,
#[serde(rename = "CreatedDate")]
#[serde(skip_serializing_if = "Option::is_none")]
pub created_date: Option<String>,
#[serde(rename = "Description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "LayerVersionArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub layer_version_arn: Option<String>,
#[serde(rename = "LicenseInfo")]
#[serde(skip_serializing_if = "Option::is_none")]
pub license_info: Option<String>,
#[serde(rename = "Version")]
#[serde(skip_serializing_if = "Option::is_none")]
pub version: Option<i64>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct LayersListItem {
#[serde(rename = "LatestMatchingVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub latest_matching_version: Option<LayerVersionsListItem>,
#[serde(rename = "LayerArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub layer_arn: Option<String>,
#[serde(rename = "LayerName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub layer_name: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct ListAliasesRequest {
#[serde(rename = "FunctionName")]
pub function_name: String,
#[serde(rename = "FunctionVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub function_version: Option<String>,
#[serde(rename = "Marker")]
#[serde(skip_serializing_if = "Option::is_none")]
pub marker: Option<String>,
#[serde(rename = "MaxItems")]
#[serde(skip_serializing_if = "Option::is_none")]
pub max_items: Option<i64>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct ListAliasesResponse {
#[serde(rename = "Aliases")]
#[serde(skip_serializing_if = "Option::is_none")]
pub aliases: Option<Vec<AliasConfiguration>>,
#[serde(rename = "NextMarker")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_marker: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct ListEventSourceMappingsRequest {
#[serde(rename = "EventSourceArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub event_source_arn: Option<String>,
#[serde(rename = "FunctionName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub function_name: Option<String>,
#[serde(rename = "Marker")]
#[serde(skip_serializing_if = "Option::is_none")]
pub marker: Option<String>,
#[serde(rename = "MaxItems")]
#[serde(skip_serializing_if = "Option::is_none")]
pub max_items: Option<i64>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct ListEventSourceMappingsResponse {
#[serde(rename = "EventSourceMappings")]
#[serde(skip_serializing_if = "Option::is_none")]
pub event_source_mappings: Option<Vec<EventSourceMappingConfiguration>>,
#[serde(rename = "NextMarker")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_marker: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct ListFunctionsRequest {
#[serde(rename = "FunctionVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub function_version: Option<String>,
#[serde(rename = "Marker")]
#[serde(skip_serializing_if = "Option::is_none")]
pub marker: Option<String>,
#[serde(rename = "MasterRegion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub master_region: Option<String>,
#[serde(rename = "MaxItems")]
#[serde(skip_serializing_if = "Option::is_none")]
pub max_items: Option<i64>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct ListFunctionsResponse {
#[serde(rename = "Functions")]
#[serde(skip_serializing_if = "Option::is_none")]
pub functions: Option<Vec<FunctionConfiguration>>,
#[serde(rename = "NextMarker")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_marker: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct ListLayerVersionsRequest {
#[serde(rename = "CompatibleRuntime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub compatible_runtime: Option<String>,
#[serde(rename = "LayerName")]
pub layer_name: String,
#[serde(rename = "Marker")]
#[serde(skip_serializing_if = "Option::is_none")]
pub marker: Option<String>,
#[serde(rename = "MaxItems")]
#[serde(skip_serializing_if = "Option::is_none")]
pub max_items: Option<i64>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct ListLayerVersionsResponse {
#[serde(rename = "LayerVersions")]
#[serde(skip_serializing_if = "Option::is_none")]
pub layer_versions: Option<Vec<LayerVersionsListItem>>,
#[serde(rename = "NextMarker")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_marker: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct ListLayersRequest {
#[serde(rename = "CompatibleRuntime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub compatible_runtime: Option<String>,
#[serde(rename = "Marker")]
#[serde(skip_serializing_if = "Option::is_none")]
pub marker: Option<String>,
#[serde(rename = "MaxItems")]
#[serde(skip_serializing_if = "Option::is_none")]
pub max_items: Option<i64>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct ListLayersResponse {
#[serde(rename = "Layers")]
#[serde(skip_serializing_if = "Option::is_none")]
pub layers: Option<Vec<LayersListItem>>,
#[serde(rename = "NextMarker")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_marker: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct ListTagsRequest {
#[serde(rename = "Resource")]
pub resource: String,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct ListTagsResponse {
#[serde(rename = "Tags")]
#[serde(skip_serializing_if = "Option::is_none")]
pub tags: Option<::std::collections::HashMap<String, String>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct ListVersionsByFunctionRequest {
#[serde(rename = "FunctionName")]
pub function_name: String,
#[serde(rename = "Marker")]
#[serde(skip_serializing_if = "Option::is_none")]
pub marker: Option<String>,
#[serde(rename = "MaxItems")]
#[serde(skip_serializing_if = "Option::is_none")]
pub max_items: Option<i64>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct ListVersionsByFunctionResponse {
#[serde(rename = "NextMarker")]
#[serde(skip_serializing_if = "Option::is_none")]
pub next_marker: Option<String>,
#[serde(rename = "Versions")]
#[serde(skip_serializing_if = "Option::is_none")]
pub versions: Option<Vec<FunctionConfiguration>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct PublishLayerVersionRequest {
#[serde(rename = "CompatibleRuntimes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub compatible_runtimes: Option<Vec<String>>,
#[serde(rename = "Content")]
pub content: LayerVersionContentInput,
#[serde(rename = "Description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "LayerName")]
pub layer_name: String,
#[serde(rename = "LicenseInfo")]
#[serde(skip_serializing_if = "Option::is_none")]
pub license_info: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct PublishLayerVersionResponse {
#[serde(rename = "CompatibleRuntimes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub compatible_runtimes: Option<Vec<String>>,
#[serde(rename = "Content")]
#[serde(skip_serializing_if = "Option::is_none")]
pub content: Option<LayerVersionContentOutput>,
#[serde(rename = "CreatedDate")]
#[serde(skip_serializing_if = "Option::is_none")]
pub created_date: Option<String>,
#[serde(rename = "Description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "LayerArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub layer_arn: Option<String>,
#[serde(rename = "LayerVersionArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub layer_version_arn: Option<String>,
#[serde(rename = "LicenseInfo")]
#[serde(skip_serializing_if = "Option::is_none")]
pub license_info: Option<String>,
#[serde(rename = "Version")]
#[serde(skip_serializing_if = "Option::is_none")]
pub version: Option<i64>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct PublishVersionRequest {
#[serde(rename = "CodeSha256")]
#[serde(skip_serializing_if = "Option::is_none")]
pub code_sha_256: Option<String>,
#[serde(rename = "Description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "FunctionName")]
pub function_name: String,
#[serde(rename = "RevisionId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub revision_id: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct PutFunctionConcurrencyRequest {
#[serde(rename = "FunctionName")]
pub function_name: String,
#[serde(rename = "ReservedConcurrentExecutions")]
pub reserved_concurrent_executions: i64,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct RemoveLayerVersionPermissionRequest {
#[serde(rename = "LayerName")]
pub layer_name: String,
#[serde(rename = "RevisionId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub revision_id: Option<String>,
#[serde(rename = "StatementId")]
pub statement_id: String,
#[serde(rename = "VersionNumber")]
pub version_number: i64,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct RemovePermissionRequest {
#[serde(rename = "FunctionName")]
pub function_name: String,
#[serde(rename = "Qualifier")]
#[serde(skip_serializing_if = "Option::is_none")]
pub qualifier: Option<String>,
#[serde(rename = "RevisionId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub revision_id: Option<String>,
#[serde(rename = "StatementId")]
pub statement_id: String,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct TagResourceRequest {
#[serde(rename = "Resource")]
pub resource: String,
#[serde(rename = "Tags")]
pub tags: ::std::collections::HashMap<String, String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct TracingConfig {
#[serde(rename = "Mode")]
#[serde(skip_serializing_if = "Option::is_none")]
pub mode: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Deserialize)]
#[cfg_attr(test, derive(Serialize))]
pub struct TracingConfigResponse {
#[serde(rename = "Mode")]
#[serde(skip_serializing_if = "Option::is_none")]
pub mode: Option<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct UntagResourceRequest {
#[serde(rename = "Resource")]
pub resource: String,
#[serde(rename = "TagKeys")]
pub tag_keys: Vec<String>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct UpdateAliasRequest {
#[serde(rename = "Description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "FunctionName")]
pub function_name: String,
#[serde(rename = "FunctionVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub function_version: Option<String>,
#[serde(rename = "Name")]
pub name: String,
#[serde(rename = "RevisionId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub revision_id: Option<String>,
#[serde(rename = "RoutingConfig")]
#[serde(skip_serializing_if = "Option::is_none")]
pub routing_config: Option<AliasRoutingConfiguration>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct UpdateEventSourceMappingRequest {
#[serde(rename = "BatchSize")]
#[serde(skip_serializing_if = "Option::is_none")]
pub batch_size: Option<i64>,
#[serde(rename = "Enabled")]
#[serde(skip_serializing_if = "Option::is_none")]
pub enabled: Option<bool>,
#[serde(rename = "FunctionName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub function_name: Option<String>,
#[serde(rename = "UUID")]
pub uuid: String,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct UpdateFunctionCodeRequest {
#[serde(rename = "DryRun")]
#[serde(skip_serializing_if = "Option::is_none")]
pub dry_run: Option<bool>,
#[serde(rename = "FunctionName")]
pub function_name: String,
#[serde(rename = "Publish")]
#[serde(skip_serializing_if = "Option::is_none")]
pub publish: Option<bool>,
#[serde(rename = "RevisionId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub revision_id: Option<String>,
#[serde(rename = "S3Bucket")]
#[serde(skip_serializing_if = "Option::is_none")]
pub s3_bucket: Option<String>,
#[serde(rename = "S3Key")]
#[serde(skip_serializing_if = "Option::is_none")]
pub s3_key: Option<String>,
#[serde(rename = "S3ObjectVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub s3_object_version: Option<String>,
#[serde(rename = "ZipFile")]
#[serde(
deserialize_with = "::rusoto_core::serialization::SerdeBlob::deserialize_blob",
serialize_with = "::rusoto_core::serialization::SerdeBlob::serialize_blob",
default
)]
#[serde(skip_serializing_if = "Option::is_none")]
pub zip_file: Option<Vec<u8>>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct UpdateFunctionConfigurationRequest {
#[serde(rename = "DeadLetterConfig")]
#[serde(skip_serializing_if = "Option::is_none")]
pub dead_letter_config: Option<DeadLetterConfig>,
#[serde(rename = "Description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "Environment")]
#[serde(skip_serializing_if = "Option::is_none")]
pub environment: Option<Environment>,
#[serde(rename = "FunctionName")]
pub function_name: String,
#[serde(rename = "Handler")]
#[serde(skip_serializing_if = "Option::is_none")]
pub handler: Option<String>,
#[serde(rename = "KMSKeyArn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub kms_key_arn: Option<String>,
#[serde(rename = "Layers")]
#[serde(skip_serializing_if = "Option::is_none")]
pub layers: Option<Vec<String>>,
#[serde(rename = "MemorySize")]
#[serde(skip_serializing_if = "Option::is_none")]
pub memory_size: Option<i64>,
#[serde(rename = "RevisionId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub revision_id: Option<String>,
#[serde(rename = "Role")]
#[serde(skip_serializing_if = "Option::is_none")]
pub role: Option<String>,
#[serde(rename = "Runtime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub runtime: Option<String>,
#[serde(rename = "Timeout")]
#[serde(skip_serializing_if = "Option::is_none")]
pub timeout: Option<i64>,
#[serde(rename = "TracingConfig")]
#[serde(skip_serializing_if = "Option::is_none")]
pub tracing_config: Option<TracingConfig>,
#[serde(rename = "VpcConfig")]
#[serde(skip_serializing_if = "Option::is_none")]
pub vpc_config: Option<VpcConfig>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
pub struct VpcConfig {
#[serde(rename = "SecurityGroupIds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub security_group_ids: Option<Vec<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 VpcConfigResponse {
#[serde(rename = "SecurityGroupIds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub security_group_ids: Option<Vec<String>>,
#[serde(rename = "SubnetIds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub subnet_ids: Option<Vec<String>>,
#[serde(rename = "VpcId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub vpc_id: Option<String>,
}
#[derive(Debug, PartialEq)]
pub enum AddLayerVersionPermissionError {
InvalidParameterValue(String),
PolicyLengthExceeded(String),
PreconditionFailed(String),
ResourceConflict(String),
ResourceNotFound(String),
Service(String),
TooManyRequests(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl AddLayerVersionPermissionError {
pub fn from_response(res: BufferedHttpResponse) -> AddLayerVersionPermissionError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InvalidParameterValueException" => {
return AddLayerVersionPermissionError::InvalidParameterValue(String::from(
error_message,
));
}
"PolicyLengthExceededException" => {
return AddLayerVersionPermissionError::PolicyLengthExceeded(String::from(
error_message,
));
}
"PreconditionFailedException" => {
return AddLayerVersionPermissionError::PreconditionFailed(String::from(
error_message,
));
}
"ResourceConflictException" => {
return AddLayerVersionPermissionError::ResourceConflict(String::from(
error_message,
));
}
"ResourceNotFoundException" => {
return AddLayerVersionPermissionError::ResourceNotFound(String::from(
error_message,
));
}
"ServiceException" => {
return AddLayerVersionPermissionError::Service(String::from(error_message));
}
"TooManyRequestsException" => {
return AddLayerVersionPermissionError::TooManyRequests(String::from(
error_message,
));
}
"ValidationException" => {
return AddLayerVersionPermissionError::Validation(error_message.to_string());
}
_ => {}
}
}
return AddLayerVersionPermissionError::Unknown(res);
}
}
impl From<serde_json::error::Error> for AddLayerVersionPermissionError {
fn from(err: serde_json::error::Error) -> AddLayerVersionPermissionError {
AddLayerVersionPermissionError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for AddLayerVersionPermissionError {
fn from(err: CredentialsError) -> AddLayerVersionPermissionError {
AddLayerVersionPermissionError::Credentials(err)
}
}
impl From<HttpDispatchError> for AddLayerVersionPermissionError {
fn from(err: HttpDispatchError) -> AddLayerVersionPermissionError {
AddLayerVersionPermissionError::HttpDispatch(err)
}
}
impl From<io::Error> for AddLayerVersionPermissionError {
fn from(err: io::Error) -> AddLayerVersionPermissionError {
AddLayerVersionPermissionError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for AddLayerVersionPermissionError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for AddLayerVersionPermissionError {
fn description(&self) -> &str {
match *self {
AddLayerVersionPermissionError::InvalidParameterValue(ref cause) => cause,
AddLayerVersionPermissionError::PolicyLengthExceeded(ref cause) => cause,
AddLayerVersionPermissionError::PreconditionFailed(ref cause) => cause,
AddLayerVersionPermissionError::ResourceConflict(ref cause) => cause,
AddLayerVersionPermissionError::ResourceNotFound(ref cause) => cause,
AddLayerVersionPermissionError::Service(ref cause) => cause,
AddLayerVersionPermissionError::TooManyRequests(ref cause) => cause,
AddLayerVersionPermissionError::Validation(ref cause) => cause,
AddLayerVersionPermissionError::Credentials(ref err) => err.description(),
AddLayerVersionPermissionError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
AddLayerVersionPermissionError::ParseError(ref cause) => cause,
AddLayerVersionPermissionError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum AddPermissionError {
InvalidParameterValue(String),
PolicyLengthExceeded(String),
PreconditionFailed(String),
ResourceConflict(String),
ResourceNotFound(String),
Service(String),
TooManyRequests(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl AddPermissionError {
pub fn from_response(res: BufferedHttpResponse) -> AddPermissionError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InvalidParameterValueException" => {
return AddPermissionError::InvalidParameterValue(String::from(error_message));
}
"PolicyLengthExceededException" => {
return AddPermissionError::PolicyLengthExceeded(String::from(error_message));
}
"PreconditionFailedException" => {
return AddPermissionError::PreconditionFailed(String::from(error_message));
}
"ResourceConflictException" => {
return AddPermissionError::ResourceConflict(String::from(error_message));
}
"ResourceNotFoundException" => {
return AddPermissionError::ResourceNotFound(String::from(error_message));
}
"ServiceException" => {
return AddPermissionError::Service(String::from(error_message));
}
"TooManyRequestsException" => {
return AddPermissionError::TooManyRequests(String::from(error_message));
}
"ValidationException" => {
return AddPermissionError::Validation(error_message.to_string());
}
_ => {}
}
}
return AddPermissionError::Unknown(res);
}
}
impl From<serde_json::error::Error> for AddPermissionError {
fn from(err: serde_json::error::Error) -> AddPermissionError {
AddPermissionError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for AddPermissionError {
fn from(err: CredentialsError) -> AddPermissionError {
AddPermissionError::Credentials(err)
}
}
impl From<HttpDispatchError> for AddPermissionError {
fn from(err: HttpDispatchError) -> AddPermissionError {
AddPermissionError::HttpDispatch(err)
}
}
impl From<io::Error> for AddPermissionError {
fn from(err: io::Error) -> AddPermissionError {
AddPermissionError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for AddPermissionError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for AddPermissionError {
fn description(&self) -> &str {
match *self {
AddPermissionError::InvalidParameterValue(ref cause) => cause,
AddPermissionError::PolicyLengthExceeded(ref cause) => cause,
AddPermissionError::PreconditionFailed(ref cause) => cause,
AddPermissionError::ResourceConflict(ref cause) => cause,
AddPermissionError::ResourceNotFound(ref cause) => cause,
AddPermissionError::Service(ref cause) => cause,
AddPermissionError::TooManyRequests(ref cause) => cause,
AddPermissionError::Validation(ref cause) => cause,
AddPermissionError::Credentials(ref err) => err.description(),
AddPermissionError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
AddPermissionError::ParseError(ref cause) => cause,
AddPermissionError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum CreateAliasError {
InvalidParameterValue(String),
ResourceConflict(String),
ResourceNotFound(String),
Service(String),
TooManyRequests(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl CreateAliasError {
pub fn from_response(res: BufferedHttpResponse) -> CreateAliasError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InvalidParameterValueException" => {
return CreateAliasError::InvalidParameterValue(String::from(error_message));
}
"ResourceConflictException" => {
return CreateAliasError::ResourceConflict(String::from(error_message));
}
"ResourceNotFoundException" => {
return CreateAliasError::ResourceNotFound(String::from(error_message));
}
"ServiceException" => return CreateAliasError::Service(String::from(error_message)),
"TooManyRequestsException" => {
return CreateAliasError::TooManyRequests(String::from(error_message));
}
"ValidationException" => {
return CreateAliasError::Validation(error_message.to_string());
}
_ => {}
}
}
return CreateAliasError::Unknown(res);
}
}
impl From<serde_json::error::Error> for CreateAliasError {
fn from(err: serde_json::error::Error) -> CreateAliasError {
CreateAliasError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for CreateAliasError {
fn from(err: CredentialsError) -> CreateAliasError {
CreateAliasError::Credentials(err)
}
}
impl From<HttpDispatchError> for CreateAliasError {
fn from(err: HttpDispatchError) -> CreateAliasError {
CreateAliasError::HttpDispatch(err)
}
}
impl From<io::Error> for CreateAliasError {
fn from(err: io::Error) -> CreateAliasError {
CreateAliasError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for CreateAliasError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for CreateAliasError {
fn description(&self) -> &str {
match *self {
CreateAliasError::InvalidParameterValue(ref cause) => cause,
CreateAliasError::ResourceConflict(ref cause) => cause,
CreateAliasError::ResourceNotFound(ref cause) => cause,
CreateAliasError::Service(ref cause) => cause,
CreateAliasError::TooManyRequests(ref cause) => cause,
CreateAliasError::Validation(ref cause) => cause,
CreateAliasError::Credentials(ref err) => err.description(),
CreateAliasError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
CreateAliasError::ParseError(ref cause) => cause,
CreateAliasError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum CreateEventSourceMappingError {
InvalidParameterValue(String),
ResourceConflict(String),
ResourceNotFound(String),
Service(String),
TooManyRequests(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl CreateEventSourceMappingError {
pub fn from_response(res: BufferedHttpResponse) -> CreateEventSourceMappingError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InvalidParameterValueException" => {
return CreateEventSourceMappingError::InvalidParameterValue(String::from(
error_message,
));
}
"ResourceConflictException" => {
return CreateEventSourceMappingError::ResourceConflict(String::from(
error_message,
));
}
"ResourceNotFoundException" => {
return CreateEventSourceMappingError::ResourceNotFound(String::from(
error_message,
));
}
"ServiceException" => {
return CreateEventSourceMappingError::Service(String::from(error_message));
}
"TooManyRequestsException" => {
return CreateEventSourceMappingError::TooManyRequests(String::from(
error_message,
));
}
"ValidationException" => {
return CreateEventSourceMappingError::Validation(error_message.to_string());
}
_ => {}
}
}
return CreateEventSourceMappingError::Unknown(res);
}
}
impl From<serde_json::error::Error> for CreateEventSourceMappingError {
fn from(err: serde_json::error::Error) -> CreateEventSourceMappingError {
CreateEventSourceMappingError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for CreateEventSourceMappingError {
fn from(err: CredentialsError) -> CreateEventSourceMappingError {
CreateEventSourceMappingError::Credentials(err)
}
}
impl From<HttpDispatchError> for CreateEventSourceMappingError {
fn from(err: HttpDispatchError) -> CreateEventSourceMappingError {
CreateEventSourceMappingError::HttpDispatch(err)
}
}
impl From<io::Error> for CreateEventSourceMappingError {
fn from(err: io::Error) -> CreateEventSourceMappingError {
CreateEventSourceMappingError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for CreateEventSourceMappingError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for CreateEventSourceMappingError {
fn description(&self) -> &str {
match *self {
CreateEventSourceMappingError::InvalidParameterValue(ref cause) => cause,
CreateEventSourceMappingError::ResourceConflict(ref cause) => cause,
CreateEventSourceMappingError::ResourceNotFound(ref cause) => cause,
CreateEventSourceMappingError::Service(ref cause) => cause,
CreateEventSourceMappingError::TooManyRequests(ref cause) => cause,
CreateEventSourceMappingError::Validation(ref cause) => cause,
CreateEventSourceMappingError::Credentials(ref err) => err.description(),
CreateEventSourceMappingError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
CreateEventSourceMappingError::ParseError(ref cause) => cause,
CreateEventSourceMappingError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum CreateFunctionError {
CodeStorageExceeded(String),
InvalidParameterValue(String),
ResourceConflict(String),
ResourceNotFound(String),
Service(String),
TooManyRequests(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl CreateFunctionError {
pub fn from_response(res: BufferedHttpResponse) -> CreateFunctionError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"CodeStorageExceededException" => {
return CreateFunctionError::CodeStorageExceeded(String::from(error_message));
}
"InvalidParameterValueException" => {
return CreateFunctionError::InvalidParameterValue(String::from(error_message));
}
"ResourceConflictException" => {
return CreateFunctionError::ResourceConflict(String::from(error_message));
}
"ResourceNotFoundException" => {
return CreateFunctionError::ResourceNotFound(String::from(error_message));
}
"ServiceException" => {
return CreateFunctionError::Service(String::from(error_message));
}
"TooManyRequestsException" => {
return CreateFunctionError::TooManyRequests(String::from(error_message));
}
"ValidationException" => {
return CreateFunctionError::Validation(error_message.to_string());
}
_ => {}
}
}
return CreateFunctionError::Unknown(res);
}
}
impl From<serde_json::error::Error> for CreateFunctionError {
fn from(err: serde_json::error::Error) -> CreateFunctionError {
CreateFunctionError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for CreateFunctionError {
fn from(err: CredentialsError) -> CreateFunctionError {
CreateFunctionError::Credentials(err)
}
}
impl From<HttpDispatchError> for CreateFunctionError {
fn from(err: HttpDispatchError) -> CreateFunctionError {
CreateFunctionError::HttpDispatch(err)
}
}
impl From<io::Error> for CreateFunctionError {
fn from(err: io::Error) -> CreateFunctionError {
CreateFunctionError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for CreateFunctionError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for CreateFunctionError {
fn description(&self) -> &str {
match *self {
CreateFunctionError::CodeStorageExceeded(ref cause) => cause,
CreateFunctionError::InvalidParameterValue(ref cause) => cause,
CreateFunctionError::ResourceConflict(ref cause) => cause,
CreateFunctionError::ResourceNotFound(ref cause) => cause,
CreateFunctionError::Service(ref cause) => cause,
CreateFunctionError::TooManyRequests(ref cause) => cause,
CreateFunctionError::Validation(ref cause) => cause,
CreateFunctionError::Credentials(ref err) => err.description(),
CreateFunctionError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
CreateFunctionError::ParseError(ref cause) => cause,
CreateFunctionError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DeleteAliasError {
InvalidParameterValue(String),
Service(String),
TooManyRequests(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DeleteAliasError {
pub fn from_response(res: BufferedHttpResponse) -> DeleteAliasError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InvalidParameterValueException" => {
return DeleteAliasError::InvalidParameterValue(String::from(error_message));
}
"ServiceException" => return DeleteAliasError::Service(String::from(error_message)),
"TooManyRequestsException" => {
return DeleteAliasError::TooManyRequests(String::from(error_message));
}
"ValidationException" => {
return DeleteAliasError::Validation(error_message.to_string());
}
_ => {}
}
}
return DeleteAliasError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DeleteAliasError {
fn from(err: serde_json::error::Error) -> DeleteAliasError {
DeleteAliasError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DeleteAliasError {
fn from(err: CredentialsError) -> DeleteAliasError {
DeleteAliasError::Credentials(err)
}
}
impl From<HttpDispatchError> for DeleteAliasError {
fn from(err: HttpDispatchError) -> DeleteAliasError {
DeleteAliasError::HttpDispatch(err)
}
}
impl From<io::Error> for DeleteAliasError {
fn from(err: io::Error) -> DeleteAliasError {
DeleteAliasError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DeleteAliasError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DeleteAliasError {
fn description(&self) -> &str {
match *self {
DeleteAliasError::InvalidParameterValue(ref cause) => cause,
DeleteAliasError::Service(ref cause) => cause,
DeleteAliasError::TooManyRequests(ref cause) => cause,
DeleteAliasError::Validation(ref cause) => cause,
DeleteAliasError::Credentials(ref err) => err.description(),
DeleteAliasError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
DeleteAliasError::ParseError(ref cause) => cause,
DeleteAliasError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DeleteEventSourceMappingError {
InvalidParameterValue(String),
ResourceInUse(String),
ResourceNotFound(String),
Service(String),
TooManyRequests(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DeleteEventSourceMappingError {
pub fn from_response(res: BufferedHttpResponse) -> DeleteEventSourceMappingError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InvalidParameterValueException" => {
return DeleteEventSourceMappingError::InvalidParameterValue(String::from(
error_message,
));
}
"ResourceInUseException" => {
return DeleteEventSourceMappingError::ResourceInUse(String::from(error_message));
}
"ResourceNotFoundException" => {
return DeleteEventSourceMappingError::ResourceNotFound(String::from(
error_message,
));
}
"ServiceException" => {
return DeleteEventSourceMappingError::Service(String::from(error_message));
}
"TooManyRequestsException" => {
return DeleteEventSourceMappingError::TooManyRequests(String::from(
error_message,
));
}
"ValidationException" => {
return DeleteEventSourceMappingError::Validation(error_message.to_string());
}
_ => {}
}
}
return DeleteEventSourceMappingError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DeleteEventSourceMappingError {
fn from(err: serde_json::error::Error) -> DeleteEventSourceMappingError {
DeleteEventSourceMappingError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DeleteEventSourceMappingError {
fn from(err: CredentialsError) -> DeleteEventSourceMappingError {
DeleteEventSourceMappingError::Credentials(err)
}
}
impl From<HttpDispatchError> for DeleteEventSourceMappingError {
fn from(err: HttpDispatchError) -> DeleteEventSourceMappingError {
DeleteEventSourceMappingError::HttpDispatch(err)
}
}
impl From<io::Error> for DeleteEventSourceMappingError {
fn from(err: io::Error) -> DeleteEventSourceMappingError {
DeleteEventSourceMappingError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DeleteEventSourceMappingError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DeleteEventSourceMappingError {
fn description(&self) -> &str {
match *self {
DeleteEventSourceMappingError::InvalidParameterValue(ref cause) => cause,
DeleteEventSourceMappingError::ResourceInUse(ref cause) => cause,
DeleteEventSourceMappingError::ResourceNotFound(ref cause) => cause,
DeleteEventSourceMappingError::Service(ref cause) => cause,
DeleteEventSourceMappingError::TooManyRequests(ref cause) => cause,
DeleteEventSourceMappingError::Validation(ref cause) => cause,
DeleteEventSourceMappingError::Credentials(ref err) => err.description(),
DeleteEventSourceMappingError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
DeleteEventSourceMappingError::ParseError(ref cause) => cause,
DeleteEventSourceMappingError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DeleteFunctionError {
InvalidParameterValue(String),
ResourceConflict(String),
ResourceNotFound(String),
Service(String),
TooManyRequests(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DeleteFunctionError {
pub fn from_response(res: BufferedHttpResponse) -> DeleteFunctionError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InvalidParameterValueException" => {
return DeleteFunctionError::InvalidParameterValue(String::from(error_message));
}
"ResourceConflictException" => {
return DeleteFunctionError::ResourceConflict(String::from(error_message));
}
"ResourceNotFoundException" => {
return DeleteFunctionError::ResourceNotFound(String::from(error_message));
}
"ServiceException" => {
return DeleteFunctionError::Service(String::from(error_message));
}
"TooManyRequestsException" => {
return DeleteFunctionError::TooManyRequests(String::from(error_message));
}
"ValidationException" => {
return DeleteFunctionError::Validation(error_message.to_string());
}
_ => {}
}
}
return DeleteFunctionError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DeleteFunctionError {
fn from(err: serde_json::error::Error) -> DeleteFunctionError {
DeleteFunctionError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DeleteFunctionError {
fn from(err: CredentialsError) -> DeleteFunctionError {
DeleteFunctionError::Credentials(err)
}
}
impl From<HttpDispatchError> for DeleteFunctionError {
fn from(err: HttpDispatchError) -> DeleteFunctionError {
DeleteFunctionError::HttpDispatch(err)
}
}
impl From<io::Error> for DeleteFunctionError {
fn from(err: io::Error) -> DeleteFunctionError {
DeleteFunctionError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DeleteFunctionError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DeleteFunctionError {
fn description(&self) -> &str {
match *self {
DeleteFunctionError::InvalidParameterValue(ref cause) => cause,
DeleteFunctionError::ResourceConflict(ref cause) => cause,
DeleteFunctionError::ResourceNotFound(ref cause) => cause,
DeleteFunctionError::Service(ref cause) => cause,
DeleteFunctionError::TooManyRequests(ref cause) => cause,
DeleteFunctionError::Validation(ref cause) => cause,
DeleteFunctionError::Credentials(ref err) => err.description(),
DeleteFunctionError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
DeleteFunctionError::ParseError(ref cause) => cause,
DeleteFunctionError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DeleteFunctionConcurrencyError {
InvalidParameterValue(String),
ResourceNotFound(String),
Service(String),
TooManyRequests(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DeleteFunctionConcurrencyError {
pub fn from_response(res: BufferedHttpResponse) -> DeleteFunctionConcurrencyError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InvalidParameterValueException" => {
return DeleteFunctionConcurrencyError::InvalidParameterValue(String::from(
error_message,
));
}
"ResourceNotFoundException" => {
return DeleteFunctionConcurrencyError::ResourceNotFound(String::from(
error_message,
));
}
"ServiceException" => {
return DeleteFunctionConcurrencyError::Service(String::from(error_message));
}
"TooManyRequestsException" => {
return DeleteFunctionConcurrencyError::TooManyRequests(String::from(
error_message,
));
}
"ValidationException" => {
return DeleteFunctionConcurrencyError::Validation(error_message.to_string());
}
_ => {}
}
}
return DeleteFunctionConcurrencyError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DeleteFunctionConcurrencyError {
fn from(err: serde_json::error::Error) -> DeleteFunctionConcurrencyError {
DeleteFunctionConcurrencyError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DeleteFunctionConcurrencyError {
fn from(err: CredentialsError) -> DeleteFunctionConcurrencyError {
DeleteFunctionConcurrencyError::Credentials(err)
}
}
impl From<HttpDispatchError> for DeleteFunctionConcurrencyError {
fn from(err: HttpDispatchError) -> DeleteFunctionConcurrencyError {
DeleteFunctionConcurrencyError::HttpDispatch(err)
}
}
impl From<io::Error> for DeleteFunctionConcurrencyError {
fn from(err: io::Error) -> DeleteFunctionConcurrencyError {
DeleteFunctionConcurrencyError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DeleteFunctionConcurrencyError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DeleteFunctionConcurrencyError {
fn description(&self) -> &str {
match *self {
DeleteFunctionConcurrencyError::InvalidParameterValue(ref cause) => cause,
DeleteFunctionConcurrencyError::ResourceNotFound(ref cause) => cause,
DeleteFunctionConcurrencyError::Service(ref cause) => cause,
DeleteFunctionConcurrencyError::TooManyRequests(ref cause) => cause,
DeleteFunctionConcurrencyError::Validation(ref cause) => cause,
DeleteFunctionConcurrencyError::Credentials(ref err) => err.description(),
DeleteFunctionConcurrencyError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
DeleteFunctionConcurrencyError::ParseError(ref cause) => cause,
DeleteFunctionConcurrencyError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum DeleteLayerVersionError {
Service(String),
TooManyRequests(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl DeleteLayerVersionError {
pub fn from_response(res: BufferedHttpResponse) -> DeleteLayerVersionError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"ServiceException" => {
return DeleteLayerVersionError::Service(String::from(error_message));
}
"TooManyRequestsException" => {
return DeleteLayerVersionError::TooManyRequests(String::from(error_message));
}
"ValidationException" => {
return DeleteLayerVersionError::Validation(error_message.to_string());
}
_ => {}
}
}
return DeleteLayerVersionError::Unknown(res);
}
}
impl From<serde_json::error::Error> for DeleteLayerVersionError {
fn from(err: serde_json::error::Error) -> DeleteLayerVersionError {
DeleteLayerVersionError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for DeleteLayerVersionError {
fn from(err: CredentialsError) -> DeleteLayerVersionError {
DeleteLayerVersionError::Credentials(err)
}
}
impl From<HttpDispatchError> for DeleteLayerVersionError {
fn from(err: HttpDispatchError) -> DeleteLayerVersionError {
DeleteLayerVersionError::HttpDispatch(err)
}
}
impl From<io::Error> for DeleteLayerVersionError {
fn from(err: io::Error) -> DeleteLayerVersionError {
DeleteLayerVersionError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for DeleteLayerVersionError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for DeleteLayerVersionError {
fn description(&self) -> &str {
match *self {
DeleteLayerVersionError::Service(ref cause) => cause,
DeleteLayerVersionError::TooManyRequests(ref cause) => cause,
DeleteLayerVersionError::Validation(ref cause) => cause,
DeleteLayerVersionError::Credentials(ref err) => err.description(),
DeleteLayerVersionError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
DeleteLayerVersionError::ParseError(ref cause) => cause,
DeleteLayerVersionError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum GetAccountSettingsError {
Service(String),
TooManyRequests(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl GetAccountSettingsError {
pub fn from_response(res: BufferedHttpResponse) -> GetAccountSettingsError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"ServiceException" => {
return GetAccountSettingsError::Service(String::from(error_message));
}
"TooManyRequestsException" => {
return GetAccountSettingsError::TooManyRequests(String::from(error_message));
}
"ValidationException" => {
return GetAccountSettingsError::Validation(error_message.to_string());
}
_ => {}
}
}
return GetAccountSettingsError::Unknown(res);
}
}
impl From<serde_json::error::Error> for GetAccountSettingsError {
fn from(err: serde_json::error::Error) -> GetAccountSettingsError {
GetAccountSettingsError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for GetAccountSettingsError {
fn from(err: CredentialsError) -> GetAccountSettingsError {
GetAccountSettingsError::Credentials(err)
}
}
impl From<HttpDispatchError> for GetAccountSettingsError {
fn from(err: HttpDispatchError) -> GetAccountSettingsError {
GetAccountSettingsError::HttpDispatch(err)
}
}
impl From<io::Error> for GetAccountSettingsError {
fn from(err: io::Error) -> GetAccountSettingsError {
GetAccountSettingsError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for GetAccountSettingsError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for GetAccountSettingsError {
fn description(&self) -> &str {
match *self {
GetAccountSettingsError::Service(ref cause) => cause,
GetAccountSettingsError::TooManyRequests(ref cause) => cause,
GetAccountSettingsError::Validation(ref cause) => cause,
GetAccountSettingsError::Credentials(ref err) => err.description(),
GetAccountSettingsError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
GetAccountSettingsError::ParseError(ref cause) => cause,
GetAccountSettingsError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum GetAliasError {
InvalidParameterValue(String),
ResourceNotFound(String),
Service(String),
TooManyRequests(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl GetAliasError {
pub fn from_response(res: BufferedHttpResponse) -> GetAliasError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InvalidParameterValueException" => {
return GetAliasError::InvalidParameterValue(String::from(error_message));
}
"ResourceNotFoundException" => {
return GetAliasError::ResourceNotFound(String::from(error_message));
}
"ServiceException" => return GetAliasError::Service(String::from(error_message)),
"TooManyRequestsException" => {
return GetAliasError::TooManyRequests(String::from(error_message));
}
"ValidationException" => {
return GetAliasError::Validation(error_message.to_string());
}
_ => {}
}
}
return GetAliasError::Unknown(res);
}
}
impl From<serde_json::error::Error> for GetAliasError {
fn from(err: serde_json::error::Error) -> GetAliasError {
GetAliasError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for GetAliasError {
fn from(err: CredentialsError) -> GetAliasError {
GetAliasError::Credentials(err)
}
}
impl From<HttpDispatchError> for GetAliasError {
fn from(err: HttpDispatchError) -> GetAliasError {
GetAliasError::HttpDispatch(err)
}
}
impl From<io::Error> for GetAliasError {
fn from(err: io::Error) -> GetAliasError {
GetAliasError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for GetAliasError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for GetAliasError {
fn description(&self) -> &str {
match *self {
GetAliasError::InvalidParameterValue(ref cause) => cause,
GetAliasError::ResourceNotFound(ref cause) => cause,
GetAliasError::Service(ref cause) => cause,
GetAliasError::TooManyRequests(ref cause) => cause,
GetAliasError::Validation(ref cause) => cause,
GetAliasError::Credentials(ref err) => err.description(),
GetAliasError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
GetAliasError::ParseError(ref cause) => cause,
GetAliasError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum GetEventSourceMappingError {
InvalidParameterValue(String),
ResourceNotFound(String),
Service(String),
TooManyRequests(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl GetEventSourceMappingError {
pub fn from_response(res: BufferedHttpResponse) -> GetEventSourceMappingError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InvalidParameterValueException" => {
return GetEventSourceMappingError::InvalidParameterValue(String::from(
error_message,
));
}
"ResourceNotFoundException" => {
return GetEventSourceMappingError::ResourceNotFound(String::from(error_message));
}
"ServiceException" => {
return GetEventSourceMappingError::Service(String::from(error_message));
}
"TooManyRequestsException" => {
return GetEventSourceMappingError::TooManyRequests(String::from(error_message));
}
"ValidationException" => {
return GetEventSourceMappingError::Validation(error_message.to_string());
}
_ => {}
}
}
return GetEventSourceMappingError::Unknown(res);
}
}
impl From<serde_json::error::Error> for GetEventSourceMappingError {
fn from(err: serde_json::error::Error) -> GetEventSourceMappingError {
GetEventSourceMappingError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for GetEventSourceMappingError {
fn from(err: CredentialsError) -> GetEventSourceMappingError {
GetEventSourceMappingError::Credentials(err)
}
}
impl From<HttpDispatchError> for GetEventSourceMappingError {
fn from(err: HttpDispatchError) -> GetEventSourceMappingError {
GetEventSourceMappingError::HttpDispatch(err)
}
}
impl From<io::Error> for GetEventSourceMappingError {
fn from(err: io::Error) -> GetEventSourceMappingError {
GetEventSourceMappingError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for GetEventSourceMappingError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for GetEventSourceMappingError {
fn description(&self) -> &str {
match *self {
GetEventSourceMappingError::InvalidParameterValue(ref cause) => cause,
GetEventSourceMappingError::ResourceNotFound(ref cause) => cause,
GetEventSourceMappingError::Service(ref cause) => cause,
GetEventSourceMappingError::TooManyRequests(ref cause) => cause,
GetEventSourceMappingError::Validation(ref cause) => cause,
GetEventSourceMappingError::Credentials(ref err) => err.description(),
GetEventSourceMappingError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
GetEventSourceMappingError::ParseError(ref cause) => cause,
GetEventSourceMappingError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum GetFunctionError {
InvalidParameterValue(String),
ResourceNotFound(String),
Service(String),
TooManyRequests(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl GetFunctionError {
pub fn from_response(res: BufferedHttpResponse) -> GetFunctionError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InvalidParameterValueException" => {
return GetFunctionError::InvalidParameterValue(String::from(error_message));
}
"ResourceNotFoundException" => {
return GetFunctionError::ResourceNotFound(String::from(error_message));
}
"ServiceException" => return GetFunctionError::Service(String::from(error_message)),
"TooManyRequestsException" => {
return GetFunctionError::TooManyRequests(String::from(error_message));
}
"ValidationException" => {
return GetFunctionError::Validation(error_message.to_string());
}
_ => {}
}
}
return GetFunctionError::Unknown(res);
}
}
impl From<serde_json::error::Error> for GetFunctionError {
fn from(err: serde_json::error::Error) -> GetFunctionError {
GetFunctionError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for GetFunctionError {
fn from(err: CredentialsError) -> GetFunctionError {
GetFunctionError::Credentials(err)
}
}
impl From<HttpDispatchError> for GetFunctionError {
fn from(err: HttpDispatchError) -> GetFunctionError {
GetFunctionError::HttpDispatch(err)
}
}
impl From<io::Error> for GetFunctionError {
fn from(err: io::Error) -> GetFunctionError {
GetFunctionError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for GetFunctionError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for GetFunctionError {
fn description(&self) -> &str {
match *self {
GetFunctionError::InvalidParameterValue(ref cause) => cause,
GetFunctionError::ResourceNotFound(ref cause) => cause,
GetFunctionError::Service(ref cause) => cause,
GetFunctionError::TooManyRequests(ref cause) => cause,
GetFunctionError::Validation(ref cause) => cause,
GetFunctionError::Credentials(ref err) => err.description(),
GetFunctionError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
GetFunctionError::ParseError(ref cause) => cause,
GetFunctionError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum GetFunctionConfigurationError {
InvalidParameterValue(String),
ResourceNotFound(String),
Service(String),
TooManyRequests(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl GetFunctionConfigurationError {
pub fn from_response(res: BufferedHttpResponse) -> GetFunctionConfigurationError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InvalidParameterValueException" => {
return GetFunctionConfigurationError::InvalidParameterValue(String::from(
error_message,
));
}
"ResourceNotFoundException" => {
return GetFunctionConfigurationError::ResourceNotFound(String::from(
error_message,
));
}
"ServiceException" => {
return GetFunctionConfigurationError::Service(String::from(error_message));
}
"TooManyRequestsException" => {
return GetFunctionConfigurationError::TooManyRequests(String::from(
error_message,
));
}
"ValidationException" => {
return GetFunctionConfigurationError::Validation(error_message.to_string());
}
_ => {}
}
}
return GetFunctionConfigurationError::Unknown(res);
}
}
impl From<serde_json::error::Error> for GetFunctionConfigurationError {
fn from(err: serde_json::error::Error) -> GetFunctionConfigurationError {
GetFunctionConfigurationError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for GetFunctionConfigurationError {
fn from(err: CredentialsError) -> GetFunctionConfigurationError {
GetFunctionConfigurationError::Credentials(err)
}
}
impl From<HttpDispatchError> for GetFunctionConfigurationError {
fn from(err: HttpDispatchError) -> GetFunctionConfigurationError {
GetFunctionConfigurationError::HttpDispatch(err)
}
}
impl From<io::Error> for GetFunctionConfigurationError {
fn from(err: io::Error) -> GetFunctionConfigurationError {
GetFunctionConfigurationError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for GetFunctionConfigurationError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for GetFunctionConfigurationError {
fn description(&self) -> &str {
match *self {
GetFunctionConfigurationError::InvalidParameterValue(ref cause) => cause,
GetFunctionConfigurationError::ResourceNotFound(ref cause) => cause,
GetFunctionConfigurationError::Service(ref cause) => cause,
GetFunctionConfigurationError::TooManyRequests(ref cause) => cause,
GetFunctionConfigurationError::Validation(ref cause) => cause,
GetFunctionConfigurationError::Credentials(ref err) => err.description(),
GetFunctionConfigurationError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
GetFunctionConfigurationError::ParseError(ref cause) => cause,
GetFunctionConfigurationError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum GetLayerVersionError {
InvalidParameterValue(String),
ResourceNotFound(String),
Service(String),
TooManyRequests(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl GetLayerVersionError {
pub fn from_response(res: BufferedHttpResponse) -> GetLayerVersionError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InvalidParameterValueException" => {
return GetLayerVersionError::InvalidParameterValue(String::from(error_message));
}
"ResourceNotFoundException" => {
return GetLayerVersionError::ResourceNotFound(String::from(error_message));
}
"ServiceException" => {
return GetLayerVersionError::Service(String::from(error_message));
}
"TooManyRequestsException" => {
return GetLayerVersionError::TooManyRequests(String::from(error_message));
}
"ValidationException" => {
return GetLayerVersionError::Validation(error_message.to_string());
}
_ => {}
}
}
return GetLayerVersionError::Unknown(res);
}
}
impl From<serde_json::error::Error> for GetLayerVersionError {
fn from(err: serde_json::error::Error) -> GetLayerVersionError {
GetLayerVersionError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for GetLayerVersionError {
fn from(err: CredentialsError) -> GetLayerVersionError {
GetLayerVersionError::Credentials(err)
}
}
impl From<HttpDispatchError> for GetLayerVersionError {
fn from(err: HttpDispatchError) -> GetLayerVersionError {
GetLayerVersionError::HttpDispatch(err)
}
}
impl From<io::Error> for GetLayerVersionError {
fn from(err: io::Error) -> GetLayerVersionError {
GetLayerVersionError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for GetLayerVersionError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for GetLayerVersionError {
fn description(&self) -> &str {
match *self {
GetLayerVersionError::InvalidParameterValue(ref cause) => cause,
GetLayerVersionError::ResourceNotFound(ref cause) => cause,
GetLayerVersionError::Service(ref cause) => cause,
GetLayerVersionError::TooManyRequests(ref cause) => cause,
GetLayerVersionError::Validation(ref cause) => cause,
GetLayerVersionError::Credentials(ref err) => err.description(),
GetLayerVersionError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
GetLayerVersionError::ParseError(ref cause) => cause,
GetLayerVersionError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum GetLayerVersionPolicyError {
InvalidParameterValue(String),
ResourceNotFound(String),
Service(String),
TooManyRequests(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl GetLayerVersionPolicyError {
pub fn from_response(res: BufferedHttpResponse) -> GetLayerVersionPolicyError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InvalidParameterValueException" => {
return GetLayerVersionPolicyError::InvalidParameterValue(String::from(
error_message,
));
}
"ResourceNotFoundException" => {
return GetLayerVersionPolicyError::ResourceNotFound(String::from(error_message));
}
"ServiceException" => {
return GetLayerVersionPolicyError::Service(String::from(error_message));
}
"TooManyRequestsException" => {
return GetLayerVersionPolicyError::TooManyRequests(String::from(error_message));
}
"ValidationException" => {
return GetLayerVersionPolicyError::Validation(error_message.to_string());
}
_ => {}
}
}
return GetLayerVersionPolicyError::Unknown(res);
}
}
impl From<serde_json::error::Error> for GetLayerVersionPolicyError {
fn from(err: serde_json::error::Error) -> GetLayerVersionPolicyError {
GetLayerVersionPolicyError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for GetLayerVersionPolicyError {
fn from(err: CredentialsError) -> GetLayerVersionPolicyError {
GetLayerVersionPolicyError::Credentials(err)
}
}
impl From<HttpDispatchError> for GetLayerVersionPolicyError {
fn from(err: HttpDispatchError) -> GetLayerVersionPolicyError {
GetLayerVersionPolicyError::HttpDispatch(err)
}
}
impl From<io::Error> for GetLayerVersionPolicyError {
fn from(err: io::Error) -> GetLayerVersionPolicyError {
GetLayerVersionPolicyError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for GetLayerVersionPolicyError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for GetLayerVersionPolicyError {
fn description(&self) -> &str {
match *self {
GetLayerVersionPolicyError::InvalidParameterValue(ref cause) => cause,
GetLayerVersionPolicyError::ResourceNotFound(ref cause) => cause,
GetLayerVersionPolicyError::Service(ref cause) => cause,
GetLayerVersionPolicyError::TooManyRequests(ref cause) => cause,
GetLayerVersionPolicyError::Validation(ref cause) => cause,
GetLayerVersionPolicyError::Credentials(ref err) => err.description(),
GetLayerVersionPolicyError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
GetLayerVersionPolicyError::ParseError(ref cause) => cause,
GetLayerVersionPolicyError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum GetPolicyError {
InvalidParameterValue(String),
ResourceNotFound(String),
Service(String),
TooManyRequests(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl GetPolicyError {
pub fn from_response(res: BufferedHttpResponse) -> GetPolicyError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InvalidParameterValueException" => {
return GetPolicyError::InvalidParameterValue(String::from(error_message));
}
"ResourceNotFoundException" => {
return GetPolicyError::ResourceNotFound(String::from(error_message));
}
"ServiceException" => return GetPolicyError::Service(String::from(error_message)),
"TooManyRequestsException" => {
return GetPolicyError::TooManyRequests(String::from(error_message));
}
"ValidationException" => {
return GetPolicyError::Validation(error_message.to_string());
}
_ => {}
}
}
return GetPolicyError::Unknown(res);
}
}
impl From<serde_json::error::Error> for GetPolicyError {
fn from(err: serde_json::error::Error) -> GetPolicyError {
GetPolicyError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for GetPolicyError {
fn from(err: CredentialsError) -> GetPolicyError {
GetPolicyError::Credentials(err)
}
}
impl From<HttpDispatchError> for GetPolicyError {
fn from(err: HttpDispatchError) -> GetPolicyError {
GetPolicyError::HttpDispatch(err)
}
}
impl From<io::Error> for GetPolicyError {
fn from(err: io::Error) -> GetPolicyError {
GetPolicyError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for GetPolicyError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for GetPolicyError {
fn description(&self) -> &str {
match *self {
GetPolicyError::InvalidParameterValue(ref cause) => cause,
GetPolicyError::ResourceNotFound(ref cause) => cause,
GetPolicyError::Service(ref cause) => cause,
GetPolicyError::TooManyRequests(ref cause) => cause,
GetPolicyError::Validation(ref cause) => cause,
GetPolicyError::Credentials(ref err) => err.description(),
GetPolicyError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
GetPolicyError::ParseError(ref cause) => cause,
GetPolicyError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum InvokeError {
EC2AccessDenied(String),
EC2Throttled(String),
EC2Unexpected(String),
ENILimitReached(String),
InvalidParameterValue(String),
InvalidRequestContent(String),
InvalidRuntime(String),
InvalidSecurityGroupID(String),
InvalidSubnetID(String),
InvalidZipFile(String),
KMSAccessDenied(String),
KMSDisabled(String),
KMSInvalidState(String),
KMSNotFound(String),
RequestTooLarge(String),
ResourceNotFound(String),
Service(String),
SubnetIPAddressLimitReached(String),
TooManyRequests(String),
UnsupportedMediaType(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl InvokeError {
pub fn from_response(res: BufferedHttpResponse) -> InvokeError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"EC2AccessDeniedException" => {
return InvokeError::EC2AccessDenied(String::from(error_message));
}
"EC2ThrottledException" => {
return InvokeError::EC2Throttled(String::from(error_message));
}
"EC2UnexpectedException" => {
return InvokeError::EC2Unexpected(String::from(error_message));
}
"ENILimitReachedException" => {
return InvokeError::ENILimitReached(String::from(error_message));
}
"InvalidParameterValueException" => {
return InvokeError::InvalidParameterValue(String::from(error_message));
}
"InvalidRequestContentException" => {
return InvokeError::InvalidRequestContent(String::from(error_message));
}
"InvalidRuntimeException" => {
return InvokeError::InvalidRuntime(String::from(error_message));
}
"InvalidSecurityGroupIDException" => {
return InvokeError::InvalidSecurityGroupID(String::from(error_message));
}
"InvalidSubnetIDException" => {
return InvokeError::InvalidSubnetID(String::from(error_message));
}
"InvalidZipFileException" => {
return InvokeError::InvalidZipFile(String::from(error_message));
}
"KMSAccessDeniedException" => {
return InvokeError::KMSAccessDenied(String::from(error_message));
}
"KMSDisabledException" => {
return InvokeError::KMSDisabled(String::from(error_message));
}
"KMSInvalidStateException" => {
return InvokeError::KMSInvalidState(String::from(error_message));
}
"KMSNotFoundException" => {
return InvokeError::KMSNotFound(String::from(error_message));
}
"RequestTooLargeException" => {
return InvokeError::RequestTooLarge(String::from(error_message));
}
"ResourceNotFoundException" => {
return InvokeError::ResourceNotFound(String::from(error_message));
}
"ServiceException" => return InvokeError::Service(String::from(error_message)),
"SubnetIPAddressLimitReachedException" => {
return InvokeError::SubnetIPAddressLimitReached(String::from(error_message));
}
"TooManyRequestsException" => {
return InvokeError::TooManyRequests(String::from(error_message));
}
"UnsupportedMediaTypeException" => {
return InvokeError::UnsupportedMediaType(String::from(error_message));
}
"ValidationException" => return InvokeError::Validation(error_message.to_string()),
_ => {}
}
}
return InvokeError::Unknown(res);
}
}
impl From<serde_json::error::Error> for InvokeError {
fn from(err: serde_json::error::Error) -> InvokeError {
InvokeError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for InvokeError {
fn from(err: CredentialsError) -> InvokeError {
InvokeError::Credentials(err)
}
}
impl From<HttpDispatchError> for InvokeError {
fn from(err: HttpDispatchError) -> InvokeError {
InvokeError::HttpDispatch(err)
}
}
impl From<io::Error> for InvokeError {
fn from(err: io::Error) -> InvokeError {
InvokeError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for InvokeError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for InvokeError {
fn description(&self) -> &str {
match *self {
InvokeError::EC2AccessDenied(ref cause) => cause,
InvokeError::EC2Throttled(ref cause) => cause,
InvokeError::EC2Unexpected(ref cause) => cause,
InvokeError::ENILimitReached(ref cause) => cause,
InvokeError::InvalidParameterValue(ref cause) => cause,
InvokeError::InvalidRequestContent(ref cause) => cause,
InvokeError::InvalidRuntime(ref cause) => cause,
InvokeError::InvalidSecurityGroupID(ref cause) => cause,
InvokeError::InvalidSubnetID(ref cause) => cause,
InvokeError::InvalidZipFile(ref cause) => cause,
InvokeError::KMSAccessDenied(ref cause) => cause,
InvokeError::KMSDisabled(ref cause) => cause,
InvokeError::KMSInvalidState(ref cause) => cause,
InvokeError::KMSNotFound(ref cause) => cause,
InvokeError::RequestTooLarge(ref cause) => cause,
InvokeError::ResourceNotFound(ref cause) => cause,
InvokeError::Service(ref cause) => cause,
InvokeError::SubnetIPAddressLimitReached(ref cause) => cause,
InvokeError::TooManyRequests(ref cause) => cause,
InvokeError::UnsupportedMediaType(ref cause) => cause,
InvokeError::Validation(ref cause) => cause,
InvokeError::Credentials(ref err) => err.description(),
InvokeError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
InvokeError::ParseError(ref cause) => cause,
InvokeError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum InvokeAsyncError {
InvalidRequestContent(String),
InvalidRuntime(String),
ResourceNotFound(String),
Service(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl InvokeAsyncError {
pub fn from_response(res: BufferedHttpResponse) -> InvokeAsyncError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InvalidRequestContentException" => {
return InvokeAsyncError::InvalidRequestContent(String::from(error_message));
}
"InvalidRuntimeException" => {
return InvokeAsyncError::InvalidRuntime(String::from(error_message));
}
"ResourceNotFoundException" => {
return InvokeAsyncError::ResourceNotFound(String::from(error_message));
}
"ServiceException" => return InvokeAsyncError::Service(String::from(error_message)),
"ValidationException" => {
return InvokeAsyncError::Validation(error_message.to_string());
}
_ => {}
}
}
return InvokeAsyncError::Unknown(res);
}
}
impl From<serde_json::error::Error> for InvokeAsyncError {
fn from(err: serde_json::error::Error) -> InvokeAsyncError {
InvokeAsyncError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for InvokeAsyncError {
fn from(err: CredentialsError) -> InvokeAsyncError {
InvokeAsyncError::Credentials(err)
}
}
impl From<HttpDispatchError> for InvokeAsyncError {
fn from(err: HttpDispatchError) -> InvokeAsyncError {
InvokeAsyncError::HttpDispatch(err)
}
}
impl From<io::Error> for InvokeAsyncError {
fn from(err: io::Error) -> InvokeAsyncError {
InvokeAsyncError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for InvokeAsyncError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for InvokeAsyncError {
fn description(&self) -> &str {
match *self {
InvokeAsyncError::InvalidRequestContent(ref cause) => cause,
InvokeAsyncError::InvalidRuntime(ref cause) => cause,
InvokeAsyncError::ResourceNotFound(ref cause) => cause,
InvokeAsyncError::Service(ref cause) => cause,
InvokeAsyncError::Validation(ref cause) => cause,
InvokeAsyncError::Credentials(ref err) => err.description(),
InvokeAsyncError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
InvokeAsyncError::ParseError(ref cause) => cause,
InvokeAsyncError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum ListAliasesError {
InvalidParameterValue(String),
ResourceNotFound(String),
Service(String),
TooManyRequests(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl ListAliasesError {
pub fn from_response(res: BufferedHttpResponse) -> ListAliasesError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InvalidParameterValueException" => {
return ListAliasesError::InvalidParameterValue(String::from(error_message));
}
"ResourceNotFoundException" => {
return ListAliasesError::ResourceNotFound(String::from(error_message));
}
"ServiceException" => return ListAliasesError::Service(String::from(error_message)),
"TooManyRequestsException" => {
return ListAliasesError::TooManyRequests(String::from(error_message));
}
"ValidationException" => {
return ListAliasesError::Validation(error_message.to_string());
}
_ => {}
}
}
return ListAliasesError::Unknown(res);
}
}
impl From<serde_json::error::Error> for ListAliasesError {
fn from(err: serde_json::error::Error) -> ListAliasesError {
ListAliasesError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for ListAliasesError {
fn from(err: CredentialsError) -> ListAliasesError {
ListAliasesError::Credentials(err)
}
}
impl From<HttpDispatchError> for ListAliasesError {
fn from(err: HttpDispatchError) -> ListAliasesError {
ListAliasesError::HttpDispatch(err)
}
}
impl From<io::Error> for ListAliasesError {
fn from(err: io::Error) -> ListAliasesError {
ListAliasesError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for ListAliasesError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for ListAliasesError {
fn description(&self) -> &str {
match *self {
ListAliasesError::InvalidParameterValue(ref cause) => cause,
ListAliasesError::ResourceNotFound(ref cause) => cause,
ListAliasesError::Service(ref cause) => cause,
ListAliasesError::TooManyRequests(ref cause) => cause,
ListAliasesError::Validation(ref cause) => cause,
ListAliasesError::Credentials(ref err) => err.description(),
ListAliasesError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
ListAliasesError::ParseError(ref cause) => cause,
ListAliasesError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum ListEventSourceMappingsError {
InvalidParameterValue(String),
ResourceNotFound(String),
Service(String),
TooManyRequests(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl ListEventSourceMappingsError {
pub fn from_response(res: BufferedHttpResponse) -> ListEventSourceMappingsError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InvalidParameterValueException" => {
return ListEventSourceMappingsError::InvalidParameterValue(String::from(
error_message,
));
}
"ResourceNotFoundException" => {
return ListEventSourceMappingsError::ResourceNotFound(String::from(
error_message,
));
}
"ServiceException" => {
return ListEventSourceMappingsError::Service(String::from(error_message));
}
"TooManyRequestsException" => {
return ListEventSourceMappingsError::TooManyRequests(String::from(
error_message,
));
}
"ValidationException" => {
return ListEventSourceMappingsError::Validation(error_message.to_string());
}
_ => {}
}
}
return ListEventSourceMappingsError::Unknown(res);
}
}
impl From<serde_json::error::Error> for ListEventSourceMappingsError {
fn from(err: serde_json::error::Error) -> ListEventSourceMappingsError {
ListEventSourceMappingsError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for ListEventSourceMappingsError {
fn from(err: CredentialsError) -> ListEventSourceMappingsError {
ListEventSourceMappingsError::Credentials(err)
}
}
impl From<HttpDispatchError> for ListEventSourceMappingsError {
fn from(err: HttpDispatchError) -> ListEventSourceMappingsError {
ListEventSourceMappingsError::HttpDispatch(err)
}
}
impl From<io::Error> for ListEventSourceMappingsError {
fn from(err: io::Error) -> ListEventSourceMappingsError {
ListEventSourceMappingsError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for ListEventSourceMappingsError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for ListEventSourceMappingsError {
fn description(&self) -> &str {
match *self {
ListEventSourceMappingsError::InvalidParameterValue(ref cause) => cause,
ListEventSourceMappingsError::ResourceNotFound(ref cause) => cause,
ListEventSourceMappingsError::Service(ref cause) => cause,
ListEventSourceMappingsError::TooManyRequests(ref cause) => cause,
ListEventSourceMappingsError::Validation(ref cause) => cause,
ListEventSourceMappingsError::Credentials(ref err) => err.description(),
ListEventSourceMappingsError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
ListEventSourceMappingsError::ParseError(ref cause) => cause,
ListEventSourceMappingsError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum ListFunctionsError {
InvalidParameterValue(String),
Service(String),
TooManyRequests(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl ListFunctionsError {
pub fn from_response(res: BufferedHttpResponse) -> ListFunctionsError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InvalidParameterValueException" => {
return ListFunctionsError::InvalidParameterValue(String::from(error_message));
}
"ServiceException" => {
return ListFunctionsError::Service(String::from(error_message));
}
"TooManyRequestsException" => {
return ListFunctionsError::TooManyRequests(String::from(error_message));
}
"ValidationException" => {
return ListFunctionsError::Validation(error_message.to_string());
}
_ => {}
}
}
return ListFunctionsError::Unknown(res);
}
}
impl From<serde_json::error::Error> for ListFunctionsError {
fn from(err: serde_json::error::Error) -> ListFunctionsError {
ListFunctionsError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for ListFunctionsError {
fn from(err: CredentialsError) -> ListFunctionsError {
ListFunctionsError::Credentials(err)
}
}
impl From<HttpDispatchError> for ListFunctionsError {
fn from(err: HttpDispatchError) -> ListFunctionsError {
ListFunctionsError::HttpDispatch(err)
}
}
impl From<io::Error> for ListFunctionsError {
fn from(err: io::Error) -> ListFunctionsError {
ListFunctionsError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for ListFunctionsError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for ListFunctionsError {
fn description(&self) -> &str {
match *self {
ListFunctionsError::InvalidParameterValue(ref cause) => cause,
ListFunctionsError::Service(ref cause) => cause,
ListFunctionsError::TooManyRequests(ref cause) => cause,
ListFunctionsError::Validation(ref cause) => cause,
ListFunctionsError::Credentials(ref err) => err.description(),
ListFunctionsError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
ListFunctionsError::ParseError(ref cause) => cause,
ListFunctionsError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum ListLayerVersionsError {
InvalidParameterValue(String),
ResourceNotFound(String),
Service(String),
TooManyRequests(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl ListLayerVersionsError {
pub fn from_response(res: BufferedHttpResponse) -> ListLayerVersionsError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InvalidParameterValueException" => {
return ListLayerVersionsError::InvalidParameterValue(String::from(
error_message,
));
}
"ResourceNotFoundException" => {
return ListLayerVersionsError::ResourceNotFound(String::from(error_message));
}
"ServiceException" => {
return ListLayerVersionsError::Service(String::from(error_message));
}
"TooManyRequestsException" => {
return ListLayerVersionsError::TooManyRequests(String::from(error_message));
}
"ValidationException" => {
return ListLayerVersionsError::Validation(error_message.to_string());
}
_ => {}
}
}
return ListLayerVersionsError::Unknown(res);
}
}
impl From<serde_json::error::Error> for ListLayerVersionsError {
fn from(err: serde_json::error::Error) -> ListLayerVersionsError {
ListLayerVersionsError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for ListLayerVersionsError {
fn from(err: CredentialsError) -> ListLayerVersionsError {
ListLayerVersionsError::Credentials(err)
}
}
impl From<HttpDispatchError> for ListLayerVersionsError {
fn from(err: HttpDispatchError) -> ListLayerVersionsError {
ListLayerVersionsError::HttpDispatch(err)
}
}
impl From<io::Error> for ListLayerVersionsError {
fn from(err: io::Error) -> ListLayerVersionsError {
ListLayerVersionsError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for ListLayerVersionsError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for ListLayerVersionsError {
fn description(&self) -> &str {
match *self {
ListLayerVersionsError::InvalidParameterValue(ref cause) => cause,
ListLayerVersionsError::ResourceNotFound(ref cause) => cause,
ListLayerVersionsError::Service(ref cause) => cause,
ListLayerVersionsError::TooManyRequests(ref cause) => cause,
ListLayerVersionsError::Validation(ref cause) => cause,
ListLayerVersionsError::Credentials(ref err) => err.description(),
ListLayerVersionsError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
ListLayerVersionsError::ParseError(ref cause) => cause,
ListLayerVersionsError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum ListLayersError {
InvalidParameterValue(String),
Service(String),
TooManyRequests(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl ListLayersError {
pub fn from_response(res: BufferedHttpResponse) -> ListLayersError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InvalidParameterValueException" => {
return ListLayersError::InvalidParameterValue(String::from(error_message));
}
"ServiceException" => return ListLayersError::Service(String::from(error_message)),
"TooManyRequestsException" => {
return ListLayersError::TooManyRequests(String::from(error_message));
}
"ValidationException" => {
return ListLayersError::Validation(error_message.to_string());
}
_ => {}
}
}
return ListLayersError::Unknown(res);
}
}
impl From<serde_json::error::Error> for ListLayersError {
fn from(err: serde_json::error::Error) -> ListLayersError {
ListLayersError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for ListLayersError {
fn from(err: CredentialsError) -> ListLayersError {
ListLayersError::Credentials(err)
}
}
impl From<HttpDispatchError> for ListLayersError {
fn from(err: HttpDispatchError) -> ListLayersError {
ListLayersError::HttpDispatch(err)
}
}
impl From<io::Error> for ListLayersError {
fn from(err: io::Error) -> ListLayersError {
ListLayersError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for ListLayersError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for ListLayersError {
fn description(&self) -> &str {
match *self {
ListLayersError::InvalidParameterValue(ref cause) => cause,
ListLayersError::Service(ref cause) => cause,
ListLayersError::TooManyRequests(ref cause) => cause,
ListLayersError::Validation(ref cause) => cause,
ListLayersError::Credentials(ref err) => err.description(),
ListLayersError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
ListLayersError::ParseError(ref cause) => cause,
ListLayersError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum ListTagsError {
InvalidParameterValue(String),
ResourceNotFound(String),
Service(String),
TooManyRequests(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl ListTagsError {
pub fn from_response(res: BufferedHttpResponse) -> ListTagsError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InvalidParameterValueException" => {
return ListTagsError::InvalidParameterValue(String::from(error_message));
}
"ResourceNotFoundException" => {
return ListTagsError::ResourceNotFound(String::from(error_message));
}
"ServiceException" => return ListTagsError::Service(String::from(error_message)),
"TooManyRequestsException" => {
return ListTagsError::TooManyRequests(String::from(error_message));
}
"ValidationException" => {
return ListTagsError::Validation(error_message.to_string());
}
_ => {}
}
}
return ListTagsError::Unknown(res);
}
}
impl From<serde_json::error::Error> for ListTagsError {
fn from(err: serde_json::error::Error) -> ListTagsError {
ListTagsError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for ListTagsError {
fn from(err: CredentialsError) -> ListTagsError {
ListTagsError::Credentials(err)
}
}
impl From<HttpDispatchError> for ListTagsError {
fn from(err: HttpDispatchError) -> ListTagsError {
ListTagsError::HttpDispatch(err)
}
}
impl From<io::Error> for ListTagsError {
fn from(err: io::Error) -> ListTagsError {
ListTagsError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for ListTagsError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for ListTagsError {
fn description(&self) -> &str {
match *self {
ListTagsError::InvalidParameterValue(ref cause) => cause,
ListTagsError::ResourceNotFound(ref cause) => cause,
ListTagsError::Service(ref cause) => cause,
ListTagsError::TooManyRequests(ref cause) => cause,
ListTagsError::Validation(ref cause) => cause,
ListTagsError::Credentials(ref err) => err.description(),
ListTagsError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
ListTagsError::ParseError(ref cause) => cause,
ListTagsError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum ListVersionsByFunctionError {
InvalidParameterValue(String),
ResourceNotFound(String),
Service(String),
TooManyRequests(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl ListVersionsByFunctionError {
pub fn from_response(res: BufferedHttpResponse) -> ListVersionsByFunctionError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InvalidParameterValueException" => {
return ListVersionsByFunctionError::InvalidParameterValue(String::from(
error_message,
));
}
"ResourceNotFoundException" => {
return ListVersionsByFunctionError::ResourceNotFound(String::from(
error_message,
));
}
"ServiceException" => {
return ListVersionsByFunctionError::Service(String::from(error_message));
}
"TooManyRequestsException" => {
return ListVersionsByFunctionError::TooManyRequests(String::from(error_message));
}
"ValidationException" => {
return ListVersionsByFunctionError::Validation(error_message.to_string());
}
_ => {}
}
}
return ListVersionsByFunctionError::Unknown(res);
}
}
impl From<serde_json::error::Error> for ListVersionsByFunctionError {
fn from(err: serde_json::error::Error) -> ListVersionsByFunctionError {
ListVersionsByFunctionError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for ListVersionsByFunctionError {
fn from(err: CredentialsError) -> ListVersionsByFunctionError {
ListVersionsByFunctionError::Credentials(err)
}
}
impl From<HttpDispatchError> for ListVersionsByFunctionError {
fn from(err: HttpDispatchError) -> ListVersionsByFunctionError {
ListVersionsByFunctionError::HttpDispatch(err)
}
}
impl From<io::Error> for ListVersionsByFunctionError {
fn from(err: io::Error) -> ListVersionsByFunctionError {
ListVersionsByFunctionError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for ListVersionsByFunctionError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for ListVersionsByFunctionError {
fn description(&self) -> &str {
match *self {
ListVersionsByFunctionError::InvalidParameterValue(ref cause) => cause,
ListVersionsByFunctionError::ResourceNotFound(ref cause) => cause,
ListVersionsByFunctionError::Service(ref cause) => cause,
ListVersionsByFunctionError::TooManyRequests(ref cause) => cause,
ListVersionsByFunctionError::Validation(ref cause) => cause,
ListVersionsByFunctionError::Credentials(ref err) => err.description(),
ListVersionsByFunctionError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
ListVersionsByFunctionError::ParseError(ref cause) => cause,
ListVersionsByFunctionError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum PublishLayerVersionError {
CodeStorageExceeded(String),
InvalidParameterValue(String),
ResourceNotFound(String),
Service(String),
TooManyRequests(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl PublishLayerVersionError {
pub fn from_response(res: BufferedHttpResponse) -> PublishLayerVersionError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"CodeStorageExceededException" => {
return PublishLayerVersionError::CodeStorageExceeded(String::from(
error_message,
));
}
"InvalidParameterValueException" => {
return PublishLayerVersionError::InvalidParameterValue(String::from(
error_message,
));
}
"ResourceNotFoundException" => {
return PublishLayerVersionError::ResourceNotFound(String::from(error_message));
}
"ServiceException" => {
return PublishLayerVersionError::Service(String::from(error_message));
}
"TooManyRequestsException" => {
return PublishLayerVersionError::TooManyRequests(String::from(error_message));
}
"ValidationException" => {
return PublishLayerVersionError::Validation(error_message.to_string());
}
_ => {}
}
}
return PublishLayerVersionError::Unknown(res);
}
}
impl From<serde_json::error::Error> for PublishLayerVersionError {
fn from(err: serde_json::error::Error) -> PublishLayerVersionError {
PublishLayerVersionError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for PublishLayerVersionError {
fn from(err: CredentialsError) -> PublishLayerVersionError {
PublishLayerVersionError::Credentials(err)
}
}
impl From<HttpDispatchError> for PublishLayerVersionError {
fn from(err: HttpDispatchError) -> PublishLayerVersionError {
PublishLayerVersionError::HttpDispatch(err)
}
}
impl From<io::Error> for PublishLayerVersionError {
fn from(err: io::Error) -> PublishLayerVersionError {
PublishLayerVersionError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for PublishLayerVersionError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for PublishLayerVersionError {
fn description(&self) -> &str {
match *self {
PublishLayerVersionError::CodeStorageExceeded(ref cause) => cause,
PublishLayerVersionError::InvalidParameterValue(ref cause) => cause,
PublishLayerVersionError::ResourceNotFound(ref cause) => cause,
PublishLayerVersionError::Service(ref cause) => cause,
PublishLayerVersionError::TooManyRequests(ref cause) => cause,
PublishLayerVersionError::Validation(ref cause) => cause,
PublishLayerVersionError::Credentials(ref err) => err.description(),
PublishLayerVersionError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
PublishLayerVersionError::ParseError(ref cause) => cause,
PublishLayerVersionError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum PublishVersionError {
CodeStorageExceeded(String),
InvalidParameterValue(String),
PreconditionFailed(String),
ResourceNotFound(String),
Service(String),
TooManyRequests(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl PublishVersionError {
pub fn from_response(res: BufferedHttpResponse) -> PublishVersionError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"CodeStorageExceededException" => {
return PublishVersionError::CodeStorageExceeded(String::from(error_message));
}
"InvalidParameterValueException" => {
return PublishVersionError::InvalidParameterValue(String::from(error_message));
}
"PreconditionFailedException" => {
return PublishVersionError::PreconditionFailed(String::from(error_message));
}
"ResourceNotFoundException" => {
return PublishVersionError::ResourceNotFound(String::from(error_message));
}
"ServiceException" => {
return PublishVersionError::Service(String::from(error_message));
}
"TooManyRequestsException" => {
return PublishVersionError::TooManyRequests(String::from(error_message));
}
"ValidationException" => {
return PublishVersionError::Validation(error_message.to_string());
}
_ => {}
}
}
return PublishVersionError::Unknown(res);
}
}
impl From<serde_json::error::Error> for PublishVersionError {
fn from(err: serde_json::error::Error) -> PublishVersionError {
PublishVersionError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for PublishVersionError {
fn from(err: CredentialsError) -> PublishVersionError {
PublishVersionError::Credentials(err)
}
}
impl From<HttpDispatchError> for PublishVersionError {
fn from(err: HttpDispatchError) -> PublishVersionError {
PublishVersionError::HttpDispatch(err)
}
}
impl From<io::Error> for PublishVersionError {
fn from(err: io::Error) -> PublishVersionError {
PublishVersionError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for PublishVersionError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for PublishVersionError {
fn description(&self) -> &str {
match *self {
PublishVersionError::CodeStorageExceeded(ref cause) => cause,
PublishVersionError::InvalidParameterValue(ref cause) => cause,
PublishVersionError::PreconditionFailed(ref cause) => cause,
PublishVersionError::ResourceNotFound(ref cause) => cause,
PublishVersionError::Service(ref cause) => cause,
PublishVersionError::TooManyRequests(ref cause) => cause,
PublishVersionError::Validation(ref cause) => cause,
PublishVersionError::Credentials(ref err) => err.description(),
PublishVersionError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
PublishVersionError::ParseError(ref cause) => cause,
PublishVersionError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum PutFunctionConcurrencyError {
InvalidParameterValue(String),
ResourceNotFound(String),
Service(String),
TooManyRequests(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl PutFunctionConcurrencyError {
pub fn from_response(res: BufferedHttpResponse) -> PutFunctionConcurrencyError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InvalidParameterValueException" => {
return PutFunctionConcurrencyError::InvalidParameterValue(String::from(
error_message,
));
}
"ResourceNotFoundException" => {
return PutFunctionConcurrencyError::ResourceNotFound(String::from(
error_message,
));
}
"ServiceException" => {
return PutFunctionConcurrencyError::Service(String::from(error_message));
}
"TooManyRequestsException" => {
return PutFunctionConcurrencyError::TooManyRequests(String::from(error_message));
}
"ValidationException" => {
return PutFunctionConcurrencyError::Validation(error_message.to_string());
}
_ => {}
}
}
return PutFunctionConcurrencyError::Unknown(res);
}
}
impl From<serde_json::error::Error> for PutFunctionConcurrencyError {
fn from(err: serde_json::error::Error) -> PutFunctionConcurrencyError {
PutFunctionConcurrencyError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for PutFunctionConcurrencyError {
fn from(err: CredentialsError) -> PutFunctionConcurrencyError {
PutFunctionConcurrencyError::Credentials(err)
}
}
impl From<HttpDispatchError> for PutFunctionConcurrencyError {
fn from(err: HttpDispatchError) -> PutFunctionConcurrencyError {
PutFunctionConcurrencyError::HttpDispatch(err)
}
}
impl From<io::Error> for PutFunctionConcurrencyError {
fn from(err: io::Error) -> PutFunctionConcurrencyError {
PutFunctionConcurrencyError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for PutFunctionConcurrencyError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for PutFunctionConcurrencyError {
fn description(&self) -> &str {
match *self {
PutFunctionConcurrencyError::InvalidParameterValue(ref cause) => cause,
PutFunctionConcurrencyError::ResourceNotFound(ref cause) => cause,
PutFunctionConcurrencyError::Service(ref cause) => cause,
PutFunctionConcurrencyError::TooManyRequests(ref cause) => cause,
PutFunctionConcurrencyError::Validation(ref cause) => cause,
PutFunctionConcurrencyError::Credentials(ref err) => err.description(),
PutFunctionConcurrencyError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
PutFunctionConcurrencyError::ParseError(ref cause) => cause,
PutFunctionConcurrencyError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum RemoveLayerVersionPermissionError {
InvalidParameterValue(String),
PreconditionFailed(String),
ResourceNotFound(String),
Service(String),
TooManyRequests(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl RemoveLayerVersionPermissionError {
pub fn from_response(res: BufferedHttpResponse) -> RemoveLayerVersionPermissionError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InvalidParameterValueException" => {
return RemoveLayerVersionPermissionError::InvalidParameterValue(String::from(
error_message,
));
}
"PreconditionFailedException" => {
return RemoveLayerVersionPermissionError::PreconditionFailed(String::from(
error_message,
));
}
"ResourceNotFoundException" => {
return RemoveLayerVersionPermissionError::ResourceNotFound(String::from(
error_message,
));
}
"ServiceException" => {
return RemoveLayerVersionPermissionError::Service(String::from(error_message));
}
"TooManyRequestsException" => {
return RemoveLayerVersionPermissionError::TooManyRequests(String::from(
error_message,
));
}
"ValidationException" => {
return RemoveLayerVersionPermissionError::Validation(error_message.to_string());
}
_ => {}
}
}
return RemoveLayerVersionPermissionError::Unknown(res);
}
}
impl From<serde_json::error::Error> for RemoveLayerVersionPermissionError {
fn from(err: serde_json::error::Error) -> RemoveLayerVersionPermissionError {
RemoveLayerVersionPermissionError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for RemoveLayerVersionPermissionError {
fn from(err: CredentialsError) -> RemoveLayerVersionPermissionError {
RemoveLayerVersionPermissionError::Credentials(err)
}
}
impl From<HttpDispatchError> for RemoveLayerVersionPermissionError {
fn from(err: HttpDispatchError) -> RemoveLayerVersionPermissionError {
RemoveLayerVersionPermissionError::HttpDispatch(err)
}
}
impl From<io::Error> for RemoveLayerVersionPermissionError {
fn from(err: io::Error) -> RemoveLayerVersionPermissionError {
RemoveLayerVersionPermissionError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for RemoveLayerVersionPermissionError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for RemoveLayerVersionPermissionError {
fn description(&self) -> &str {
match *self {
RemoveLayerVersionPermissionError::InvalidParameterValue(ref cause) => cause,
RemoveLayerVersionPermissionError::PreconditionFailed(ref cause) => cause,
RemoveLayerVersionPermissionError::ResourceNotFound(ref cause) => cause,
RemoveLayerVersionPermissionError::Service(ref cause) => cause,
RemoveLayerVersionPermissionError::TooManyRequests(ref cause) => cause,
RemoveLayerVersionPermissionError::Validation(ref cause) => cause,
RemoveLayerVersionPermissionError::Credentials(ref err) => err.description(),
RemoveLayerVersionPermissionError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
RemoveLayerVersionPermissionError::ParseError(ref cause) => cause,
RemoveLayerVersionPermissionError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum RemovePermissionError {
InvalidParameterValue(String),
PreconditionFailed(String),
ResourceNotFound(String),
Service(String),
TooManyRequests(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl RemovePermissionError {
pub fn from_response(res: BufferedHttpResponse) -> RemovePermissionError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InvalidParameterValueException" => {
return RemovePermissionError::InvalidParameterValue(String::from(error_message));
}
"PreconditionFailedException" => {
return RemovePermissionError::PreconditionFailed(String::from(error_message));
}
"ResourceNotFoundException" => {
return RemovePermissionError::ResourceNotFound(String::from(error_message));
}
"ServiceException" => {
return RemovePermissionError::Service(String::from(error_message));
}
"TooManyRequestsException" => {
return RemovePermissionError::TooManyRequests(String::from(error_message));
}
"ValidationException" => {
return RemovePermissionError::Validation(error_message.to_string());
}
_ => {}
}
}
return RemovePermissionError::Unknown(res);
}
}
impl From<serde_json::error::Error> for RemovePermissionError {
fn from(err: serde_json::error::Error) -> RemovePermissionError {
RemovePermissionError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for RemovePermissionError {
fn from(err: CredentialsError) -> RemovePermissionError {
RemovePermissionError::Credentials(err)
}
}
impl From<HttpDispatchError> for RemovePermissionError {
fn from(err: HttpDispatchError) -> RemovePermissionError {
RemovePermissionError::HttpDispatch(err)
}
}
impl From<io::Error> for RemovePermissionError {
fn from(err: io::Error) -> RemovePermissionError {
RemovePermissionError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for RemovePermissionError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for RemovePermissionError {
fn description(&self) -> &str {
match *self {
RemovePermissionError::InvalidParameterValue(ref cause) => cause,
RemovePermissionError::PreconditionFailed(ref cause) => cause,
RemovePermissionError::ResourceNotFound(ref cause) => cause,
RemovePermissionError::Service(ref cause) => cause,
RemovePermissionError::TooManyRequests(ref cause) => cause,
RemovePermissionError::Validation(ref cause) => cause,
RemovePermissionError::Credentials(ref err) => err.description(),
RemovePermissionError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
RemovePermissionError::ParseError(ref cause) => cause,
RemovePermissionError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum TagResourceError {
InvalidParameterValue(String),
ResourceNotFound(String),
Service(String),
TooManyRequests(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl TagResourceError {
pub fn from_response(res: BufferedHttpResponse) -> TagResourceError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InvalidParameterValueException" => {
return TagResourceError::InvalidParameterValue(String::from(error_message));
}
"ResourceNotFoundException" => {
return TagResourceError::ResourceNotFound(String::from(error_message));
}
"ServiceException" => return TagResourceError::Service(String::from(error_message)),
"TooManyRequestsException" => {
return TagResourceError::TooManyRequests(String::from(error_message));
}
"ValidationException" => {
return TagResourceError::Validation(error_message.to_string());
}
_ => {}
}
}
return TagResourceError::Unknown(res);
}
}
impl From<serde_json::error::Error> for TagResourceError {
fn from(err: serde_json::error::Error) -> TagResourceError {
TagResourceError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for TagResourceError {
fn from(err: CredentialsError) -> TagResourceError {
TagResourceError::Credentials(err)
}
}
impl From<HttpDispatchError> for TagResourceError {
fn from(err: HttpDispatchError) -> TagResourceError {
TagResourceError::HttpDispatch(err)
}
}
impl From<io::Error> for TagResourceError {
fn from(err: io::Error) -> TagResourceError {
TagResourceError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for TagResourceError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for TagResourceError {
fn description(&self) -> &str {
match *self {
TagResourceError::InvalidParameterValue(ref cause) => cause,
TagResourceError::ResourceNotFound(ref cause) => cause,
TagResourceError::Service(ref cause) => cause,
TagResourceError::TooManyRequests(ref cause) => cause,
TagResourceError::Validation(ref cause) => cause,
TagResourceError::Credentials(ref err) => err.description(),
TagResourceError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
TagResourceError::ParseError(ref cause) => cause,
TagResourceError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum UntagResourceError {
InvalidParameterValue(String),
ResourceNotFound(String),
Service(String),
TooManyRequests(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl UntagResourceError {
pub fn from_response(res: BufferedHttpResponse) -> UntagResourceError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InvalidParameterValueException" => {
return UntagResourceError::InvalidParameterValue(String::from(error_message));
}
"ResourceNotFoundException" => {
return UntagResourceError::ResourceNotFound(String::from(error_message));
}
"ServiceException" => {
return UntagResourceError::Service(String::from(error_message));
}
"TooManyRequestsException" => {
return UntagResourceError::TooManyRequests(String::from(error_message));
}
"ValidationException" => {
return UntagResourceError::Validation(error_message.to_string());
}
_ => {}
}
}
return UntagResourceError::Unknown(res);
}
}
impl From<serde_json::error::Error> for UntagResourceError {
fn from(err: serde_json::error::Error) -> UntagResourceError {
UntagResourceError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for UntagResourceError {
fn from(err: CredentialsError) -> UntagResourceError {
UntagResourceError::Credentials(err)
}
}
impl From<HttpDispatchError> for UntagResourceError {
fn from(err: HttpDispatchError) -> UntagResourceError {
UntagResourceError::HttpDispatch(err)
}
}
impl From<io::Error> for UntagResourceError {
fn from(err: io::Error) -> UntagResourceError {
UntagResourceError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for UntagResourceError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for UntagResourceError {
fn description(&self) -> &str {
match *self {
UntagResourceError::InvalidParameterValue(ref cause) => cause,
UntagResourceError::ResourceNotFound(ref cause) => cause,
UntagResourceError::Service(ref cause) => cause,
UntagResourceError::TooManyRequests(ref cause) => cause,
UntagResourceError::Validation(ref cause) => cause,
UntagResourceError::Credentials(ref err) => err.description(),
UntagResourceError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
UntagResourceError::ParseError(ref cause) => cause,
UntagResourceError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum UpdateAliasError {
InvalidParameterValue(String),
PreconditionFailed(String),
ResourceNotFound(String),
Service(String),
TooManyRequests(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl UpdateAliasError {
pub fn from_response(res: BufferedHttpResponse) -> UpdateAliasError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InvalidParameterValueException" => {
return UpdateAliasError::InvalidParameterValue(String::from(error_message));
}
"PreconditionFailedException" => {
return UpdateAliasError::PreconditionFailed(String::from(error_message));
}
"ResourceNotFoundException" => {
return UpdateAliasError::ResourceNotFound(String::from(error_message));
}
"ServiceException" => return UpdateAliasError::Service(String::from(error_message)),
"TooManyRequestsException" => {
return UpdateAliasError::TooManyRequests(String::from(error_message));
}
"ValidationException" => {
return UpdateAliasError::Validation(error_message.to_string());
}
_ => {}
}
}
return UpdateAliasError::Unknown(res);
}
}
impl From<serde_json::error::Error> for UpdateAliasError {
fn from(err: serde_json::error::Error) -> UpdateAliasError {
UpdateAliasError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for UpdateAliasError {
fn from(err: CredentialsError) -> UpdateAliasError {
UpdateAliasError::Credentials(err)
}
}
impl From<HttpDispatchError> for UpdateAliasError {
fn from(err: HttpDispatchError) -> UpdateAliasError {
UpdateAliasError::HttpDispatch(err)
}
}
impl From<io::Error> for UpdateAliasError {
fn from(err: io::Error) -> UpdateAliasError {
UpdateAliasError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for UpdateAliasError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for UpdateAliasError {
fn description(&self) -> &str {
match *self {
UpdateAliasError::InvalidParameterValue(ref cause) => cause,
UpdateAliasError::PreconditionFailed(ref cause) => cause,
UpdateAliasError::ResourceNotFound(ref cause) => cause,
UpdateAliasError::Service(ref cause) => cause,
UpdateAliasError::TooManyRequests(ref cause) => cause,
UpdateAliasError::Validation(ref cause) => cause,
UpdateAliasError::Credentials(ref err) => err.description(),
UpdateAliasError::HttpDispatch(ref dispatch_error) => dispatch_error.description(),
UpdateAliasError::ParseError(ref cause) => cause,
UpdateAliasError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum UpdateEventSourceMappingError {
InvalidParameterValue(String),
ResourceConflict(String),
ResourceInUse(String),
ResourceNotFound(String),
Service(String),
TooManyRequests(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl UpdateEventSourceMappingError {
pub fn from_response(res: BufferedHttpResponse) -> UpdateEventSourceMappingError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InvalidParameterValueException" => {
return UpdateEventSourceMappingError::InvalidParameterValue(String::from(
error_message,
));
}
"ResourceConflictException" => {
return UpdateEventSourceMappingError::ResourceConflict(String::from(
error_message,
));
}
"ResourceInUseException" => {
return UpdateEventSourceMappingError::ResourceInUse(String::from(error_message));
}
"ResourceNotFoundException" => {
return UpdateEventSourceMappingError::ResourceNotFound(String::from(
error_message,
));
}
"ServiceException" => {
return UpdateEventSourceMappingError::Service(String::from(error_message));
}
"TooManyRequestsException" => {
return UpdateEventSourceMappingError::TooManyRequests(String::from(
error_message,
));
}
"ValidationException" => {
return UpdateEventSourceMappingError::Validation(error_message.to_string());
}
_ => {}
}
}
return UpdateEventSourceMappingError::Unknown(res);
}
}
impl From<serde_json::error::Error> for UpdateEventSourceMappingError {
fn from(err: serde_json::error::Error) -> UpdateEventSourceMappingError {
UpdateEventSourceMappingError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for UpdateEventSourceMappingError {
fn from(err: CredentialsError) -> UpdateEventSourceMappingError {
UpdateEventSourceMappingError::Credentials(err)
}
}
impl From<HttpDispatchError> for UpdateEventSourceMappingError {
fn from(err: HttpDispatchError) -> UpdateEventSourceMappingError {
UpdateEventSourceMappingError::HttpDispatch(err)
}
}
impl From<io::Error> for UpdateEventSourceMappingError {
fn from(err: io::Error) -> UpdateEventSourceMappingError {
UpdateEventSourceMappingError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for UpdateEventSourceMappingError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for UpdateEventSourceMappingError {
fn description(&self) -> &str {
match *self {
UpdateEventSourceMappingError::InvalidParameterValue(ref cause) => cause,
UpdateEventSourceMappingError::ResourceConflict(ref cause) => cause,
UpdateEventSourceMappingError::ResourceInUse(ref cause) => cause,
UpdateEventSourceMappingError::ResourceNotFound(ref cause) => cause,
UpdateEventSourceMappingError::Service(ref cause) => cause,
UpdateEventSourceMappingError::TooManyRequests(ref cause) => cause,
UpdateEventSourceMappingError::Validation(ref cause) => cause,
UpdateEventSourceMappingError::Credentials(ref err) => err.description(),
UpdateEventSourceMappingError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
UpdateEventSourceMappingError::ParseError(ref cause) => cause,
UpdateEventSourceMappingError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum UpdateFunctionCodeError {
CodeStorageExceeded(String),
InvalidParameterValue(String),
PreconditionFailed(String),
ResourceNotFound(String),
Service(String),
TooManyRequests(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl UpdateFunctionCodeError {
pub fn from_response(res: BufferedHttpResponse) -> UpdateFunctionCodeError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"CodeStorageExceededException" => {
return UpdateFunctionCodeError::CodeStorageExceeded(String::from(error_message));
}
"InvalidParameterValueException" => {
return UpdateFunctionCodeError::InvalidParameterValue(String::from(
error_message,
));
}
"PreconditionFailedException" => {
return UpdateFunctionCodeError::PreconditionFailed(String::from(error_message));
}
"ResourceNotFoundException" => {
return UpdateFunctionCodeError::ResourceNotFound(String::from(error_message));
}
"ServiceException" => {
return UpdateFunctionCodeError::Service(String::from(error_message));
}
"TooManyRequestsException" => {
return UpdateFunctionCodeError::TooManyRequests(String::from(error_message));
}
"ValidationException" => {
return UpdateFunctionCodeError::Validation(error_message.to_string());
}
_ => {}
}
}
return UpdateFunctionCodeError::Unknown(res);
}
}
impl From<serde_json::error::Error> for UpdateFunctionCodeError {
fn from(err: serde_json::error::Error) -> UpdateFunctionCodeError {
UpdateFunctionCodeError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for UpdateFunctionCodeError {
fn from(err: CredentialsError) -> UpdateFunctionCodeError {
UpdateFunctionCodeError::Credentials(err)
}
}
impl From<HttpDispatchError> for UpdateFunctionCodeError {
fn from(err: HttpDispatchError) -> UpdateFunctionCodeError {
UpdateFunctionCodeError::HttpDispatch(err)
}
}
impl From<io::Error> for UpdateFunctionCodeError {
fn from(err: io::Error) -> UpdateFunctionCodeError {
UpdateFunctionCodeError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for UpdateFunctionCodeError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for UpdateFunctionCodeError {
fn description(&self) -> &str {
match *self {
UpdateFunctionCodeError::CodeStorageExceeded(ref cause) => cause,
UpdateFunctionCodeError::InvalidParameterValue(ref cause) => cause,
UpdateFunctionCodeError::PreconditionFailed(ref cause) => cause,
UpdateFunctionCodeError::ResourceNotFound(ref cause) => cause,
UpdateFunctionCodeError::Service(ref cause) => cause,
UpdateFunctionCodeError::TooManyRequests(ref cause) => cause,
UpdateFunctionCodeError::Validation(ref cause) => cause,
UpdateFunctionCodeError::Credentials(ref err) => err.description(),
UpdateFunctionCodeError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
UpdateFunctionCodeError::ParseError(ref cause) => cause,
UpdateFunctionCodeError::Unknown(_) => "unknown error",
}
}
}
#[derive(Debug, PartialEq)]
pub enum UpdateFunctionConfigurationError {
InvalidParameterValue(String),
PreconditionFailed(String),
ResourceConflict(String),
ResourceNotFound(String),
Service(String),
TooManyRequests(String),
HttpDispatch(HttpDispatchError),
Credentials(CredentialsError),
Validation(String),
ParseError(String),
Unknown(BufferedHttpResponse),
}
impl UpdateFunctionConfigurationError {
pub fn from_response(res: BufferedHttpResponse) -> UpdateFunctionConfigurationError {
if let Ok(json) = from_slice::<SerdeJsonValue>(&res.body) {
let error_type = match res.headers.get("x-amzn-errortype") {
Some(raw_error_type) => raw_error_type
.split(':')
.next()
.unwrap_or_else(|| "Unknown"),
_ => json
.get("code")
.or_else(|| json.get("Code"))
.and_then(|c| c.as_str())
.unwrap_or_else(|| "Unknown"),
};
let error_message = json
.get("message")
.or_else(|| json.get("Message"))
.and_then(|m| m.as_str())
.unwrap_or("");
match error_type {
"InvalidParameterValueException" => {
return UpdateFunctionConfigurationError::InvalidParameterValue(String::from(
error_message,
));
}
"PreconditionFailedException" => {
return UpdateFunctionConfigurationError::PreconditionFailed(String::from(
error_message,
));
}
"ResourceConflictException" => {
return UpdateFunctionConfigurationError::ResourceConflict(String::from(
error_message,
));
}
"ResourceNotFoundException" => {
return UpdateFunctionConfigurationError::ResourceNotFound(String::from(
error_message,
));
}
"ServiceException" => {
return UpdateFunctionConfigurationError::Service(String::from(error_message));
}
"TooManyRequestsException" => {
return UpdateFunctionConfigurationError::TooManyRequests(String::from(
error_message,
));
}
"ValidationException" => {
return UpdateFunctionConfigurationError::Validation(error_message.to_string());
}
_ => {}
}
}
return UpdateFunctionConfigurationError::Unknown(res);
}
}
impl From<serde_json::error::Error> for UpdateFunctionConfigurationError {
fn from(err: serde_json::error::Error) -> UpdateFunctionConfigurationError {
UpdateFunctionConfigurationError::ParseError(err.description().to_string())
}
}
impl From<CredentialsError> for UpdateFunctionConfigurationError {
fn from(err: CredentialsError) -> UpdateFunctionConfigurationError {
UpdateFunctionConfigurationError::Credentials(err)
}
}
impl From<HttpDispatchError> for UpdateFunctionConfigurationError {
fn from(err: HttpDispatchError) -> UpdateFunctionConfigurationError {
UpdateFunctionConfigurationError::HttpDispatch(err)
}
}
impl From<io::Error> for UpdateFunctionConfigurationError {
fn from(err: io::Error) -> UpdateFunctionConfigurationError {
UpdateFunctionConfigurationError::HttpDispatch(HttpDispatchError::from(err))
}
}
impl fmt::Display for UpdateFunctionConfigurationError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
}
}
impl Error for UpdateFunctionConfigurationError {
fn description(&self) -> &str {
match *self {
UpdateFunctionConfigurationError::InvalidParameterValue(ref cause) => cause,
UpdateFunctionConfigurationError::PreconditionFailed(ref cause) => cause,
UpdateFunctionConfigurationError::ResourceConflict(ref cause) => cause,
UpdateFunctionConfigurationError::ResourceNotFound(ref cause) => cause,
UpdateFunctionConfigurationError::Service(ref cause) => cause,
UpdateFunctionConfigurationError::TooManyRequests(ref cause) => cause,
UpdateFunctionConfigurationError::Validation(ref cause) => cause,
UpdateFunctionConfigurationError::Credentials(ref err) => err.description(),
UpdateFunctionConfigurationError::HttpDispatch(ref dispatch_error) => {
dispatch_error.description()
}
UpdateFunctionConfigurationError::ParseError(ref cause) => cause,
UpdateFunctionConfigurationError::Unknown(_) => "unknown error",
}
}
}
pub trait Lambda {
fn add_layer_version_permission(
&self,
input: AddLayerVersionPermissionRequest,
) -> RusotoFuture<AddLayerVersionPermissionResponse, AddLayerVersionPermissionError>;
fn add_permission(
&self,
input: AddPermissionRequest,
) -> RusotoFuture<AddPermissionResponse, AddPermissionError>;
fn create_alias(
&self,
input: CreateAliasRequest,
) -> RusotoFuture<AliasConfiguration, CreateAliasError>;
fn create_event_source_mapping(
&self,
input: CreateEventSourceMappingRequest,
) -> RusotoFuture<EventSourceMappingConfiguration, CreateEventSourceMappingError>;
fn create_function(
&self,
input: CreateFunctionRequest,
) -> RusotoFuture<FunctionConfiguration, CreateFunctionError>;
fn delete_alias(&self, input: DeleteAliasRequest) -> RusotoFuture<(), DeleteAliasError>;
fn delete_event_source_mapping(
&self,
input: DeleteEventSourceMappingRequest,
) -> RusotoFuture<EventSourceMappingConfiguration, DeleteEventSourceMappingError>;
fn delete_function(
&self,
input: DeleteFunctionRequest,
) -> RusotoFuture<(), DeleteFunctionError>;
fn delete_function_concurrency(
&self,
input: DeleteFunctionConcurrencyRequest,
) -> RusotoFuture<(), DeleteFunctionConcurrencyError>;
fn delete_layer_version(
&self,
input: DeleteLayerVersionRequest,
) -> RusotoFuture<(), DeleteLayerVersionError>;
fn get_account_settings(
&self,
) -> RusotoFuture<GetAccountSettingsResponse, GetAccountSettingsError>;
fn get_alias(&self, input: GetAliasRequest) -> RusotoFuture<AliasConfiguration, GetAliasError>;
fn get_event_source_mapping(
&self,
input: GetEventSourceMappingRequest,
) -> RusotoFuture<EventSourceMappingConfiguration, GetEventSourceMappingError>;
fn get_function(
&self,
input: GetFunctionRequest,
) -> RusotoFuture<GetFunctionResponse, GetFunctionError>;
fn get_function_configuration(
&self,
input: GetFunctionConfigurationRequest,
) -> RusotoFuture<FunctionConfiguration, GetFunctionConfigurationError>;
fn get_layer_version(
&self,
input: GetLayerVersionRequest,
) -> RusotoFuture<GetLayerVersionResponse, GetLayerVersionError>;
fn get_layer_version_policy(
&self,
input: GetLayerVersionPolicyRequest,
) -> RusotoFuture<GetLayerVersionPolicyResponse, GetLayerVersionPolicyError>;
fn get_policy(
&self,
input: GetPolicyRequest,
) -> RusotoFuture<GetPolicyResponse, GetPolicyError>;
fn invoke(&self, input: InvocationRequest) -> RusotoFuture<InvocationResponse, InvokeError>;
fn invoke_async(
&self,
input: InvokeAsyncRequest,
) -> RusotoFuture<InvokeAsyncResponse, InvokeAsyncError>;
fn list_aliases(
&self,
input: ListAliasesRequest,
) -> RusotoFuture<ListAliasesResponse, ListAliasesError>;
fn list_event_source_mappings(
&self,
input: ListEventSourceMappingsRequest,
) -> RusotoFuture<ListEventSourceMappingsResponse, ListEventSourceMappingsError>;
fn list_functions(
&self,
input: ListFunctionsRequest,
) -> RusotoFuture<ListFunctionsResponse, ListFunctionsError>;
fn list_layer_versions(
&self,
input: ListLayerVersionsRequest,
) -> RusotoFuture<ListLayerVersionsResponse, ListLayerVersionsError>;
fn list_layers(
&self,
input: ListLayersRequest,
) -> RusotoFuture<ListLayersResponse, ListLayersError>;
fn list_tags(&self, input: ListTagsRequest) -> RusotoFuture<ListTagsResponse, ListTagsError>;
fn list_versions_by_function(
&self,
input: ListVersionsByFunctionRequest,
) -> RusotoFuture<ListVersionsByFunctionResponse, ListVersionsByFunctionError>;
fn publish_layer_version(
&self,
input: PublishLayerVersionRequest,
) -> RusotoFuture<PublishLayerVersionResponse, PublishLayerVersionError>;
fn publish_version(
&self,
input: PublishVersionRequest,
) -> RusotoFuture<FunctionConfiguration, PublishVersionError>;
fn put_function_concurrency(
&self,
input: PutFunctionConcurrencyRequest,
) -> RusotoFuture<Concurrency, PutFunctionConcurrencyError>;
fn remove_layer_version_permission(
&self,
input: RemoveLayerVersionPermissionRequest,
) -> RusotoFuture<(), RemoveLayerVersionPermissionError>;
fn remove_permission(
&self,
input: RemovePermissionRequest,
) -> RusotoFuture<(), RemovePermissionError>;
fn tag_resource(&self, input: TagResourceRequest) -> RusotoFuture<(), TagResourceError>;
fn untag_resource(&self, input: UntagResourceRequest) -> RusotoFuture<(), UntagResourceError>;
fn update_alias(
&self,
input: UpdateAliasRequest,
) -> RusotoFuture<AliasConfiguration, UpdateAliasError>;
fn update_event_source_mapping(
&self,
input: UpdateEventSourceMappingRequest,
) -> RusotoFuture<EventSourceMappingConfiguration, UpdateEventSourceMappingError>;
fn update_function_code(
&self,
input: UpdateFunctionCodeRequest,
) -> RusotoFuture<FunctionConfiguration, UpdateFunctionCodeError>;
fn update_function_configuration(
&self,
input: UpdateFunctionConfigurationRequest,
) -> RusotoFuture<FunctionConfiguration, UpdateFunctionConfigurationError>;
}
#[derive(Clone)]
pub struct LambdaClient {
client: Client,
region: region::Region,
}
impl LambdaClient {
pub fn new(region: region::Region) -> LambdaClient {
LambdaClient {
client: Client::shared(),
region: region,
}
}
pub fn new_with<P, D>(
request_dispatcher: D,
credentials_provider: P,
region: region::Region,
) -> LambdaClient
where
P: ProvideAwsCredentials + Send + Sync + 'static,
P::Future: Send,
D: DispatchSignedRequest + Send + Sync + 'static,
D::Future: Send,
{
LambdaClient {
client: Client::new_with(credentials_provider, request_dispatcher),
region: region,
}
}
}
impl Lambda for LambdaClient {
fn add_layer_version_permission(
&self,
input: AddLayerVersionPermissionRequest,
) -> RusotoFuture<AddLayerVersionPermissionResponse, AddLayerVersionPermissionError> {
let request_uri = format!(
"/2018-10-31/layers/{layer_name}/versions/{version_number}/policy",
layer_name = input.layer_name,
version_number = input.version_number
);
let mut request = SignedRequest::new("POST", "lambda", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
let mut params = Params::new();
if let Some(ref x) = input.revision_id {
params.put("RevisionId", x);
}
request.set_params(params);
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 201 {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result =
serde_json::from_slice::<AddLayerVersionPermissionResponse>(&body).unwrap();
result
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(AddLayerVersionPermissionError::from_response(response))
}))
}
})
}
fn add_permission(
&self,
input: AddPermissionRequest,
) -> RusotoFuture<AddPermissionResponse, AddPermissionError> {
let request_uri = format!(
"/2015-03-31/functions/{function_name}/policy",
function_name = input.function_name
);
let mut request = SignedRequest::new("POST", "lambda", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
let mut params = Params::new();
if let Some(ref x) = input.qualifier {
params.put("Qualifier", x);
}
request.set_params(params);
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 201 {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result = serde_json::from_slice::<AddPermissionResponse>(&body).unwrap();
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(AddPermissionError::from_response(response))),
)
}
})
}
fn create_alias(
&self,
input: CreateAliasRequest,
) -> RusotoFuture<AliasConfiguration, CreateAliasError> {
let request_uri = format!(
"/2015-03-31/functions/{function_name}/aliases",
function_name = input.function_name
);
let mut request = SignedRequest::new("POST", "lambda", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 201 {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result = serde_json::from_slice::<AliasConfiguration>(&body).unwrap();
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(CreateAliasError::from_response(response))),
)
}
})
}
fn create_event_source_mapping(
&self,
input: CreateEventSourceMappingRequest,
) -> RusotoFuture<EventSourceMappingConfiguration, CreateEventSourceMappingError> {
let request_uri = "/2015-03-31/event-source-mappings/";
let mut request = SignedRequest::new("POST", "lambda", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 202 {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result =
serde_json::from_slice::<EventSourceMappingConfiguration>(&body).unwrap();
result
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(CreateEventSourceMappingError::from_response(response))
}))
}
})
}
fn create_function(
&self,
input: CreateFunctionRequest,
) -> RusotoFuture<FunctionConfiguration, CreateFunctionError> {
let request_uri = "/2015-03-31/functions";
let mut request = SignedRequest::new("POST", "lambda", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 201 {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result = serde_json::from_slice::<FunctionConfiguration>(&body).unwrap();
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(CreateFunctionError::from_response(response))),
)
}
})
}
fn delete_alias(&self, input: DeleteAliasRequest) -> RusotoFuture<(), DeleteAliasError> {
let request_uri = format!(
"/2015-03-31/functions/{function_name}/aliases/{name}",
function_name = input.function_name,
name = input.name
);
let mut request = SignedRequest::new("DELETE", "lambda", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 204 {
Box::new(response.buffer().from_err().map(|response| {
let result = ::std::mem::drop(response);
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DeleteAliasError::from_response(response))),
)
}
})
}
fn delete_event_source_mapping(
&self,
input: DeleteEventSourceMappingRequest,
) -> RusotoFuture<EventSourceMappingConfiguration, DeleteEventSourceMappingError> {
let request_uri = format!(
"/2015-03-31/event-source-mappings/{uuid}",
uuid = input.uuid
);
let mut request = SignedRequest::new("DELETE", "lambda", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 202 {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result =
serde_json::from_slice::<EventSourceMappingConfiguration>(&body).unwrap();
result
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(DeleteEventSourceMappingError::from_response(response))
}))
}
})
}
fn delete_function(
&self,
input: DeleteFunctionRequest,
) -> RusotoFuture<(), DeleteFunctionError> {
let request_uri = format!(
"/2015-03-31/functions/{function_name}",
function_name = input.function_name
);
let mut request = SignedRequest::new("DELETE", "lambda", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let mut params = Params::new();
if let Some(ref x) = input.qualifier {
params.put("Qualifier", x);
}
request.set_params(params);
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 204 {
Box::new(response.buffer().from_err().map(|response| {
let result = ::std::mem::drop(response);
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DeleteFunctionError::from_response(response))),
)
}
})
}
fn delete_function_concurrency(
&self,
input: DeleteFunctionConcurrencyRequest,
) -> RusotoFuture<(), DeleteFunctionConcurrencyError> {
let request_uri = format!(
"/2017-10-31/functions/{function_name}/concurrency",
function_name = input.function_name
);
let mut request = SignedRequest::new("DELETE", "lambda", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 204 {
Box::new(response.buffer().from_err().map(|response| {
let result = ::std::mem::drop(response);
result
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(DeleteFunctionConcurrencyError::from_response(response))
}))
}
})
}
fn delete_layer_version(
&self,
input: DeleteLayerVersionRequest,
) -> RusotoFuture<(), DeleteLayerVersionError> {
let request_uri = format!(
"/2018-10-31/layers/{layer_name}/versions/{version_number}",
layer_name = input.layer_name,
version_number = input.version_number
);
let mut request = SignedRequest::new("DELETE", "lambda", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 204 {
Box::new(response.buffer().from_err().map(|response| {
let result = ::std::mem::drop(response);
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(DeleteLayerVersionError::from_response(response))),
)
}
})
}
fn get_account_settings(
&self,
) -> RusotoFuture<GetAccountSettingsResponse, GetAccountSettingsError> {
let request_uri = "/2016-08-19/account-settings/";
let mut request = SignedRequest::new("GET", "lambda", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 200 {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result =
serde_json::from_slice::<GetAccountSettingsResponse>(&body).unwrap();
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(GetAccountSettingsError::from_response(response))),
)
}
})
}
fn get_alias(&self, input: GetAliasRequest) -> RusotoFuture<AliasConfiguration, GetAliasError> {
let request_uri = format!(
"/2015-03-31/functions/{function_name}/aliases/{name}",
function_name = input.function_name,
name = input.name
);
let mut request = SignedRequest::new("GET", "lambda", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 200 {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result = serde_json::from_slice::<AliasConfiguration>(&body).unwrap();
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(GetAliasError::from_response(response))),
)
}
})
}
fn get_event_source_mapping(
&self,
input: GetEventSourceMappingRequest,
) -> RusotoFuture<EventSourceMappingConfiguration, GetEventSourceMappingError> {
let request_uri = format!(
"/2015-03-31/event-source-mappings/{uuid}",
uuid = input.uuid
);
let mut request = SignedRequest::new("GET", "lambda", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 200 {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result =
serde_json::from_slice::<EventSourceMappingConfiguration>(&body).unwrap();
result
}))
} else {
Box::new(
response.buffer().from_err().and_then(|response| {
Err(GetEventSourceMappingError::from_response(response))
}),
)
}
})
}
fn get_function(
&self,
input: GetFunctionRequest,
) -> RusotoFuture<GetFunctionResponse, GetFunctionError> {
let request_uri = format!(
"/2015-03-31/functions/{function_name}",
function_name = input.function_name
);
let mut request = SignedRequest::new("GET", "lambda", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let mut params = Params::new();
if let Some(ref x) = input.qualifier {
params.put("Qualifier", x);
}
request.set_params(params);
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 200 {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result = serde_json::from_slice::<GetFunctionResponse>(&body).unwrap();
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(GetFunctionError::from_response(response))),
)
}
})
}
fn get_function_configuration(
&self,
input: GetFunctionConfigurationRequest,
) -> RusotoFuture<FunctionConfiguration, GetFunctionConfigurationError> {
let request_uri = format!(
"/2015-03-31/functions/{function_name}/configuration",
function_name = input.function_name
);
let mut request = SignedRequest::new("GET", "lambda", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let mut params = Params::new();
if let Some(ref x) = input.qualifier {
params.put("Qualifier", x);
}
request.set_params(params);
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 200 {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result = serde_json::from_slice::<FunctionConfiguration>(&body).unwrap();
result
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(GetFunctionConfigurationError::from_response(response))
}))
}
})
}
fn get_layer_version(
&self,
input: GetLayerVersionRequest,
) -> RusotoFuture<GetLayerVersionResponse, GetLayerVersionError> {
let request_uri = format!(
"/2018-10-31/layers/{layer_name}/versions/{version_number}",
layer_name = input.layer_name,
version_number = input.version_number
);
let mut request = SignedRequest::new("GET", "lambda", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 200 {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result = serde_json::from_slice::<GetLayerVersionResponse>(&body).unwrap();
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(GetLayerVersionError::from_response(response))),
)
}
})
}
fn get_layer_version_policy(
&self,
input: GetLayerVersionPolicyRequest,
) -> RusotoFuture<GetLayerVersionPolicyResponse, GetLayerVersionPolicyError> {
let request_uri = format!(
"/2018-10-31/layers/{layer_name}/versions/{version_number}/policy",
layer_name = input.layer_name,
version_number = input.version_number
);
let mut request = SignedRequest::new("GET", "lambda", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 200 {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result =
serde_json::from_slice::<GetLayerVersionPolicyResponse>(&body).unwrap();
result
}))
} else {
Box::new(
response.buffer().from_err().and_then(|response| {
Err(GetLayerVersionPolicyError::from_response(response))
}),
)
}
})
}
fn get_policy(
&self,
input: GetPolicyRequest,
) -> RusotoFuture<GetPolicyResponse, GetPolicyError> {
let request_uri = format!(
"/2015-03-31/functions/{function_name}/policy",
function_name = input.function_name
);
let mut request = SignedRequest::new("GET", "lambda", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let mut params = Params::new();
if let Some(ref x) = input.qualifier {
params.put("Qualifier", x);
}
request.set_params(params);
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 200 {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result = serde_json::from_slice::<GetPolicyResponse>(&body).unwrap();
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(GetPolicyError::from_response(response))),
)
}
})
}
fn invoke(&self, input: InvocationRequest) -> RusotoFuture<InvocationResponse, InvokeError> {
let request_uri = format!(
"/2015-03-31/functions/{function_name}/invocations",
function_name = input.function_name
);
let mut request = SignedRequest::new("POST", "lambda", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = if let Some(ref payload) = input.payload {
Some(payload.to_owned())
} else {
None
};
request.set_payload(encoded);
if let Some(ref client_context) = input.client_context {
request.add_header("X-Amz-Client-Context", &client_context.to_string());
}
if let Some(ref invocation_type) = input.invocation_type {
request.add_header("X-Amz-Invocation-Type", &invocation_type.to_string());
}
if let Some(ref log_type) = input.log_type {
request.add_header("X-Amz-Log-Type", &log_type.to_string());
}
let mut params = Params::new();
if let Some(ref x) = input.qualifier {
params.put("Qualifier", x);
}
request.set_params(params);
self.client.sign_and_dispatch(request, |response| {
if response.status.is_success() {
Box::new(response.buffer().from_err().map(|response| {
let mut result = InvocationResponse::default();
result.payload = Some(response.body);
if let Some(executed_version) = response.headers.get("X-Amz-Executed-Version") {
let value = executed_version.to_owned();
result.executed_version = Some(value)
};
if let Some(function_error) = response.headers.get("X-Amz-Function-Error") {
let value = function_error.to_owned();
result.function_error = Some(value)
};
if let Some(log_result) = response.headers.get("X-Amz-Log-Result") {
let value = log_result.to_owned();
result.log_result = Some(value)
};
result.status_code = Some(response.status.as_u16() as i64);
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(InvokeError::from_response(response))),
)
}
})
}
fn invoke_async(
&self,
input: InvokeAsyncRequest,
) -> RusotoFuture<InvokeAsyncResponse, InvokeAsyncError> {
let request_uri = format!(
"/2014-11-13/functions/{function_name}/invoke-async/",
function_name = input.function_name
);
let mut request = SignedRequest::new("POST", "lambda", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(input.invoke_args.to_owned());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 202 {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let mut result = serde_json::from_slice::<InvokeAsyncResponse>(&body).unwrap();
result.status = Some(response.status.as_u16() as i64);
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(InvokeAsyncError::from_response(response))),
)
}
})
}
fn list_aliases(
&self,
input: ListAliasesRequest,
) -> RusotoFuture<ListAliasesResponse, ListAliasesError> {
let request_uri = format!(
"/2015-03-31/functions/{function_name}/aliases",
function_name = input.function_name
);
let mut request = SignedRequest::new("GET", "lambda", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let mut params = Params::new();
if let Some(ref x) = input.function_version {
params.put("FunctionVersion", x);
}
if let Some(ref x) = input.marker {
params.put("Marker", x);
}
if let Some(ref x) = input.max_items {
params.put("MaxItems", x);
}
request.set_params(params);
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 200 {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result = serde_json::from_slice::<ListAliasesResponse>(&body).unwrap();
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(ListAliasesError::from_response(response))),
)
}
})
}
fn list_event_source_mappings(
&self,
input: ListEventSourceMappingsRequest,
) -> RusotoFuture<ListEventSourceMappingsResponse, ListEventSourceMappingsError> {
let request_uri = "/2015-03-31/event-source-mappings/";
let mut request = SignedRequest::new("GET", "lambda", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let mut params = Params::new();
if let Some(ref x) = input.event_source_arn {
params.put("EventSourceArn", x);
}
if let Some(ref x) = input.function_name {
params.put("FunctionName", x);
}
if let Some(ref x) = input.marker {
params.put("Marker", x);
}
if let Some(ref x) = input.max_items {
params.put("MaxItems", x);
}
request.set_params(params);
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 200 {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result =
serde_json::from_slice::<ListEventSourceMappingsResponse>(&body).unwrap();
result
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(ListEventSourceMappingsError::from_response(response))
}))
}
})
}
fn list_functions(
&self,
input: ListFunctionsRequest,
) -> RusotoFuture<ListFunctionsResponse, ListFunctionsError> {
let request_uri = "/2015-03-31/functions/";
let mut request = SignedRequest::new("GET", "lambda", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let mut params = Params::new();
if let Some(ref x) = input.function_version {
params.put("FunctionVersion", x);
}
if let Some(ref x) = input.marker {
params.put("Marker", x);
}
if let Some(ref x) = input.master_region {
params.put("MasterRegion", x);
}
if let Some(ref x) = input.max_items {
params.put("MaxItems", x);
}
request.set_params(params);
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 200 {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result = serde_json::from_slice::<ListFunctionsResponse>(&body).unwrap();
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(ListFunctionsError::from_response(response))),
)
}
})
}
fn list_layer_versions(
&self,
input: ListLayerVersionsRequest,
) -> RusotoFuture<ListLayerVersionsResponse, ListLayerVersionsError> {
let request_uri = format!(
"/2018-10-31/layers/{layer_name}/versions",
layer_name = input.layer_name
);
let mut request = SignedRequest::new("GET", "lambda", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let mut params = Params::new();
if let Some(ref x) = input.compatible_runtime {
params.put("CompatibleRuntime", x);
}
if let Some(ref x) = input.marker {
params.put("Marker", x);
}
if let Some(ref x) = input.max_items {
params.put("MaxItems", x);
}
request.set_params(params);
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 200 {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result =
serde_json::from_slice::<ListLayerVersionsResponse>(&body).unwrap();
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(ListLayerVersionsError::from_response(response))),
)
}
})
}
fn list_layers(
&self,
input: ListLayersRequest,
) -> RusotoFuture<ListLayersResponse, ListLayersError> {
let request_uri = "/2018-10-31/layers";
let mut request = SignedRequest::new("GET", "lambda", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let mut params = Params::new();
if let Some(ref x) = input.compatible_runtime {
params.put("CompatibleRuntime", x);
}
if let Some(ref x) = input.marker {
params.put("Marker", x);
}
if let Some(ref x) = input.max_items {
params.put("MaxItems", x);
}
request.set_params(params);
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 200 {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result = serde_json::from_slice::<ListLayersResponse>(&body).unwrap();
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(ListLayersError::from_response(response))),
)
}
})
}
fn list_tags(&self, input: ListTagsRequest) -> RusotoFuture<ListTagsResponse, ListTagsError> {
let request_uri = format!("/2017-03-31/tags/{arn}", arn = input.resource);
let mut request = SignedRequest::new("GET", "lambda", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
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 == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result = serde_json::from_slice::<ListTagsResponse>(&body).unwrap();
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(ListTagsError::from_response(response))),
)
}
})
}
fn list_versions_by_function(
&self,
input: ListVersionsByFunctionRequest,
) -> RusotoFuture<ListVersionsByFunctionResponse, ListVersionsByFunctionError> {
let request_uri = format!(
"/2015-03-31/functions/{function_name}/versions",
function_name = input.function_name
);
let mut request = SignedRequest::new("GET", "lambda", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let mut params = Params::new();
if let Some(ref x) = input.marker {
params.put("Marker", x);
}
if let Some(ref x) = input.max_items {
params.put("MaxItems", x);
}
request.set_params(params);
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 200 {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result =
serde_json::from_slice::<ListVersionsByFunctionResponse>(&body).unwrap();
result
}))
} else {
Box::new(
response.buffer().from_err().and_then(|response| {
Err(ListVersionsByFunctionError::from_response(response))
}),
)
}
})
}
fn publish_layer_version(
&self,
input: PublishLayerVersionRequest,
) -> RusotoFuture<PublishLayerVersionResponse, PublishLayerVersionError> {
let request_uri = format!(
"/2018-10-31/layers/{layer_name}/versions",
layer_name = input.layer_name
);
let mut request = SignedRequest::new("POST", "lambda", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 201 {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result =
serde_json::from_slice::<PublishLayerVersionResponse>(&body).unwrap();
result
}))
} else {
Box::new(
response.buffer().from_err().and_then(|response| {
Err(PublishLayerVersionError::from_response(response))
}),
)
}
})
}
fn publish_version(
&self,
input: PublishVersionRequest,
) -> RusotoFuture<FunctionConfiguration, PublishVersionError> {
let request_uri = format!(
"/2015-03-31/functions/{function_name}/versions",
function_name = input.function_name
);
let mut request = SignedRequest::new("POST", "lambda", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 201 {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result = serde_json::from_slice::<FunctionConfiguration>(&body).unwrap();
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(PublishVersionError::from_response(response))),
)
}
})
}
fn put_function_concurrency(
&self,
input: PutFunctionConcurrencyRequest,
) -> RusotoFuture<Concurrency, PutFunctionConcurrencyError> {
let request_uri = format!(
"/2017-10-31/functions/{function_name}/concurrency",
function_name = input.function_name
);
let mut request = SignedRequest::new("PUT", "lambda", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 200 {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result = serde_json::from_slice::<Concurrency>(&body).unwrap();
result
}))
} else {
Box::new(
response.buffer().from_err().and_then(|response| {
Err(PutFunctionConcurrencyError::from_response(response))
}),
)
}
})
}
fn remove_layer_version_permission(
&self,
input: RemoveLayerVersionPermissionRequest,
) -> RusotoFuture<(), RemoveLayerVersionPermissionError> {
let request_uri = format!(
"/2018-10-31/layers/{layer_name}/versions/{version_number}/policy/{statement_id}",
layer_name = input.layer_name,
statement_id = input.statement_id,
version_number = input.version_number
);
let mut request = SignedRequest::new("DELETE", "lambda", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let mut params = Params::new();
if let Some(ref x) = input.revision_id {
params.put("RevisionId", x);
}
request.set_params(params);
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 204 {
Box::new(response.buffer().from_err().map(|response| {
let result = ::std::mem::drop(response);
result
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(RemoveLayerVersionPermissionError::from_response(response))
}))
}
})
}
fn remove_permission(
&self,
input: RemovePermissionRequest,
) -> RusotoFuture<(), RemovePermissionError> {
let request_uri = format!(
"/2015-03-31/functions/{function_name}/policy/{statement_id}",
function_name = input.function_name,
statement_id = input.statement_id
);
let mut request = SignedRequest::new("DELETE", "lambda", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let mut params = Params::new();
if let Some(ref x) = input.qualifier {
params.put("Qualifier", x);
}
if let Some(ref x) = input.revision_id {
params.put("RevisionId", x);
}
request.set_params(params);
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 204 {
Box::new(response.buffer().from_err().map(|response| {
let result = ::std::mem::drop(response);
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(RemovePermissionError::from_response(response))),
)
}
})
}
fn tag_resource(&self, input: TagResourceRequest) -> RusotoFuture<(), TagResourceError> {
let request_uri = format!("/2017-03-31/tags/{arn}", arn = input.resource);
let mut request = SignedRequest::new("POST", "lambda", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 204 {
Box::new(response.buffer().from_err().map(|response| {
let result = ::std::mem::drop(response);
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(TagResourceError::from_response(response))),
)
}
})
}
fn untag_resource(&self, input: UntagResourceRequest) -> RusotoFuture<(), UntagResourceError> {
let request_uri = format!("/2017-03-31/tags/{arn}", arn = input.resource);
let mut request = SignedRequest::new("DELETE", "lambda", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let mut params = Params::new();
for item in input.tag_keys.iter() {
params.put("tagKeys", item);
}
request.set_params(params);
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 204 {
Box::new(response.buffer().from_err().map(|response| {
let result = ::std::mem::drop(response);
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(UntagResourceError::from_response(response))),
)
}
})
}
fn update_alias(
&self,
input: UpdateAliasRequest,
) -> RusotoFuture<AliasConfiguration, UpdateAliasError> {
let request_uri = format!(
"/2015-03-31/functions/{function_name}/aliases/{name}",
function_name = input.function_name,
name = input.name
);
let mut request = SignedRequest::new("PUT", "lambda", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 200 {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result = serde_json::from_slice::<AliasConfiguration>(&body).unwrap();
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(UpdateAliasError::from_response(response))),
)
}
})
}
fn update_event_source_mapping(
&self,
input: UpdateEventSourceMappingRequest,
) -> RusotoFuture<EventSourceMappingConfiguration, UpdateEventSourceMappingError> {
let request_uri = format!(
"/2015-03-31/event-source-mappings/{uuid}",
uuid = input.uuid
);
let mut request = SignedRequest::new("PUT", "lambda", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 202 {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result =
serde_json::from_slice::<EventSourceMappingConfiguration>(&body).unwrap();
result
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(UpdateEventSourceMappingError::from_response(response))
}))
}
})
}
fn update_function_code(
&self,
input: UpdateFunctionCodeRequest,
) -> RusotoFuture<FunctionConfiguration, UpdateFunctionCodeError> {
let request_uri = format!(
"/2015-03-31/functions/{function_name}/code",
function_name = input.function_name
);
let mut request = SignedRequest::new("PUT", "lambda", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 200 {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result = serde_json::from_slice::<FunctionConfiguration>(&body).unwrap();
result
}))
} else {
Box::new(
response
.buffer()
.from_err()
.and_then(|response| Err(UpdateFunctionCodeError::from_response(response))),
)
}
})
}
fn update_function_configuration(
&self,
input: UpdateFunctionConfigurationRequest,
) -> RusotoFuture<FunctionConfiguration, UpdateFunctionConfigurationError> {
let request_uri = format!(
"/2015-03-31/functions/{function_name}/configuration",
function_name = input.function_name
);
let mut request = SignedRequest::new("PUT", "lambda", &self.region, &request_uri);
request.set_content_type("application/x-amz-json-1.1".to_owned());
let encoded = Some(serde_json::to_vec(&input).unwrap());
request.set_payload(encoded);
self.client.sign_and_dispatch(request, |response| {
if response.status.as_u16() == 200 {
Box::new(response.buffer().from_err().map(|response| {
let mut body = response.body;
if body == b"null" || body.is_empty() {
body = b"{}".to_vec();
}
debug!("Response body: {:?}", body);
debug!("Response status: {}", response.status);
let result = serde_json::from_slice::<FunctionConfiguration>(&body).unwrap();
result
}))
} else {
Box::new(response.buffer().from_err().and_then(|response| {
Err(UpdateFunctionConfigurationError::from_response(response))
}))
}
})
}
}
#[cfg(test)]
mod protocol_tests {}