Class: Fog::Compute::ProfitBricks::Datacenter

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Datacenter



14
15
16
# File 'lib/fog/profitbricks/models/compute/datacenter.rb', line 14

def initialize(attributes={})
    super
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



12
13
14
# File 'lib/fog/profitbricks/models/compute/datacenter.rb', line 12

def options
  @options
end

Instance Method Details

#clear(confirm = false) ⇒ Object



39
40
41
42
43
44
45
46
47
# File 'lib/fog/profitbricks/models/compute/datacenter.rb', line 39

def clear(confirm = false)
    requires :id
    if confirm == true
        service.clear_data_center(id)
        true
    else
        raise ArgumentError.new('Confirm with true boolean to clear datacenter')
    end
end

#destroyObject



33
34
35
36
37
# File 'lib/fog/profitbricks/models/compute/datacenter.rb', line 33

def destroy
    requires :id
    service.delete_data_center(id)
    true
end

#failed?Boolean



53
54
55
# File 'lib/fog/profitbricks/models/compute/datacenter.rb', line 53

def failed?
    self.state == 'ERROR'
end

#ready?Boolean



49
50
51
# File 'lib/fog/profitbricks/models/compute/datacenter.rb', line 49

def ready?
    self.state == 'AVAILABLE'
end

#saveObject



18
19
20
21
22
23
24
# File 'lib/fog/profitbricks/models/compute/datacenter.rb', line 18

def save
    requires :name, :region

    data = service.create_data_center(name, region)
    merge_attributes(data.body['createDataCenterResponse'])
    true
end

#updateObject



26
27
28
29
30
31
# File 'lib/fog/profitbricks/models/compute/datacenter.rb', line 26

def update
    requires :id
    data = service.update_data_center(id, options)
    merge_attributes(data.body['updateDataCenterResponse'])
    true
end