Class: Fog::Compute::ProfitBricks::Datacenter
- Inherits:
-
Models::ProfitBricks::Base
- Object
- Model
- Models::ProfitBricks::Base
- Fog::Compute::ProfitBricks::Datacenter
- Includes:
- Helpers::ProfitBricks::DataHelper
- Defined in:
- lib/fog/profitbricks/models/compute/datacenter.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #delete ⇒ Object
-
#initialize(attributes = {}) ⇒ Datacenter
constructor
A new instance of Datacenter.
- #save ⇒ Object
- #update ⇒ Object
Methods included from Helpers::ProfitBricks::DataHelper
Methods inherited from Models::ProfitBricks::Base
#failed?, #ready?, #request_status, #wait_for
Constructor Details
#initialize(attributes = {}) ⇒ Datacenter
Returns a new instance of Datacenter.
36 37 38 |
# File 'lib/fog/profitbricks/models/compute/datacenter.rb', line 36 def initialize(attributes = {}) super end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
34 35 36 |
# File 'lib/fog/profitbricks/models/compute/datacenter.rb', line 34 def @options end |
Instance Method Details
#delete ⇒ Object
90 91 92 93 94 |
# File 'lib/fog/profitbricks/models/compute/datacenter.rb', line 90 def delete requires :id data = service.delete_datacenter(id) true end |
#save ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/fog/profitbricks/models/compute/datacenter.rb', line 40 def save requires :name, :location = {} [:name] = name [:location] = location [:description] = description if description [:servers] = servers if servers [:volumes] = volumes if volumes [:loadbalancers] = loadbalancers if loadbalancers [:lans] = lans if lans entities = {} # Retrieve servers collection if present and generate appropriate JSON. if .key?(:servers) entities[:servers] = collect_entities(.delete(:servers)) end # Retrieve volumes collection if present and generate appropriate JSON. if .key?(:volumes) entities[:volumes] = collect_entities(.delete(:volumes)) end # Retrieve volumes collection if present and generate appropriate JSON. if .key?(:loadbalancers) entities[:loadbalancers] = collect_entities(.delete(:loadbalancers)) end # Retrieve volumes collection if present and generate appropriate JSON. if .key?(:lans) entities[:lans] = collect_entities(.delete(:lans)) end data = service.create_datacenter(, entities) merge_attributes(flatten(data.body)) true end |
#update ⇒ Object
79 80 81 82 83 84 85 86 87 88 |
# File 'lib/fog/profitbricks/models/compute/datacenter.rb', line 79 def update requires :id = {} [:name] = name if name [:description] = description if description data = service.update_datacenter(id, ) merge_attributes(flatten(data.body)) true end |