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

58 lines
1.3 KiB
Ruby
Raw Normal View History

2009-09-18 11:56:42 -04:00
module Fog
module AWS
class EC2
def security_groups
Fog::AWS::EC2::SecurityGroups.new(:connection => self)
end
class SecurityGroups < Fog::Collection
attribute :group_name
2009-09-18 11:56:42 -04:00
def all(group_name = [])
data = connection.describe_security_groups(group_name)
security_groups = Fog::AWS::EC2::SecurityGroups.new(
:connection => connection,
:group_name => group_name
)
2009-09-18 11:56:42 -04:00
data['securityGroupInfo'].each do |security_group|
security_groups << Fog::AWS::EC2::SecurityGroup.new({
:connection => connection,
:security_groups => self
2009-09-18 11:56:42 -04:00
}.merge!(security_group))
end
security_groups
end
def create(attributes = {})
security_group = new(attributes)
security_group.save
security_group
end
def get(group_name)
all(group_name).first
rescue Fog::Errors::BadRequest
nil
end
2009-09-18 11:56:42 -04:00
def new(attributes = {})
2009-09-20 12:21:03 -04:00
Fog::AWS::EC2::SecurityGroup.new(
attributes.merge!(
:connection => connection,
:security_groups => self
)
)
2009-09-18 11:56:42 -04:00
end
def reload
all(group_name)
end
2009-09-18 11:56:42 -04:00
end
end
end
end