Class: Fog::Compute::AWS::Subnet

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/aws/models/compute/subnet.rb

Instance Attribute Summary

Attributes inherited from Model

#collection, #service

Instance Method Summary collapse

Methods inherited from Model

#initialize, #inspect, #reload, #symbolize_keys, #to_json, #wait_for

Methods included from Attributes::ClassMethods

#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes

Methods included from Fog::Core::DeprecatedConnectionAccessors

#connection, #connection=, #prepare_service_value

Methods included from Attributes::InstanceMethods

#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #persisted?, #requires, #requires_one

Constructor Details

This class inherits a constructor from Fog::Model

Instance Method Details

#destroyObject

Removes an existing subnet

subnet.destroy

Returns

True or false depending on the result



31
32
33
34
35
36
# File 'lib/fog/aws/models/compute/subnet.rb', line 31

def destroy
  requires :subnet_id

  service.delete_subnet(subnet_id)
  true
end

#ready?Boolean

Returns:

  • (Boolean)


17
18
19
20
# File 'lib/fog/aws/models/compute/subnet.rb', line 17

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

#saveObject

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



48
49
50
51
52
53
54
55
56
57
58
# File 'lib/fog/aws/models/compute/subnet.rb', line 48

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