1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[aws|elasticache] implement describe_engine_default_parameters request

This commit is contained in:
Benton Roberts 2011-09-23 18:00:50 -04:00 committed by geemus
parent 56d2c35fab
commit 0cf36a63b6
6 changed files with 132 additions and 1 deletions

View file

@ -21,7 +21,7 @@ module Fog
request :describe_cache_parameter_groups
#request :modify_cache_parameter_group
#request :reset_cache_parameter_group
#request :describe_engine_default_parameters
request :describe_engine_default_parameters
#request :describe_cache_parameters
request :create_cache_security_group

View file

@ -0,0 +1,22 @@
module Fog
module Parsers
module AWS
module Elasticache
require 'fog/aws/parsers/elasticache/engine_defaults_parser'
class DescribeEngineDefaultParameters < EngineDefaultsParser
def end_element(name)
case name
when 'EngineDefaults'
@response[name] = @engine_defaults
reset_engine_defaults
else
super
end
end
end
end
end
end
end

View file

@ -0,0 +1,59 @@
module Fog
module Parsers
module AWS
module Elasticache
require 'fog/aws/parsers/elasticache/base'
class EngineDefaultsParser < Base
def reset
super
reset_engine_defaults
end
def reset_engine_defaults
@engine_defaults = {
'CacheNodeTypeSpecificParameters' => [],
'Parameters' => [],
}
end
def start_element(name, attrs = [])
case name
when 'CacheNodeTypeSpecificParameter', 'Parameter'
@parameter = {}
when 'CacheNodeTypeSpecificValues'
@parameter[name] = []
when 'CacheNodeTypeSpecificValue'
@node_specific_value = {}
else
super
end
end
def end_element(name)
case name
when 'CacheParameterGroupFamily'
@engine_defaults[name] = value
when 'CacheNodeTypeSpecificParameter', 'Parameter'
if not @parameter.empty?
@engine_defaults["#{name}s"] << @parameter
end
when 'AllowedValues', 'DataType', 'Description', 'IsModifiable',
'MinimumEngineVersion', 'ParameterName', 'Source'
@parameter[name] = value
when 'CacheNodeType', 'Value'
@node_specific_value[name] = value
when 'CacheNodeTypeSpecificValue'
if not @node_specific_value.empty?
@parameter["#{name}s"] << @node_specific_value
end
else
super
end
end
end
end
end
end
end

View file

@ -0,0 +1,35 @@
module Fog
module AWS
class Elasticache
class Real
require 'fog/aws/parsers/elasticache/describe_engine_default_parameters'
# Returns the default engine and system parameter information
# for the specified cache engine.
#
# === Parameters (optional)
# * options <~Hash>:
# * :engine <~String> - the engine whose parameters are requested
# * :marker <~String> - marker provided in the previous request
# * :max_records <~Integer> - the maximum number of records to include
def describe_engine_default_parameters(options = {})
request({
'Action' => 'DescribeEngineDefaultParameters',
'CacheParameterGroupFamily' => options[:engine] || 'memcached1.4',
'Marker' => options[:marker],
'MaxRecords' => options[:max_records],
:parser => Fog::Parsers::AWS::Elasticache::DescribeEngineDefaultParameters.new
})
end
end
class Mock
def describe_engine_defalut_parameters(options = {})
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -25,6 +25,12 @@ class AWS
SINGLE_PARAMETER_GROUP = BASIC.merge('CacheParameterGroup' => PARAMETER_GROUP)
DESCRIBE_PARAMETER_GROUPS = BASIC.merge('CacheParameterGroups' => [PARAMETER_GROUP])
ENGINE_DEFAULTS = {
'CacheParameterGroupFamily' => String,
'Parameters' => Array,
'CacheNodeTypeSpecificParameters' => Array,
}
# Cache Clusters - more parameters get added as the lifecycle progresses
CACHE_CLUSTER = {
'AutoMinorVersionUpgrade' => String, # actually TrueClass or FalseClass

View file

@ -6,6 +6,15 @@ Shindo.tests('AWS::Elasticache | parameter group requests', ['aws', 'elasticache
name = 'fog-test'
description = 'Fog Test Parameter Group'
tests(
'#describe_engine_default_parameters'
).formats(AWS::Elasticache::Formats::ENGINE_DEFAULTS) do
response = AWS[:elasticache].describe_engine_default_parameters
engine_defaults = response.body['EngineDefaults']
returns('memcached1.4') { engine_defaults['CacheParameterGroupFamily'] }
engine_defaults
end
tests(
'#create_cache_parameter_group'
).formats(AWS::Elasticache::Formats::SINGLE_PARAMETER_GROUP) do