1
0
Fork 0
mirror of https://github.com/fog/fog-aws.git synced 2022-11-09 13:50:52 -05:00
fog--fog-aws/lib/fog/aws/models/elasticache/security_group.rb
Josh Lane d48d376e9c initial import
* take the liberty of correcting Aws naming
2014-12-31 09:17:51 -08:00

48 lines
1.4 KiB
Ruby

require 'fog/core/model'
module Fog
module AWS
class Elasticache
class SecurityGroup < Fog::Model
identity :id, :aliases => 'CacheSecurityGroupName'
attribute :description, :aliases => 'Description'
attribute :ec2_groups, :aliases => 'EC2SecurityGroups', :type => :array
attribute :owner_id, :aliases => 'OwnerId'
def ready?
ec2_groups.all?{|ingress| ingress['Status'] == 'authorized'}
end
def destroy
requires :id
service.delete_cache_security_group(id)
true
end
def save
requires :id
requires :description
service.create_cache_security_group(id, description)
end
def authorize_ec2_group(group_name, group_owner_id=owner_id)
requires :id
requires :owner_id if group_owner_id.nil?
data = service.authorize_cache_security_group_ingress(
id, group_name, group_owner_id
)
merge_attributes(data.body['CacheSecurityGroup'])
end
def revoke_ec2_group(group_name, group_owner_id=owner_id)
requires :id
requires :owner_id if group_owner_id.nil?
data = service.revoke_cache_security_group_ingress(
id, group_name, group_owner_id
)
merge_attributes(data.body['CacheSecurityGroup'])
end
end
end
end
end