Sha256: c774565cbfd2c64e9b7b7f23b4864ab83758f5fb33be7e78fbe04ced505d4c06

Contents?: true

Size: 1.44 KB

Versions: 16

Compression:

Stored size: 1.44 KB

Contents

module Fog
  module AWS
    class EC2

      def security_groups
        Fog::AWS::EC2::SecurityGroups.new(:connection => self)
      end

      class SecurityGroups < Fog::Collection

        attribute :group_name

        def initialize(attributes)
          @group_name ||= []
          super
        end

        def all(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({
              :connection       => connection,
              :security_groups  => self
            }.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

        def new(attributes = {})
          Fog::AWS::EC2::SecurityGroup.new(
            attributes.merge!(
              :connection => connection,
              :security_groups  => self
            )
          )
        end

        def reload
          all(group_name)
        end

      end

    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
fog-0.0.25 lib/fog/aws/models/ec2/security_groups.rb
fog-0.0.24 lib/fog/aws/models/ec2/security_groups.rb
fog-0.0.23 lib/fog/aws/models/ec2/security_groups.rb
fog-0.0.22 lib/fog/aws/models/ec2/security_groups.rb
fog-0.0.21 lib/fog/aws/models/ec2/security_groups.rb
fog-0.0.20 lib/fog/aws/models/ec2/security_groups.rb
fog-0.0.19 lib/fog/aws/models/ec2/security_groups.rb
fog-0.0.18 lib/fog/aws/models/ec2/security_groups.rb
fog-0.0.17 lib/fog/aws/models/ec2/security_groups.rb
fog-0.0.16 lib/fog/aws/models/ec2/security_groups.rb
fog-0.0.15 lib/fog/aws/models/ec2/security_groups.rb
fog-0.0.14 lib/fog/aws/models/ec2/security_groups.rb
fog-0.0.13 lib/fog/aws/models/ec2/security_groups.rb
fog-0.0.12 lib/fog/aws/models/ec2/security_groups.rb
fog-0.0.11 lib/fog/aws/models/ec2/security_groups.rb
fog-0.0.10 lib/fog/aws/models/ec2/security_groups.rb