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

[aws|elasticache] implement reset_cache_parameter_group request

This commit is contained in:
Benton Roberts 2011-09-26 09:52:17 -04:00 committed by geemus
parent 6e5e7f9ef4
commit e6a7bff3fb
4 changed files with 104 additions and 9 deletions

View file

@ -20,7 +20,7 @@ module Fog
request :delete_cache_parameter_group
request :describe_cache_parameter_groups
request :modify_cache_parameter_group
#request :reset_cache_parameter_group
request :reset_cache_parameter_group
request :describe_engine_default_parameters
#request :describe_cache_parameters

View file

@ -0,0 +1,27 @@
module Fog
module Parsers
module AWS
module Elasticache
require 'fog/aws/parsers/elasticache/parameter_group_parser'
class ResetParameterGroup < ParameterGroupParser
def reset
super
@response['ResetCacheParameterGroupResult'] = []
end
def end_element(name)
case name
when 'ResetCacheParameterGroupResult'
@response[name] = @parameter_group
reset_parameter_group
else
super
end
end
end
end
end
end
end

View file

@ -0,0 +1,46 @@
module Fog
module AWS
class Elasticache
class Real
require 'fog/aws/parsers/elasticache/reset_parameter_group'
# Resets an existing cache parameter group
# Returns a the name of the modified parameter group
#
# === Required Parameters
# * id <~String> - The ID of the parameter group to be modified
# === Optional Parameters
# * parameter_names <~Array> - The parameters to reset
# === Returns
# * response <~Excon::Response>:
# * body <~Hash>
def reset_cache_parameter_group(id, parameter_names = [])
# Construct Parameter resets in the format:
# ParameterNameValues.member.N => "param_name"
parameter_changes = parameter_names.inject({}) do |new_args, param|
index = parameter_names.index(param) + 1
new_args["ParameterNameValues.member.#{index}"] = param
new_args
end
if parameter_changes.empty?
parameter_changes = {'ResetAllParameters' => 'true'}
end
# Merge the Cache Security Group parameters with the normal options
request(parameter_changes.merge(
'Action' => 'ResetCacheParameterGroup',
'CacheParameterGroupName' => id,
:parser => Fog::Parsers::AWS::Elasticache::ResetParameterGroup.new
))
end
end
class Mock
def reset_cache_parameter_group(id, parameter_names)
Fog::Mock.not_implemented
end
end
end
end
end

View file

@ -39,14 +39,13 @@ Shindo.tests('AWS::Elasticache | parameter group requests', ['aws', 'elasticache
end
tests(
'#describe_cache_parameter_groups with name'
).formats(AWS::Elasticache::Formats::DESCRIBE_PARAMETER_GROUPS) do
body = AWS[:elasticache].describe_cache_parameter_groups(name).body
returns(1, "size of 1") { body['CacheParameterGroups'].size }
returns(name, "has #{name}") do
body['CacheParameterGroups'].first['CacheParameterGroupName']
end
body
'#reset_cache_parameter_group completely'
).formats('CacheParameterGroupName' => String) do
result = AWS[:elasticache].reset_cache_parameter_group(
name
).body['ResetCacheParameterGroupResult']
returns(name) {result['CacheParameterGroupName']}
result
end
tests(
@ -59,6 +58,29 @@ Shindo.tests('AWS::Elasticache | parameter group requests', ['aws', 'elasticache
result
end
# BUG: returns "MalformedInput - Unexpected complex element termination"
tests(
'#reset_cache_parameter_group with one parameter'
).formats('CacheParameterGroupName' => String) do
pending
result = AWS[:elasticache].reset_cache_parameter_group(
name, ["chunk_size"]
).body['ResetCacheParameterGroupResult']
returns(name) {result['CacheParameterGroupName']}
result
end
tests(
'#describe_cache_parameter_groups with name'
).formats(AWS::Elasticache::Formats::DESCRIBE_PARAMETER_GROUPS) do
body = AWS[:elasticache].describe_cache_parameter_groups(name).body
returns(1, "size of 1") { body['CacheParameterGroups'].size }
returns(name, "has #{name}") do
body['CacheParameterGroups'].first['CacheParameterGroupName']
end
body
end
tests(
'#delete_cache_parameter_group'
).formats(AWS::Elasticache::Formats::BASIC) do