mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[aws|elasticache] implement modify_cache_parameter_group request
This commit is contained in:
parent
f397bf50ec
commit
6e5e7f9ef4
5 changed files with 84 additions and 2 deletions
|
@ -19,7 +19,7 @@ module Fog
|
|||
request :create_cache_parameter_group
|
||||
request :delete_cache_parameter_group
|
||||
request :describe_cache_parameter_groups
|
||||
#request :modify_cache_parameter_group
|
||||
request :modify_cache_parameter_group
|
||||
#request :reset_cache_parameter_group
|
||||
request :describe_engine_default_parameters
|
||||
#request :describe_cache_parameters
|
||||
|
|
27
lib/fog/aws/parsers/elasticache/modify_parameter_group.rb
Normal file
27
lib/fog/aws/parsers/elasticache/modify_parameter_group.rb
Normal file
|
@ -0,0 +1,27 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module AWS
|
||||
module Elasticache
|
||||
require 'fog/aws/parsers/elasticache/parameter_group_parser'
|
||||
|
||||
class ModifyParameterGroup < ParameterGroupParser
|
||||
|
||||
def reset
|
||||
super
|
||||
@response['ModifyCacheParameterGroupResult'] = []
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'ModifyCacheParameterGroupResult'
|
||||
@response[name] = @parameter_group
|
||||
reset_parameter_group
|
||||
else
|
||||
super
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,45 @@
|
|||
module Fog
|
||||
module AWS
|
||||
class Elasticache
|
||||
class Real
|
||||
|
||||
require 'fog/aws/parsers/elasticache/modify_parameter_group'
|
||||
|
||||
# Modifies 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
|
||||
# * new_parameters <~Hash> - The parameters to modify, and their values
|
||||
# === Returns
|
||||
# * response <~Excon::Response>:
|
||||
# * body <~Hash>
|
||||
def modify_cache_parameter_group(id, new_parameters)
|
||||
# Construct Parameter Modifications in the format:
|
||||
# ParameterNameValues.member.N.ParameterName => "param_name"
|
||||
# ParameterNameValues.member.N.ParameterValue => "param_value"
|
||||
n = 0 # n is the parameter index
|
||||
parameter_changes = new_parameters.inject({}) do |new_args,pair|
|
||||
n += 1
|
||||
new_args["ParameterNameValues.member.#{n}.ParameterName"] = pair[0]
|
||||
new_args["ParameterNameValues.member.#{n}.ParameterValue"] = pair[1]
|
||||
new_args
|
||||
end
|
||||
# Merge the Cache Security Group parameters with the normal options
|
||||
request(parameter_changes.merge(
|
||||
'Action' => 'ModifyCacheParameterGroup',
|
||||
'CacheParameterGroupName' => id,
|
||||
:parser => Fog::Parsers::AWS::Elasticache::ModifyParameterGroup.new
|
||||
))
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
def modify_cache_parameter_group(id, new_parameters)
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -24,7 +24,7 @@ class AWS
|
|||
}
|
||||
SINGLE_PARAMETER_GROUP = BASIC.merge('CacheParameterGroup' => PARAMETER_GROUP)
|
||||
DESCRIBE_PARAMETER_GROUPS = BASIC.merge('CacheParameterGroups' => [PARAMETER_GROUP])
|
||||
|
||||
MODIFY_PARAMETER_GROUP = {'CacheParameterGroupName' => String }
|
||||
ENGINE_DEFAULTS = {
|
||||
'CacheParameterGroupFamily' => String,
|
||||
'Parameters' => Array,
|
||||
|
|
|
@ -49,6 +49,16 @@ Shindo.tests('AWS::Elasticache | parameter group requests', ['aws', 'elasticache
|
|||
body
|
||||
end
|
||||
|
||||
tests(
|
||||
'#modify_cache_parameter_group'
|
||||
).formats('CacheParameterGroupName' => String) do
|
||||
result = AWS[:elasticache].modify_cache_parameter_group(
|
||||
name, {"chunk_size" => 32}
|
||||
).body['ModifyCacheParameterGroupResult']
|
||||
returns(name) {result['CacheParameterGroupName']}
|
||||
result
|
||||
end
|
||||
|
||||
tests(
|
||||
'#delete_cache_parameter_group'
|
||||
).formats(AWS::Elasticache::Formats::BASIC) do
|
||||
|
|
Loading…
Reference in a new issue