Sha256: 9ba2cc210cf8e954b147019f2b4fb572ed6e41da24f99164426f594e06d95268

Contents?: true

Size: 730 Bytes

Versions: 8

Compression:

Stored size: 730 Bytes

Contents

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

module Fog
  module AWS
    class Compute

      class SecurityGroups < Fog::Collection

        attribute :group_name

        model Fog::AWS::Compute::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 Fog::Errors::NotFound
          nil
        end

      end

    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
fog-0.3.7 lib/fog/aws/models/compute/security_groups.rb
fog-0.3.6 lib/fog/aws/models/compute/security_groups.rb
fog-0.3.5 lib/fog/aws/models/compute/security_groups.rb
fog-0.3.4 lib/fog/aws/models/compute/security_groups.rb
fog-0.3.3 lib/fog/aws/models/compute/security_groups.rb
fog-0.3.2 lib/fog/aws/models/compute/security_groups.rb
fog-0.3.1 lib/fog/aws/models/compute/security_groups.rb
fog-0.3.0 lib/fog/aws/models/compute/security_groups.rb