Class: Fog::Compute::ProfitBricks::Lan

Inherits:
Models::ProfitBricks::Base show all
Includes:
Helpers::ProfitBricks::DataHelper
Defined in:
lib/fog/profitbricks/models/compute/lan.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers::ProfitBricks::DataHelper

#flatten

Methods inherited from Models::ProfitBricks::Base

#request_status, #wait_for

Instance Attribute Details

#optionsObject

Returns the value of attribute options


30
31
32
# File 'lib/fog/profitbricks/models/compute/lan.rb', line 30

def options
  @options
end

Instance Method Details

#deleteObject


61
62
63
64
65
# File 'lib/fog/profitbricks/models/compute/lan.rb', line 61

def delete
  requires :datacenter_id, :id
  service.delete_lan(datacenter_id, id)
  true
end

#failed?Boolean

Returns:

  • (Boolean)

87
88
89
# File 'lib/fog/profitbricks/models/compute/lan.rb', line 87

def failed?
  state == 'ERROR'
end

#ready?Boolean

Returns:

  • (Boolean)

83
84
85
# File 'lib/fog/profitbricks/models/compute/lan.rb', line 83

def ready?
  state == 'AVAILABLE'
end

#reloadObject


67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/fog/profitbricks/models/compute/lan.rb', line 67

def reload
  requires :datacenter_id, :id

  data = begin
    collection.get(datacenter_id, id)
  rescue Excon::Errors::SocketError
    nil
  end

  return unless data

  new_attributes = data.attributes
  merge_attributes(new_attributes)
  self
end

#saveObject


32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/fog/profitbricks/models/compute/lan.rb', line 32

def save
  requires :datacenter_id

  properties = {}
  properties[:name]   = name if name
  properties[:public] = public if public
  properties[:ipFailover] = ip_failover if ip_failover

  entities = {}
  entities[:nics] = nics if nics

  data = service.create_lan(datacenter_id, properties, entities)
  merge_attributes(flatten(data.body))
  true
end

#updateObject


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

def update
  requires :datacenter_id, :id

  options = {}
  options[:name]   = name if name
  options[:public] = public if public
  options[:ipFailover] = ip_failover if ip_failover

  data = service.update_lan(datacenter_id, id, options)
  merge_attributes(flatten(data.body))
  true
end