hetznercloud 1.0.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -0
- data/README.md +32 -8
- data/config/inflections.rb +12 -3
- data/lib/core_ext/send_wrap.rb +11 -4
- data/lib/hcloud/concerns/actionable.rb +9 -2
- data/lib/hcloud/concerns/concerns.rb +8 -0
- data/lib/hcloud/concerns/creatable.rb +3 -2
- data/lib/hcloud/concerns/deletable.rb +2 -0
- data/lib/hcloud/concerns/meterable.rb +17 -0
- data/lib/hcloud/concerns/queryable.rb +4 -0
- data/lib/hcloud/concerns/singleton.rb +25 -0
- data/lib/hcloud/concerns/updatable.rb +2 -0
- data/lib/hcloud/entities/algorithm.rb +7 -0
- data/lib/hcloud/entities/certificate_status.rb +9 -0
- data/lib/hcloud/entities/floating_ip_price.rb +7 -0
- data/lib/hcloud/entities/floating_ip_prices.rb +8 -0
- data/lib/hcloud/entities/health_check.rb +12 -0
- data/lib/hcloud/entities/health_check_http.rb +13 -0
- data/lib/hcloud/entities/health_status.rb +8 -0
- data/lib/hcloud/entities/image_price.rb +7 -0
- data/lib/hcloud/entities/ipv4.rb +12 -0
- data/lib/hcloud/entities/ipv6.rb +12 -0
- data/lib/hcloud/entities/label_selector.rb +7 -0
- data/lib/hcloud/entities/load_balancer_private_net.rb +8 -0
- data/lib/hcloud/entities/load_balancer_public_net.rb +11 -0
- data/lib/hcloud/entities/load_balancer_type_price.rb +9 -0
- data/lib/hcloud/entities/private_net.rb +10 -0
- data/lib/hcloud/entities/public_net.rb +10 -0
- data/lib/hcloud/entities/route.rb +8 -0
- data/lib/hcloud/entities/server_backup_price.rb +7 -0
- data/lib/hcloud/entities/server_type_price.rb +9 -0
- data/lib/hcloud/entities/service.rb +16 -0
- data/lib/hcloud/entities/service_http.rb +16 -0
- data/lib/hcloud/entities/subnet.rb +11 -0
- data/lib/hcloud/entities/target.rb +15 -0
- data/lib/hcloud/entities/target_ip.rb +7 -0
- data/lib/hcloud/entities/target_target.rb +15 -0
- data/lib/hcloud/entities/targets.rb +13 -0
- data/lib/hcloud/entities/traffic_price.rb +7 -0
- data/lib/hcloud/entities/used_by.rb +8 -0
- data/lib/hcloud/entities/volume_price.rb +7 -0
- data/lib/hcloud/entity.rb +1 -0
- data/lib/hcloud/errors.rb +32 -2
- data/lib/hcloud/http.rb +12 -4
- data/lib/hcloud/resource_type.rb +41 -2
- data/lib/hcloud/resources/certificate.rb +131 -0
- data/lib/hcloud/resources/firewall.rb +57 -3
- data/lib/hcloud/resources/floating_ip.rb +2 -3
- data/lib/hcloud/resources/image.rb +1 -1
- data/lib/hcloud/resources/load_balancer.rb +107 -0
- data/lib/hcloud/resources/load_balancer_type.rb +38 -0
- data/lib/hcloud/resources/network.rb +142 -0
- data/lib/hcloud/resources/pricing.rb +34 -0
- data/lib/hcloud/resources/server.rb +12 -15
- data/lib/hcloud/resources/volume.rb +4 -5
- data/lib/hcloud/version.rb +2 -2
- data/lib/hcloud.rb +0 -2
- metadata +38 -16
@@ -0,0 +1,142 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module HCloud
|
4
|
+
##
|
5
|
+
# Represents a network
|
6
|
+
#
|
7
|
+
# == List all networks
|
8
|
+
#
|
9
|
+
# HCloud::Network.all
|
10
|
+
# # => [#<HCloud::Network id: 1, ...>, ...]
|
11
|
+
#
|
12
|
+
# == Search networks
|
13
|
+
#
|
14
|
+
# HCloud::Network.all.where(name: "my_network")
|
15
|
+
# # => #<HCloud::Network id: 1, ...>
|
16
|
+
#
|
17
|
+
# == Find network by ID
|
18
|
+
#
|
19
|
+
# HCloud::Network.find(1)
|
20
|
+
# # => #<HCloud::Network id: 1, ...>
|
21
|
+
#
|
22
|
+
# == Create network
|
23
|
+
#
|
24
|
+
# network = HCloud::Network.new(name: "my_network", ip_range: "10.0.0.0/16")
|
25
|
+
# network.create
|
26
|
+
# network.created?
|
27
|
+
# # => true
|
28
|
+
#
|
29
|
+
# network = HCloud::Network.create(name: "my_network", ip_range: "10.0.0.0/16")
|
30
|
+
# # => #<HCloud::Network id: 1, ...>
|
31
|
+
#
|
32
|
+
# == Update network
|
33
|
+
#
|
34
|
+
# network = HCloud::Network.find(1)
|
35
|
+
# network.name = "another_network"
|
36
|
+
# network.update
|
37
|
+
#
|
38
|
+
# == Delete network
|
39
|
+
#
|
40
|
+
# network = HCloud::Network.find(1)
|
41
|
+
# network.delete
|
42
|
+
# network.deleted?
|
43
|
+
# # => true
|
44
|
+
#
|
45
|
+
# = Actions
|
46
|
+
# == List actions
|
47
|
+
#
|
48
|
+
# actions = HCloud::FloatingIP.find(1).actions
|
49
|
+
# # => [#<HCloud::Action id: 1, ...>, ...]
|
50
|
+
#
|
51
|
+
# == Sort actions
|
52
|
+
#
|
53
|
+
# HCloud::FloatingIP.find(1).actions.sort(finished: :desc)
|
54
|
+
# # => [#<HCloud::Action id: 1, ...>, ...]
|
55
|
+
#
|
56
|
+
# HCloud::FloatingIP.find(1).actions.sort(:command, finished: :asc)
|
57
|
+
# # => [#<HCloud::Actions id: 1, ...>, ...]
|
58
|
+
#
|
59
|
+
# == Search actions
|
60
|
+
#
|
61
|
+
# HCloud::FloatingIP.find(1).actions.where(command: "assign_floating_ip")
|
62
|
+
# # => #<HCloud::Action id: 1, ...>
|
63
|
+
#
|
64
|
+
# HCloud::FloatingIP.find(1).actions.where(status: "success")
|
65
|
+
# # => #<HCloud::Action id: 1, ...>
|
66
|
+
#
|
67
|
+
# == Find action by ID
|
68
|
+
#
|
69
|
+
# HCloud::FloatingIP.find(1).actions.find(1)
|
70
|
+
# # => #<HCloud::Action id: 1, ...>
|
71
|
+
#
|
72
|
+
# = Resource-specific actions
|
73
|
+
# == Change protection
|
74
|
+
#
|
75
|
+
# HCloud::Network.find(1).change_protection(delete: true)
|
76
|
+
# # => #<HCloud::Action id: 1, ...>
|
77
|
+
#
|
78
|
+
# == Add a route
|
79
|
+
#
|
80
|
+
# HCloud::Network.find(1).add_route(destination: "10.100.1.0/24", gateway: "10.0.1.1")
|
81
|
+
# # => #<HCloud::Action id: 1, ...>
|
82
|
+
#
|
83
|
+
# == Add a subnet
|
84
|
+
#
|
85
|
+
# HCloud::Network.find(1).add_subnet(ip_range: "10.0.1.0/24", network_zone: "eu-central", type: "cloud")
|
86
|
+
# # => #<HCloud::Action id: 1, ...>
|
87
|
+
#
|
88
|
+
# == Change the IP range
|
89
|
+
#
|
90
|
+
# HCloud::Network.find(1).change_ip_range(ip_range: "10.0.0.0/15")
|
91
|
+
# # => #<HCloud::Action id: 1, ...>
|
92
|
+
#
|
93
|
+
# == Delete a route
|
94
|
+
#
|
95
|
+
# HCloud::Network.find(1).delete_route(destination: "10.100.1.0/24", gateway: "10.0.1.1")
|
96
|
+
# # => #<HCloud::Action id: 1, ...>
|
97
|
+
#
|
98
|
+
# == Delete a subnet
|
99
|
+
#
|
100
|
+
# HCloud::Network.find(1).delete_subnet(ip_range: "10.0.1.0/24", network_zone: "eu-central", type: "cloud")
|
101
|
+
# # => #<HCloud::Action id: 1, ...>
|
102
|
+
#
|
103
|
+
class Network < Resource
|
104
|
+
actionable
|
105
|
+
queryable
|
106
|
+
creatable
|
107
|
+
updatable
|
108
|
+
deletable
|
109
|
+
|
110
|
+
attribute :id, :integer
|
111
|
+
attribute :name
|
112
|
+
|
113
|
+
attribute :ip_range
|
114
|
+
|
115
|
+
attribute :routes, :route, array: true, default: -> { [] }
|
116
|
+
attribute :subnets, :subnet, array: true, default: -> { [] }
|
117
|
+
|
118
|
+
attribute :servers, :server, array: true, default: -> { [] }
|
119
|
+
|
120
|
+
attribute :load_balancers, :load_balancer, array: true, default: -> { [] }
|
121
|
+
|
122
|
+
attribute :protection, :protection
|
123
|
+
|
124
|
+
attribute :labels, default: -> { {} }
|
125
|
+
|
126
|
+
action :change_protection
|
127
|
+
|
128
|
+
action :add_route
|
129
|
+
action :add_subnet
|
130
|
+
action :change_ip_range
|
131
|
+
action :delete_route
|
132
|
+
action :delete_subnet
|
133
|
+
|
134
|
+
def creatable_attributes
|
135
|
+
[:name, :labels, :ip_range, :routes, :subnets]
|
136
|
+
end
|
137
|
+
|
138
|
+
def updatable_attributes
|
139
|
+
[:name, :labels]
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module HCloud
|
4
|
+
##
|
5
|
+
# Represents pricing
|
6
|
+
#
|
7
|
+
# == Find pricing
|
8
|
+
#
|
9
|
+
# HCloud::Pricing.find
|
10
|
+
# # => #<HCloud::Pricing ...>
|
11
|
+
#
|
12
|
+
class Pricing < Resource
|
13
|
+
singleton
|
14
|
+
|
15
|
+
attribute :currency
|
16
|
+
|
17
|
+
attribute :floating_ip, :floating_ip_price
|
18
|
+
attribute :floating_ips, :floating_ip_prices, array: true, default: -> { [] }
|
19
|
+
|
20
|
+
attribute :image, :image_price
|
21
|
+
|
22
|
+
attribute :load_balancer_types, :load_balancer_type_price, array: true, default: -> { [] }
|
23
|
+
|
24
|
+
attribute :server_backup, :server_backup_price
|
25
|
+
|
26
|
+
attribute :server_types, :server_type_price, array: true, default: -> { [] }
|
27
|
+
|
28
|
+
attribute :traffic, :traffic_price
|
29
|
+
|
30
|
+
attribute :vat_rate
|
31
|
+
|
32
|
+
attribute :volume, :volume_price
|
33
|
+
end
|
34
|
+
end
|
@@ -33,7 +33,7 @@ module HCloud
|
|
33
33
|
# == Create server
|
34
34
|
#
|
35
35
|
# user_data = File.read("user_data.yml")
|
36
|
-
# server = HCloud::Server.new(name: "my_server", image: "debian-11", server_type: "cx11")
|
36
|
+
# server = HCloud::Server.new(name: "my_server", image: "debian-11", server_type: "cx11", user_data: user_data)
|
37
37
|
# server.create
|
38
38
|
# server.created?
|
39
39
|
# # => true
|
@@ -64,7 +64,6 @@ module HCloud
|
|
64
64
|
# # => #<HCloud::Metrics ...>
|
65
65
|
#
|
66
66
|
# TODO: actions
|
67
|
-
# TODO: return root_password if ssh_keys is empty
|
68
67
|
#
|
69
68
|
class Server < Resource
|
70
69
|
actionable
|
@@ -72,6 +71,7 @@ module HCloud
|
|
72
71
|
creatable
|
73
72
|
updatable
|
74
73
|
deletable
|
74
|
+
meterable
|
75
75
|
|
76
76
|
attribute :id, :integer
|
77
77
|
attribute :name
|
@@ -82,6 +82,9 @@ module HCloud
|
|
82
82
|
|
83
83
|
attribute :backup_window
|
84
84
|
|
85
|
+
# TODO: use only for creation
|
86
|
+
attribute :user_data
|
87
|
+
|
85
88
|
# TODO: use only for creation
|
86
89
|
attribute :location, :location
|
87
90
|
|
@@ -94,6 +97,8 @@ module HCloud
|
|
94
97
|
# TODO: use only for creation
|
95
98
|
attribute :networks, array: true, default: -> { [] }
|
96
99
|
|
100
|
+
attribute :root_password
|
101
|
+
|
97
102
|
attribute :datacenter, :datacenter
|
98
103
|
|
99
104
|
attribute :included_traffic, :integer
|
@@ -106,9 +111,8 @@ module HCloud
|
|
106
111
|
|
107
112
|
attribute :image, :image
|
108
113
|
|
109
|
-
|
110
|
-
attribute :
|
111
|
-
attribute :private_net
|
114
|
+
attribute :public_net, :public_net
|
115
|
+
attribute :private_net, :private_net
|
112
116
|
|
113
117
|
attribute :placement_group, :placement_group
|
114
118
|
|
@@ -116,13 +120,12 @@ module HCloud
|
|
116
120
|
|
117
121
|
attribute :labels, default: -> { {} }
|
118
122
|
|
119
|
-
|
120
|
-
attribute :load_balancers, array: true, default: -> { [] }
|
123
|
+
attribute :load_balancers, :load_balancer, array: true, default: -> { [] }
|
121
124
|
|
122
125
|
attribute :volumes, :volume, array: true, default: -> { [] }
|
123
126
|
|
124
|
-
attribute :locked
|
125
|
-
attribute :rescue_enabled
|
127
|
+
attribute :locked, :boolean
|
128
|
+
attribute :rescue_enabled, :boolean
|
126
129
|
|
127
130
|
alias rescue_enabled? rescue_enabled
|
128
131
|
|
@@ -162,12 +165,6 @@ module HCloud
|
|
162
165
|
|
163
166
|
action :request_console
|
164
167
|
|
165
|
-
def metrics(type:, from:, to:, step: nil)
|
166
|
-
Metrics.new client
|
167
|
-
.get("/servers/#{id}/metrics", type: Array(type).join(","), start: from.iso8601, end: to.iso8601, step: step)
|
168
|
-
.fetch(:metrics)
|
169
|
-
end
|
170
|
-
|
171
168
|
def creatable_attributes
|
172
169
|
[:name, :automount, :start_after_create, :user_data, :labels, datacenter: [:id, :name], image: [:id, :name], location: [:id, :name], server_type: [:id, :name], ssh_keys: [:id, :name], firewalls: :id, networks: :id, volumes: :id]
|
173
170
|
end
|
@@ -80,10 +80,10 @@ module HCloud
|
|
80
80
|
# HCloud::Volume.find(1).actions.find(1)
|
81
81
|
# # => #<HCloud::Action id: 1, ...>
|
82
82
|
#
|
83
|
-
# =
|
83
|
+
# = Resource-specific actions
|
84
84
|
# == Attach a volume to a server
|
85
85
|
#
|
86
|
-
# HCloud::Volume.find(1).attach(server: 1)
|
86
|
+
# HCloud::Volume.find(1).attach(server: 1, automount: false)
|
87
87
|
# # => #<HCloud::Action id: 1, ...>
|
88
88
|
#
|
89
89
|
# == Detach a volume from a server
|
@@ -93,7 +93,7 @@ module HCloud
|
|
93
93
|
#
|
94
94
|
# == Resize volume
|
95
95
|
#
|
96
|
-
# HCloud::Volume.find(1).resize(size:
|
96
|
+
# HCloud::Volume.find(1).resize(size: 25)
|
97
97
|
# # => #<HCloud::Action id: 1, ...>
|
98
98
|
#
|
99
99
|
# == Change protection
|
@@ -122,8 +122,7 @@ module HCloud
|
|
122
122
|
attribute :location, :location
|
123
123
|
attribute :protection, :protection
|
124
124
|
|
125
|
-
|
126
|
-
attribute :server, :integer
|
125
|
+
attribute :server, :server
|
127
126
|
|
128
127
|
attribute :labels, default: -> { {} }
|
129
128
|
|
data/lib/hcloud/version.rb
CHANGED
data/lib/hcloud.rb
CHANGED
@@ -15,7 +15,6 @@ module HCloud
|
|
15
15
|
@root ||= Pathname.new(File.expand_path(File.join("..", ".."), __FILE__))
|
16
16
|
end
|
17
17
|
|
18
|
-
# rubocop:disable Metrics/AbcSize
|
19
18
|
def setup
|
20
19
|
@loader = Zeitwerk::Loader.for_gem
|
21
20
|
|
@@ -35,7 +34,6 @@ module HCloud
|
|
35
34
|
loader.setup
|
36
35
|
loader.eager_load
|
37
36
|
end
|
38
|
-
# rubocop:enable Metrics/AbcSize
|
39
37
|
end
|
40
38
|
end
|
41
39
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hetznercloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Dejonckheere
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-02-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -94,20 +94,6 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: factory_bot
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - ">="
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - ">="
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
111
97
|
- !ruby/object:Gem::Dependency
|
112
98
|
name: ffaker
|
113
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -227,32 +213,68 @@ files:
|
|
227
213
|
- lib/hcloud/concerns/concerns.rb
|
228
214
|
- lib/hcloud/concerns/creatable.rb
|
229
215
|
- lib/hcloud/concerns/deletable.rb
|
216
|
+
- lib/hcloud/concerns/meterable.rb
|
230
217
|
- lib/hcloud/concerns/queryable.rb
|
218
|
+
- lib/hcloud/concerns/singleton.rb
|
231
219
|
- lib/hcloud/concerns/updatable.rb
|
220
|
+
- lib/hcloud/entities/algorithm.rb
|
232
221
|
- lib/hcloud/entities/amount.rb
|
233
222
|
- lib/hcloud/entities/applied_to.rb
|
234
223
|
- lib/hcloud/entities/applied_to_resource.rb
|
235
224
|
- lib/hcloud/entities/apply_to.rb
|
225
|
+
- lib/hcloud/entities/certificate_status.rb
|
236
226
|
- lib/hcloud/entities/datacenter_server_type.rb
|
237
227
|
- lib/hcloud/entities/dns_pointer.rb
|
238
228
|
- lib/hcloud/entities/error.rb
|
229
|
+
- lib/hcloud/entities/floating_ip_price.rb
|
230
|
+
- lib/hcloud/entities/floating_ip_prices.rb
|
231
|
+
- lib/hcloud/entities/health_check.rb
|
232
|
+
- lib/hcloud/entities/health_check_http.rb
|
233
|
+
- lib/hcloud/entities/health_status.rb
|
234
|
+
- lib/hcloud/entities/image_price.rb
|
235
|
+
- lib/hcloud/entities/ipv4.rb
|
236
|
+
- lib/hcloud/entities/ipv6.rb
|
237
|
+
- lib/hcloud/entities/label_selector.rb
|
238
|
+
- lib/hcloud/entities/load_balancer_private_net.rb
|
239
|
+
- lib/hcloud/entities/load_balancer_public_net.rb
|
240
|
+
- lib/hcloud/entities/load_balancer_type_price.rb
|
239
241
|
- lib/hcloud/entities/metrics.rb
|
240
242
|
- lib/hcloud/entities/price.rb
|
243
|
+
- lib/hcloud/entities/private_net.rb
|
241
244
|
- lib/hcloud/entities/protection.rb
|
245
|
+
- lib/hcloud/entities/public_net.rb
|
246
|
+
- lib/hcloud/entities/route.rb
|
242
247
|
- lib/hcloud/entities/rule.rb
|
248
|
+
- lib/hcloud/entities/server_backup_price.rb
|
249
|
+
- lib/hcloud/entities/server_type_price.rb
|
250
|
+
- lib/hcloud/entities/service.rb
|
251
|
+
- lib/hcloud/entities/service_http.rb
|
252
|
+
- lib/hcloud/entities/subnet.rb
|
253
|
+
- lib/hcloud/entities/target.rb
|
254
|
+
- lib/hcloud/entities/target_ip.rb
|
255
|
+
- lib/hcloud/entities/target_target.rb
|
256
|
+
- lib/hcloud/entities/targets.rb
|
257
|
+
- lib/hcloud/entities/traffic_price.rb
|
258
|
+
- lib/hcloud/entities/used_by.rb
|
259
|
+
- lib/hcloud/entities/volume_price.rb
|
243
260
|
- lib/hcloud/entity.rb
|
244
261
|
- lib/hcloud/errors.rb
|
245
262
|
- lib/hcloud/http.rb
|
246
263
|
- lib/hcloud/resource.rb
|
247
264
|
- lib/hcloud/resource_type.rb
|
248
265
|
- lib/hcloud/resources/action.rb
|
266
|
+
- lib/hcloud/resources/certificate.rb
|
249
267
|
- lib/hcloud/resources/datacenter.rb
|
250
268
|
- lib/hcloud/resources/firewall.rb
|
251
269
|
- lib/hcloud/resources/floating_ip.rb
|
252
270
|
- lib/hcloud/resources/image.rb
|
253
271
|
- lib/hcloud/resources/iso.rb
|
272
|
+
- lib/hcloud/resources/load_balancer.rb
|
273
|
+
- lib/hcloud/resources/load_balancer_type.rb
|
254
274
|
- lib/hcloud/resources/location.rb
|
275
|
+
- lib/hcloud/resources/network.rb
|
255
276
|
- lib/hcloud/resources/placement_group.rb
|
277
|
+
- lib/hcloud/resources/pricing.rb
|
256
278
|
- lib/hcloud/resources/server.rb
|
257
279
|
- lib/hcloud/resources/server_type.rb
|
258
280
|
- lib/hcloud/resources/ssh_key.rb
|