mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[aws|elasticache] implement Elasticache::ParameterGroup model and collection
This commit is contained in:
parent
0cf36a63b6
commit
f397bf50ec
5 changed files with 86 additions and 8 deletions
|
@ -37,8 +37,8 @@ module Fog
|
|||
collection :clusters
|
||||
model :security_group
|
||||
collection :security_groups
|
||||
# model :parameter_group
|
||||
# collection :parameter_groups
|
||||
model :parameter_group
|
||||
collection :parameter_groups
|
||||
|
||||
class Mock
|
||||
def initalize(options={})
|
||||
|
@ -103,9 +103,8 @@ module Fog
|
|||
rescue Excon::Errors::HTTPStatusError => error
|
||||
if match = error.message.match(/<Code>(.*)<\/Code>/m)
|
||||
case match[1]
|
||||
when 'CacheSecurityGroupNotFound'
|
||||
raise Fog::AWS::Elasticache::NotFound
|
||||
when 'CacheClusterNotFound'
|
||||
when 'CacheSecurityGroupNotFound', 'CacheParameterGroupNotFound',
|
||||
'CacheClusterNotFound'
|
||||
raise Fog::AWS::Elasticache::NotFound
|
||||
when 'CacheSecurityGroupAlreadyExists'
|
||||
raise Fog::AWS::Elasticache::IdentifierTaken
|
||||
|
|
32
lib/fog/aws/models/elasticache/parameter_group.rb
Normal file
32
lib/fog/aws/models/elasticache/parameter_group.rb
Normal file
|
@ -0,0 +1,32 @@
|
|||
require 'fog/core/model'
|
||||
|
||||
module Fog
|
||||
module AWS
|
||||
class Elasticache
|
||||
|
||||
class ParameterGroup < Fog::Model
|
||||
|
||||
identity :id, :aliases => 'CacheParameterGroupName'
|
||||
attribute :description, :aliases => 'Description'
|
||||
attribute :family, :aliases => 'CacheParameterGroupFamily'
|
||||
|
||||
def destroy
|
||||
requires :id
|
||||
connection.delete_cache_parameter_group(id)
|
||||
true
|
||||
end
|
||||
|
||||
def save
|
||||
requires :id
|
||||
connection.create_cache_parameter_group(
|
||||
id,
|
||||
description = id,
|
||||
family = 'memcached1.4'
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
30
lib/fog/aws/models/elasticache/parameter_groups.rb
Normal file
30
lib/fog/aws/models/elasticache/parameter_groups.rb
Normal file
|
@ -0,0 +1,30 @@
|
|||
require 'fog/core/collection'
|
||||
require 'fog/aws/models/elasticache/parameter_group'
|
||||
|
||||
module Fog
|
||||
module AWS
|
||||
class Elasticache
|
||||
|
||||
class ParameterGroups < Fog::Collection
|
||||
model Fog::AWS::Elasticache::ParameterGroup
|
||||
|
||||
def all
|
||||
load(
|
||||
connection.describe_cache_parameter_groups.body['CacheParameterGroups']
|
||||
)
|
||||
end
|
||||
|
||||
def get(identity)
|
||||
new(
|
||||
connection.describe_cache_parameter_groups(
|
||||
identity
|
||||
).body['CacheParameterGroups'].first
|
||||
)
|
||||
rescue Fog::AWS::Elasticache::NotFound
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -15,8 +15,7 @@ module Fog
|
|||
# === Returns
|
||||
# * response <~Excon::Response>:
|
||||
# * body <~Hash>
|
||||
def create_cache_parameter_group(name, description = name,
|
||||
family = 'memcached1.4')
|
||||
def create_cache_parameter_group(name, description = name, family = 'memcached1.4')
|
||||
request({
|
||||
'Action' => 'CreateCacheParameterGroup',
|
||||
'CacheParameterGroupName' => name,
|
||||
|
@ -28,7 +27,8 @@ module Fog
|
|||
end
|
||||
|
||||
class Mock
|
||||
def create_cache_parameter_group(name, desciption=name)
|
||||
def create_cache_parameter_group(name, description = name,
|
||||
family = 'memcached1.4')
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
end
|
||||
|
|
17
tests/aws/models/elasticache/parameter_groups_tests.rb
Normal file
17
tests/aws/models/elasticache/parameter_groups_tests.rb
Normal file
|
@ -0,0 +1,17 @@
|
|||
Shindo.tests('AWS::Elasticache | parameter groups', ['aws', 'elasticache']) do
|
||||
group_name = 'fog-test'
|
||||
description = 'Fog Test'
|
||||
|
||||
pending if Fog.mocking?
|
||||
|
||||
model_tests(
|
||||
AWS[:elasticache].parameter_groups,
|
||||
{:id => group_name, :description => description}, false
|
||||
)
|
||||
|
||||
collection_tests(
|
||||
AWS[:elasticache].parameter_groups,
|
||||
{:id => group_name, :description => description}, false
|
||||
)
|
||||
|
||||
end
|
Loading…
Reference in a new issue