-
Notifications
You must be signed in to change notification settings - Fork 4
/
datacenter.rb
51 lines (47 loc) · 1.14 KB
/
datacenter.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# frozen_string_literal: true
module HCloud
##
# 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 Datacenter < Resource
queryable
attribute :id, :integer
attribute :name
attribute :description
attribute :location, :location
attribute :server_types, :datacenter_server_type
def self.recommendation
find client
.get("/#{resource_name.pluralize}")
.fetch(:recommendation)
end
end
end