Class: Fog::AWS::EC2::SecurityGroups
- Inherits:
-
Collection
- Object
- Array
- Collection
- Fog::AWS::EC2::SecurityGroups
- Defined in:
- lib/fog/aws/models/ec2/security_groups.rb
Instance Method Summary collapse
- #all(group_name = @group_name) ⇒ Object
- #get(group_name) ⇒ Object
-
#initialize(attributes) ⇒ SecurityGroups
constructor
A new instance of SecurityGroups.
Methods inherited from Collection
#_dump, _load, aliases, attribute, attributes, #attributes, #connection, #connection=, #create, #inspect, #merge_attributes, model, #model, #new, #reload
Constructor Details
#initialize(attributes) ⇒ SecurityGroups
Returns a new instance of SecurityGroups.
15 16 17 18 |
# File 'lib/fog/aws/models/ec2/security_groups.rb', line 15 def initialize(attributes) @group_name ||= [] super end |
Instance Method Details
#all(group_name = @group_name) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/fog/aws/models/ec2/security_groups.rb', line 20 def all(group_name = @group_name) data = connection.describe_security_groups(group_name).body security_groups = Fog::AWS::EC2::SecurityGroups.new({ :connection => connection, :group_name => group_name }.merge!(attributes)) data['securityGroupInfo'].each do |security_group| security_groups << Fog::AWS::EC2::SecurityGroup.new({ :collection => security_groups, :connection => connection }.merge!(security_group)) end security_groups end |
#get(group_name) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/fog/aws/models/ec2/security_groups.rb', line 35 def get(group_name) if group_name all(group_name).first end rescue Excon::Errors::BadRequest nil end |