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.



28
29
30
# File 'lib/fog/profitbricks/models/compute/lan.rb', line 28

def options
  @options
end

Instance Method Details

#deleteObject



57
58
59
60
61
# File 'lib/fog/profitbricks/models/compute/lan.rb', line 57

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

#failed?Boolean

Returns:

  • (Boolean)


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

def failed?
  state == 'ERROR'
end

#ready?Boolean

Returns:

  • (Boolean)


79
80
81
# File 'lib/fog/profitbricks/models/compute/lan.rb', line 79

def ready?
  state == 'AVAILABLE'
end

#reloadObject



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/fog/profitbricks/models/compute/lan.rb', line 63

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



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

def save
  requires :datacenter_id

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

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

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

#updateObject



45
46
47
48
49
50
51
52
53
54
55
# File 'lib/fog/profitbricks/models/compute/lan.rb', line 45

def update
  requires :datacenter_id, :id

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

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