hetznercloud 2.2.1 → 4.0.0
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 +88 -4
- data/README.md +49 -32
- data/lib/hcloud/action_collection.rb +2 -2
- data/lib/hcloud/client.rb +28 -2
- data/lib/hcloud/collection.rb +10 -2
- data/lib/hcloud/concerns/actionable.rb +1 -1
- data/lib/hcloud/concerns/creatable.rb +21 -6
- data/lib/hcloud/concerns/deletable.rb +1 -1
- data/lib/hcloud/concerns/meterable.rb +1 -1
- data/lib/hcloud/concerns/queryable.rb +3 -3
- data/lib/hcloud/concerns/subresource.rb +62 -0
- data/lib/hcloud/concerns/updatable.rb +1 -1
- data/lib/hcloud/entities/storage_box_access_settings.rb +17 -0
- data/lib/hcloud/entities/storage_box_price.rb +10 -0
- data/lib/hcloud/entities/storage_box_snapshot_plan.rb +11 -0
- data/lib/hcloud/entities/storage_box_snapshot_stats.rb +8 -0
- data/lib/hcloud/entities/storage_box_stats.rb +9 -0
- data/lib/hcloud/entities/storage_box_subaccount_access_settings.rb +19 -0
- data/lib/hcloud/errors.rb +2 -1
- data/lib/hcloud/resource.rb +1 -0
- data/lib/hcloud/resource_type.rb +10 -0
- data/lib/hcloud/resources/certificate.rb +1 -1
- data/lib/hcloud/resources/datacenter.rb +1 -1
- data/lib/hcloud/resources/firewall.rb +1 -1
- data/lib/hcloud/resources/floating_ip.rb +1 -1
- data/lib/hcloud/resources/load_balancer.rb +1 -1
- data/lib/hcloud/resources/network.rb +1 -1
- data/lib/hcloud/resources/placement_group.rb +1 -1
- data/lib/hcloud/resources/pricing.rb +1 -1
- data/lib/hcloud/resources/primary_ip.rb +1 -1
- data/lib/hcloud/resources/server.rb +1 -1
- data/lib/hcloud/resources/server_type.rb +0 -4
- data/lib/hcloud/resources/ssh_key.rb +1 -1
- data/lib/hcloud/resources/storage_box.rb +191 -0
- data/lib/hcloud/resources/storage_box_snapshot.rb +104 -0
- data/lib/hcloud/resources/storage_box_subaccount.rb +125 -0
- data/lib/hcloud/resources/storage_box_type.rb +43 -0
- data/lib/hcloud/resources/volume.rb +2 -2
- data/lib/hcloud/sub_collection.rb +79 -0
- data/lib/hcloud/version.rb +3 -3
- data/lib/http/features/compression.rb +1 -1
- data/lib/http/features/request/brotli_body.rb +1 -1
- data/lib/http/features/response/brotli_inflater.rb +1 -1
- data/lib/http/rate_limiter.rb +2 -0
- metadata +18 -6
@@ -0,0 +1,79 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module HCloud
|
4
|
+
# @!visibility private
|
5
|
+
class SubCollection
|
6
|
+
include Enumerable
|
7
|
+
|
8
|
+
attr_reader :name, :type, :resource, :label_selector
|
9
|
+
|
10
|
+
def initialize(name, type, resource)
|
11
|
+
@name = name
|
12
|
+
@type = type
|
13
|
+
@resource = resource
|
14
|
+
end
|
15
|
+
|
16
|
+
def where(label_selector: nil)
|
17
|
+
@label_selector = label_selector
|
18
|
+
|
19
|
+
self
|
20
|
+
end
|
21
|
+
|
22
|
+
def each(&block)
|
23
|
+
return to_enum(:each) unless block
|
24
|
+
|
25
|
+
all.each(&block)
|
26
|
+
|
27
|
+
self
|
28
|
+
end
|
29
|
+
|
30
|
+
def find(id)
|
31
|
+
raise Errors::MissingIDError unless resource.id
|
32
|
+
|
33
|
+
subresource_class.new resource
|
34
|
+
.client
|
35
|
+
.get("#{resource.resource_path}/#{resource.id}/#{name.to_s.pluralize}/#{id}")
|
36
|
+
.fetch(name)
|
37
|
+
end
|
38
|
+
|
39
|
+
def new(attributes = {})
|
40
|
+
subresource_class.new attributes
|
41
|
+
.merge(resource.resource_name => resource.id)
|
42
|
+
end
|
43
|
+
|
44
|
+
def create(attributes = {})
|
45
|
+
new(attributes)
|
46
|
+
.tap(&:create)
|
47
|
+
end
|
48
|
+
|
49
|
+
def inspect
|
50
|
+
label_selector = label_selector ? " labels_selector: (#{label_selector})" : nil
|
51
|
+
|
52
|
+
"#<#{self.class}#{label_selector} count: #{count}>"
|
53
|
+
end
|
54
|
+
|
55
|
+
delegate :[], :first, :last, :count, :empty?, to: :to_a
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def all
|
60
|
+
@all ||= resource
|
61
|
+
.client
|
62
|
+
.get("#{resource.resource_path}/#{resource.id}/#{name.to_s.pluralize}", params)
|
63
|
+
.fetch(name.to_s.pluralize.to_sym)
|
64
|
+
.map { |attrs| subresource_class.new attrs }
|
65
|
+
end
|
66
|
+
|
67
|
+
def params
|
68
|
+
{
|
69
|
+
label_selector: label_selector,
|
70
|
+
}
|
71
|
+
end
|
72
|
+
|
73
|
+
def subresource_class
|
74
|
+
@subresource_class ||= ActiveModel::Type
|
75
|
+
.lookup(type)
|
76
|
+
.resource_class
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
data/lib/hcloud/version.rb
CHANGED
@@ -4,7 +4,7 @@ begin
|
|
4
4
|
require "brotli"
|
5
5
|
|
6
6
|
version = Brotli::VERSION.split(".").map(&:to_i)
|
7
|
-
raise ArgumentError, "incompatible version of brotli: #{Brotli::VERSION}, needs to be at least 0.3.0" unless
|
7
|
+
raise ArgumentError, "incompatible version of brotli: #{Brotli::VERSION}, needs to be at least 0.3.0" unless version[0].positive? || version[1] >= 3
|
8
8
|
rescue LoadError
|
9
9
|
# Ignore
|
10
10
|
end
|
@@ -4,7 +4,7 @@ begin
|
|
4
4
|
require "brotli"
|
5
5
|
|
6
6
|
version = Brotli::VERSION.split(".").map(&:to_i)
|
7
|
-
raise ArgumentError, "incompatible version of brotli: #{Brotli::VERSION}, needs to be at least 0.3.0" unless
|
7
|
+
raise ArgumentError, "incompatible version of brotli: #{Brotli::VERSION}, needs to be at least 0.3.0" unless version[0].positive? || version[1] >= 3
|
8
8
|
rescue LoadError
|
9
9
|
# Ignore
|
10
10
|
end
|
data/lib/http/rate_limiter.rb
CHANGED
@@ -23,6 +23,8 @@ module HTTP
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def wrap_response(response)
|
26
|
+
return response if response["RateLimit-Limit"].nil? || response["RateLimit-Remaining"].nil? || response["RateLimit-Reset"].nil?
|
27
|
+
|
26
28
|
# Extract rate limits
|
27
29
|
@limit = response["RateLimit-Limit"].to_i
|
28
30
|
@remaining = response["RateLimit-Remaining"].to_i
|
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:
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Dejonckheere
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -92,6 +92,7 @@ files:
|
|
92
92
|
- lib/hcloud/concerns/meterable.rb
|
93
93
|
- lib/hcloud/concerns/queryable.rb
|
94
94
|
- lib/hcloud/concerns/singleton.rb
|
95
|
+
- lib/hcloud/concerns/subresource.rb
|
95
96
|
- lib/hcloud/concerns/updatable.rb
|
96
97
|
- lib/hcloud/entities/algorithm.rb
|
97
98
|
- lib/hcloud/entities/amount.rb
|
@@ -130,6 +131,12 @@ files:
|
|
130
131
|
- lib/hcloud/entities/server_type_price.rb
|
131
132
|
- lib/hcloud/entities/service.rb
|
132
133
|
- lib/hcloud/entities/service_http.rb
|
134
|
+
- lib/hcloud/entities/storage_box_access_settings.rb
|
135
|
+
- lib/hcloud/entities/storage_box_price.rb
|
136
|
+
- lib/hcloud/entities/storage_box_snapshot_plan.rb
|
137
|
+
- lib/hcloud/entities/storage_box_snapshot_stats.rb
|
138
|
+
- lib/hcloud/entities/storage_box_stats.rb
|
139
|
+
- lib/hcloud/entities/storage_box_subaccount_access_settings.rb
|
133
140
|
- lib/hcloud/entities/subnet.rb
|
134
141
|
- lib/hcloud/entities/target.rb
|
135
142
|
- lib/hcloud/entities/target_ip.rb
|
@@ -161,7 +168,12 @@ files:
|
|
161
168
|
- lib/hcloud/resources/server.rb
|
162
169
|
- lib/hcloud/resources/server_type.rb
|
163
170
|
- lib/hcloud/resources/ssh_key.rb
|
171
|
+
- lib/hcloud/resources/storage_box.rb
|
172
|
+
- lib/hcloud/resources/storage_box_snapshot.rb
|
173
|
+
- lib/hcloud/resources/storage_box_subaccount.rb
|
174
|
+
- lib/hcloud/resources/storage_box_type.rb
|
164
175
|
- lib/hcloud/resources/volume.rb
|
176
|
+
- lib/hcloud/sub_collection.rb
|
165
177
|
- lib/hcloud/version.rb
|
166
178
|
- lib/http/features/block_io.rb
|
167
179
|
- lib/http/features/compression.rb
|
@@ -178,7 +190,7 @@ licenses:
|
|
178
190
|
metadata:
|
179
191
|
source_code_uri: https://github.com/floriandejonckheere/hcloud.git
|
180
192
|
rubygems_mfa_required: 'true'
|
181
|
-
post_install_message:
|
193
|
+
post_install_message:
|
182
194
|
rdoc_options: []
|
183
195
|
require_paths:
|
184
196
|
- lib
|
@@ -193,8 +205,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
193
205
|
- !ruby/object:Gem::Version
|
194
206
|
version: '0'
|
195
207
|
requirements: []
|
196
|
-
rubygems_version: 3.
|
197
|
-
signing_key:
|
208
|
+
rubygems_version: 3.4.20
|
209
|
+
signing_key:
|
198
210
|
specification_version: 4
|
199
211
|
summary: Ruby library wrapping the Hetzner Cloud API
|
200
212
|
test_files: []
|