Sha256: 1dc4adde3dce13884f358abe956add6777299754f0ba1a2a3290e2a5cb61ad1b

Contents?: true

Size: 1.83 KB

Versions: 36

Compression:

Stored size: 1.83 KB

Contents

module Fog
  module AWS
    class Compute
      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'
        attribute :default_for_az,              :aliases => 'defaultForAz'

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

        def network_interfaces
          service.network_interfaces.all('subnet-id' => [self.identity])
        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

36 entries across 36 versions & 1 rubygems

Version Path
fog-aws-3.29.0 lib/fog/aws/models/compute/subnet.rb
fog-aws-3.28.0 lib/fog/aws/models/compute/subnet.rb
fog-aws-3.27.0 lib/fog/aws/models/compute/subnet.rb
fog-aws-3.26.0 lib/fog/aws/models/compute/subnet.rb
fog-aws-3.25.0 lib/fog/aws/models/compute/subnet.rb
fog-aws-3.24.0 lib/fog/aws/models/compute/subnet.rb
fog-aws-3.23.0 lib/fog/aws/models/compute/subnet.rb
fog-aws-3.22.0 lib/fog/aws/models/compute/subnet.rb
fog-aws-3.21.1 lib/fog/aws/models/compute/subnet.rb
fog-aws-3.21.0 lib/fog/aws/models/compute/subnet.rb
fog-aws-3.20.0 lib/fog/aws/models/compute/subnet.rb
fog-aws-3.19.0 lib/fog/aws/models/compute/subnet.rb
fog-aws-3.18.0 lib/fog/aws/models/compute/subnet.rb
fog-aws-3.17.0 lib/fog/aws/models/compute/subnet.rb
fog-aws-3.16.0 lib/fog/aws/models/compute/subnet.rb
fog-aws-3.15.0 lib/fog/aws/models/compute/subnet.rb
fog-aws-3.14.0 lib/fog/aws/models/compute/subnet.rb
fog-aws-3.13.0 lib/fog/aws/models/compute/subnet.rb
fog-aws-3.12.0 lib/fog/aws/models/compute/subnet.rb
fog-aws-3.11.0 lib/fog/aws/models/compute/subnet.rb