Sha256: cb1bb366a409f438a404d6d9cd4bdaabff9d263b8e49a2a7aae6632c6c8c7a87

Contents?: true

Size: 989 Bytes

Versions: 48

Compression:

Stored size: 989 Bytes

Contents

require 'fog/collection'
require 'fog/aws/models/ec2/security_group'

module Fog
  module AWS
    module EC2

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

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

      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)
          @group_name = group_name
          data = connection.describe_security_groups(group_name).body
          load(data['securityGroupInfo'])
        end

        def get(group_name)
          if group_name
            all(group_name).first
          end
        rescue Excon::Errors::BadRequest
          nil
        end

      end

    end
  end
end

Version data entries

48 entries across 48 versions & 1 rubygems

Version Path
fog-0.1.3 lib/fog/aws/models/ec2/security_groups.rb
fog-0.1.2 lib/fog/aws/models/ec2/security_groups.rb
fog-0.1.1 lib/fog/aws/models/ec2/security_groups.rb
fog-0.1.0 lib/fog/aws/models/ec2/security_groups.rb
fog-0.0.100 lib/fog/aws/models/ec2/security_groups.rb
fog-0.0.99 lib/fog/aws/models/ec2/security_groups.rb
fog-0.0.98 lib/fog/aws/models/ec2/security_groups.rb
fog-0.0.97 lib/fog/aws/models/ec2/security_groups.rb
fog-0.0.96 lib/fog/aws/models/ec2/security_groups.rb
fog-0.0.95 lib/fog/aws/models/ec2/security_groups.rb
fog-0.0.94 lib/fog/aws/models/ec2/security_groups.rb
fog-0.0.93 lib/fog/aws/models/ec2/security_groups.rb
fog-0.0.92 lib/fog/aws/models/ec2/security_groups.rb
fog-0.0.91 lib/fog/aws/models/ec2/security_groups.rb
fog-0.0.90 lib/fog/aws/models/ec2/security_groups.rb
fog-0.0.89 lib/fog/aws/models/ec2/security_groups.rb
fog-0.0.88 lib/fog/aws/models/ec2/security_groups.rb
fog-0.0.87 lib/fog/aws/models/ec2/security_groups.rb
fog-0.0.86 lib/fog/aws/models/ec2/security_groups.rb
fog-0.0.85 lib/fog/aws/models/ec2/security_groups.rb