Class: Fog::Network::OpenStack::Port

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/openstack/models/network/port.rb

Instance Attribute Summary

Attributes inherited from Model

#collection, #service

Instance Method Summary collapse

Methods inherited from Model

#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 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

#initialize(attributes) ⇒ Port

Returns a new instance of Port.



19
20
21
22
23
# File 'lib/fog/openstack/models/network/port.rb', line 19

def initialize(attributes)
  # Old 'connection' is renamed as service and should be used instead
  prepare_service_value(attributes)
  super
end

Instance Method Details

#createObject



30
31
32
33
34
35
# File 'lib/fog/openstack/models/network/port.rb', line 30

def create
  requires :network_id
  merge_attributes(service.create_port(self.network_id,
                                          self.attributes).body['port'])
  self
end

#destroyObject



44
45
46
47
48
# File 'lib/fog/openstack/models/network/port.rb', line 44

def destroy
  requires :id
  service.delete_port(self.id)
  true
end

#saveObject



25
26
27
28
# File 'lib/fog/openstack/models/network/port.rb', line 25

def save
  requires :network_id
  identity ? update : create
end

#updateObject



37
38
39
40
41
42
# File 'lib/fog/openstack/models/network/port.rb', line 37

def update
  requires :id, :network_id
  merge_attributes(service.update_port(self.id,
                                          self.attributes).body['port'])
  self
end