1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/aws/models/ec2/security_groups.rb

38 lines
718 B
Ruby
Raw Normal View History

2010-03-16 15:46:21 -07:00
require 'fog/collection'
require 'fog/aws/models/ec2/security_group'
2009-09-18 08:56:42 -07:00
module Fog
module AWS
class EC2
2009-09-18 08:56:42 -07:00
class SecurityGroups < Fog::Collection
attribute :group_name
model Fog::AWS::EC2::SecurityGroup
def initialize(attributes)
@group_name ||= []
super
end
def all(group_name = @group_name)
2010-01-04 22:03:24 -08:00
@group_name = group_name
2009-09-28 20:00:49 -07:00
data = connection.describe_security_groups(group_name).body
load(data['securityGroupInfo'])
2009-09-18 08:56:42 -07:00
end
def get(group_name)
2009-10-22 20:46:15 -07:00
if group_name
all(group_name).first
end
rescue Fog::Errors::NotFound
nil
end
2009-09-18 08:56:42 -07:00
end
end
end
end