Sha256: bdbb5143057980b48f68be0951e4fd77830732b5e5bda59f9e6db44789d7d9ab

Contents?: true

Size: 1.67 KB

Versions: 11

Compression:

Stored size: 1.67 KB

Contents

require 'fog/core/model'

module Fog
  module Compute
    class AWS
      class Subnet < Fog::Model
        identity  :subnet_id,                   :aliases => 'subnetId'
        attribute :state
        attribute :vpc_id,                      :aliases => 'vpcId'
        attribute :cidr_block,                  :aliases => 'cidrBlock'
        attribute :available_ip_address_count,  :aliases => 'availableIpAddressCount'
        attribute :availability_zone,           :aliases => 'availabilityZone'
        attribute :tag_set,                     :aliases => 'tagSet'
        attribute :map_public_ip_on_launch,     :aliases => 'mapPublicIpOnLaunch'

        def ready?
          requires :state
          state == 'available'
        end

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

        def destroy
          requires :subnet_id

          service.delete_subnet(subnet_id)
          true
        end

        # Create a subnet
        #
        #  >> g = AWS.subnets.new(:vpc_id => "vpc-someId", :cidr_block => "10.0.0.0/24")
        #  >> g.save
        #
        # == Returns:
        #
        # requestId and a subnet object
        #

        def save
          requires :vpc_id, :cidr_block
          options = {}
          options['AvailabilityZone'] = availability_zone if availability_zone
          data = service.create_subnet(vpc_id, cidr_block, options).body['subnet']
          new_attributes = data.reject {|key,value| key == 'requestId'}
          merge_attributes(new_attributes)
          true

          true
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 3 rubygems

Version Path
fog-aws-0.1.1 lib/fog/aws/models/compute/subnet.rb
fog-aws-0.1.0 lib/fog/aws/models/compute/subnet.rb
fog-aws-0.0.8 lib/fog/aws/models/compute/subnet.rb
fog-aws-0.0.7 lib/fog/aws/models/compute/subnet.rb
fog-aws-0.0.6 lib/fog/aws/models/compute/subnet.rb
fog-aws-0.0.5 lib/fog/aws/models/compute/subnet.rb
fog-1.26.0 lib/fog/aws/models/compute/subnet.rb
fog-1.25.0 lib/fog/aws/models/compute/subnet.rb
nsidc-fog-1.24.1 lib/fog/aws/models/compute/subnet.rb
fog-1.24.0 lib/fog/aws/models/compute/subnet.rb
fog-1.23.0 lib/fog/aws/models/compute/subnet.rb