Class: HCloud::Datacenter
- Defined in:
- lib/hcloud/resources/datacenter.rb
Overview
Represents a datacenter
List all datacenters
HCloud::Datacenter.all
# => [#<HCloud::Datacenter id: 2, ...>, ...]
Sort datacenters
HCloud::Datacenter.sort(name: :desc)
# => [#<HCloud::Datacenter id: 1, ...>, ...]
HCloud::Datacenter.sort(:id, name: :asc)
# => [#<HCloud::Datacenter id: 1, ...>, ...]
Search datacenters
HCloud::Datacenter.where(name: "fsn1-dc8")
# => #<HCloud::Datacenter id: 2, ...>
Find datacenter by ID
HCloud::Datacenter.find(2)
# => #<HCloud::Datacenter id: 2, ...>
Get datacenter recommendation
HCloud::Datacenter.recommendation
# => #<HCloud::Datacenter id: 2, ...>
Class Method Summary collapse
Methods inherited from Resource
#==, attribute, client, #initialize, #inspect, resource_name, #to_h
Constructor Details
This class inherits a constructor from HCloud::Resource
Class Method Details
.recommendation ⇒ Object
45 46 47 48 49 |
# File 'lib/hcloud/resources/datacenter.rb', line 45 def self.recommendation find client .get("/#{resource_name.pluralize}") .fetch(:recommendation) end |