Sha256: e4a924ad292b99412154903c07ce450a011247e859894471de7ea6720af80068

Contents?: true

Size: 1.49 KB

Versions: 18

Compression:

Stored size: 1.49 KB

Contents

require 'fog/core/model'

module Fog
  module Compute
    class AWS

      class VPC < Fog::Model

        identity :id,                :aliases => 'vpcId'

        attribute :state
        attribute :cidr_block,       :aliases => 'cidrBlock'
        attribute :dhcp_options_id,  :aliases => 'dhcpOptionsId'
        attribute :tags,             :aliases => 'tagSet'
        attribute :tenancy,          :aliases => 'instanceTenancy'

        def initialize(attributes={})
          self.dhcp_options_id ||= "default"
          self.tenancy ||= "default"
          super
        end

        # Removes an existing vpc
        #
        # vpc.destroy
        #
        # ==== Returns
        #
        # True or false depending on the result
        #

        def destroy
          requires :id

          connection.delete_vpc(id)
          true
        end

        # Create a vpc
        #
        # >> g = AWS.vpcs.new(:cidr_block => "10.1.2.0/24")
        # >> g.save
        #
        # == Returns:
        #
        # True or an exception depending on the result. Keep in mind that this *creates* a new vpc.
        # As such, it yields an InvalidGroup.Duplicate exception if you attempt to save an existing vpc.
        #

        def save
          requires :cidr_block

          data = connection.create_vpc(cidr_block).body['vpcSet'].first
          new_attributes = data.reject {|key,value| key == 'requestId'}
          merge_attributes(new_attributes)
          true
        end

      end

    end
  end
end

Version data entries

18 entries across 18 versions & 9 rubygems

Version Path
fog-nirvanix-1.8.2 lib/fog/aws/models/compute/vpc.rb
fog-nirvanix-1.8.1 lib/fog/aws/models/compute/vpc.rb
fog-parser-fix-1.6.1 lib/fog/aws/models/compute/vpc.rb
fog-test-again-1.6.0 lib/fog/aws/models/compute/vpc.rb
fog-parser-fix-1.6.0 lib/fog/aws/models/compute/vpc.rb
ey-vendored-backup-3.0.27 vendor/gems/fog/lib/fog/aws/models/compute/vpc.rb
fog-sgonyea-1.8.1 lib/fog/aws/models/compute/vpc.rb
fog-1.8.0 lib/fog/aws/models/compute/vpc.rb
fog-maestrodev-1.7.0.20121114190951 lib/fog/aws/models/compute/vpc.rb
fog-1.7.0 lib/fog/aws/models/compute/vpc.rb
fog-1.6.0 lib/fog/aws/models/compute/vpc.rb
fog-1.5.0 lib/fog/aws/models/compute/vpc.rb
fog-1.4.0 lib/fog/aws/models/compute/vpc.rb
michiels-fog-1.3.1 lib/fog/aws/models/compute/vpc.rb
ftl-0.2.0 vendor/bundle/gems/fog-1.3.1/lib/fog/aws/models/compute/vpc.rb
fog-1.3.1 lib/fog/aws/models/compute/vpc.rb
fog-1.3.0 lib/fog/aws/models/compute/vpc.rb
fog-1.2.0 lib/fog/aws/models/compute/vpc.rb