hetznercloud 5.1.0 → 6.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 75059c7c37ac0cb1f885b4af4f6c02567f926bb22ce3f77985456219da87546d
4
- data.tar.gz: 3b02d023297bc5a4376901591f790b2d2009ba0ec0f8add1c51da405cee1d0ff
3
+ metadata.gz: c97f9307e8cae23c94b06c853eab8432a5d571fc90b13c527a0fa8a029038143
4
+ data.tar.gz: da9e9aecda35dbdca6a6b1e1047d4ff957ca63a649f1a3a52b25d31c42302f48
5
5
  SHA512:
6
- metadata.gz: 33a26943527f4e9136c21699670f01771f92d3bee9fe50c64347b2c33562005f692c9f1c3784c6d34e3b64ca8c5f956793678c698b4b89b2e6dc4bac66c99632
7
- data.tar.gz: 7e9768db1f0e803dca01b1d8f698cc6c49a1f6737544cc43c88e64079003a2ff31889dfcb1b7939b2ad7408d08a61761d05c842efae64955cce7265fa97b1956
6
+ metadata.gz: feb065fa72661720caeefff45ea650374bdb71919a7e901102cfcfe79f386b80b9fde9e1700112052041ec5f4e7cc7e25eec3c6ced0e5dd15f2bbf5eb4872e37
7
+ data.tar.gz: 61fe9582cdc7681c567c9da110c1028a0c713f3cd3fc1f8a59ff00a0495a1e82e82070e74e3514f738eacc7949513dd68e2c35d761883cbb464015dc63b9d3ba
data/CHANGELOG.md CHANGED
@@ -10,6 +10,37 @@
10
10
 
11
11
  ### Fixed
12
12
 
13
+ ## HCloud v6.1.0 (2026-07-10)
14
+
15
+ ### Added
16
+
17
+ - Add `enable_ipv4` and `enable_ipv6` attributes to `HCloud::PublicNet`
18
+ - Add `public_net` to `HCloud::Server` creatable attributes
19
+
20
+ ### Fixed
21
+
22
+ - Fix a bug where name-only SSH keys serialize incorrectly
23
+
24
+ ## HCloud v6.0.0 (2026-06-09)
25
+
26
+ ### Added
27
+
28
+ - Add `deprecation` attribute to `HCloud::LoadBalancerType`
29
+ - Add `MustBeUnassigned` error class
30
+ - Add `DeprecatedApiEndpoint` error class
31
+
32
+ ### Changed
33
+
34
+ - Deprecate `HCloud::LoadBalancerType#deprecated`
35
+ - Deprecate `HCloud::Datacenter`
36
+ - Replace `GET /<resource>/{id}/actions/{action_id}` with `GET /actions/{action_id}`
37
+
38
+ ### Removed
39
+
40
+ - Remove `HCloud::Action.all`, `.first`, `.last`, `.count`, `.where`, `.sort`, `.each`, `.empty?`, `.any?`
41
+
42
+ ### Fixed
43
+
13
44
  ## HCloud v5.1.0 (2026-03-03)
14
45
 
15
46
  ### Added
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  ![Continuous Integration](https://github.com/floriandejonckheere/hcloud/actions/workflows/ci.yml/badge.svg)
4
4
  ![Release](https://img.shields.io/github/v/release/floriandejonckheere/hcloud?label=Latest%20release)
5
5
 
6
- Unofficial Ruby integration with the [Hetzner Cloud API](https://docs.hetzner.cloud/).
6
+ Unofficial Ruby integration with the [Hetzner Cloud API](https://docs.hetzner.cloud/). Refer to the [API specification](https://docs.hetzner.cloud/reference/cloud) for more details.
7
7
 
8
8
  ## Installation
9
9
 
@@ -94,8 +94,8 @@ The following table lists the Hetzner Cloud API endpoints that are currently imp
94
94
  | [Pricing](lib/hcloud/resources/pricing.rb) | Implemented |
95
95
  | [RRSets](lib/hcloud/resources/rrset.rb) | Implemented |
96
96
  | [RRSet Actions](lib/hcloud/resources/rrset.rb) | Implemented |
97
- | [Servers](lib/hcloud/resources/server.rb) | Partially implemented |
98
- | [Server Actions](lib/hcloud/resources/server.rb) | Not implemented |
97
+ | [Servers](lib/hcloud/resources/server.rb) | Implemented |
98
+ | [Server Actions](lib/hcloud/resources/server.rb) | Implemented |
99
99
  | [Server Types](lib/hcloud/resources/server_type.rb) | Implemented |
100
100
  | [SSH Keys](lib/hcloud/resources/ssh_key.rb) | Implemented |
101
101
  | [Storage Boxes](lib/hcloud/resources/storage_box.rb) | Implemented |
@@ -14,7 +14,7 @@ module HCloud
14
14
  def find(id)
15
15
  Action.new resource
16
16
  .client
17
- .get("#{resource.resource_path}/#{resource.id}/actions/#{id}")
17
+ .get("/actions/#{id}")
18
18
  .fetch(:action)
19
19
  end
20
20
 
@@ -42,19 +42,38 @@ module HCloud
42
42
  []
43
43
  end
44
44
 
45
- # Convert creatable_attributes into a key-value list
46
- # rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
47
45
  def creatable_params
48
46
  # Split simple and nested attributes
49
47
  nested_attributes, simple_attributes = creatable_attributes.partition { |a| a.respond_to? :each }
50
48
 
49
+ serialize_simple_attributes(simple_attributes)
50
+ .merge(serialize_nested_attributes(nested_attributes))
51
+ .compact_blank
52
+ end
53
+
54
+ private
55
+
56
+ def serialize_simple_attributes(simple_attributes)
51
57
  attributes
52
58
  .slice(*simple_attributes.map(&:to_s))
53
59
  .transform_values { |v| v&.send_wrap { |o| o.try(:to_h) || o } || v&.send_wrap(:to_s) }
54
- .merge(nested_attributes.reduce(&:merge).to_h { |k, v| [k.to_s, Array(v).filter_map { |w| send(k)&.send_wrap(w) }.first] })
55
- .compact_blank
56
60
  end
57
- # rubocop:enable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
61
+
62
+ def serialize_nested_attributes(nested_attributes)
63
+ return {} if nested_attributes.empty?
64
+
65
+ nested_attributes.reduce(&:merge).to_h do |k, v|
66
+ [k.to_s, serialize_nested_attribute(send(k), v)]
67
+ end
68
+ end
69
+
70
+ def serialize_nested_attribute(value, fallbacks)
71
+ if value.is_a?(Array)
72
+ value.map { |item| Array(fallbacks).filter_map { |w| item&.send_wrap(w) }.first }
73
+ else
74
+ Array(fallbacks).filter_map { |w| value&.send_wrap(w) }.first
75
+ end
76
+ end
58
77
  end
59
78
 
60
79
  class_methods do
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HCloud
4
+ # @!visibility private
5
+ module DeprecatedResource
6
+ extend ActiveSupport::Concern
7
+
8
+ included do
9
+ class_attribute :_deprecated, default: false
10
+ class_attribute :deprecated_since
11
+ end
12
+
13
+ class_methods do # rubocop:disable Metrics/BlockLength
14
+ def deprecated(since: nil)
15
+ self._deprecated = true
16
+ self.deprecated_since = Date.parse(since) if since
17
+
18
+ [:find, :all, :create].each do |method|
19
+ define_singleton_method(method) do |*args, **kwargs, &block|
20
+ warn "[DEPRECATION] Resource \"#{name}\" is deprecated since #{deprecated_since.iso8601}." if deprecated?
21
+
22
+ super(*args, **kwargs, &block)
23
+ end
24
+ end
25
+ end
26
+
27
+ def deprecated?
28
+ _deprecated
29
+ end
30
+
31
+ # Wrap instance methods as they are defined (e.g. reload added by queryable)
32
+ def method_added(method_name)
33
+ super
34
+
35
+ return unless _deprecated
36
+ return unless [:reload, :update, :delete].include? method_name
37
+
38
+ return if @_wrapping_deprecated_instance
39
+
40
+ @_wrapping_deprecated_instance = true
41
+
42
+ original = instance_method(method_name)
43
+
44
+ define_method(method_name) do |*args, **kwargs, &block|
45
+ warn "[DEPRECATION] Resource \"#{self.class.name}\" is deprecated since #{self.class.deprecated_since.iso8601}." if self.class.deprecated?
46
+
47
+ original.bind_call(self, *args, **kwargs, &block)
48
+ end
49
+
50
+ @_wrapping_deprecated_instance = false
51
+ end
52
+ end
53
+ end
54
+ end
@@ -6,5 +6,17 @@ module HCloud
6
6
  attribute :floating_ips, :floating_ip, array: true, default: -> { [] }
7
7
  attribute :ipv4, :ipv4
8
8
  attribute :ipv6, :ipv6
9
+
10
+ attribute :enable_ipv4, :boolean
11
+ attribute :enable_ipv6, :boolean
12
+
13
+ def to_h
14
+ {
15
+ enable_ipv4: enable_ipv4,
16
+ enable_ipv6: enable_ipv6,
17
+ ipv4: ipv4&.id,
18
+ ipv6: ipv6&.id,
19
+ }.compact
20
+ end
9
21
  end
10
22
  end
data/lib/hcloud/errors.rb CHANGED
@@ -25,6 +25,7 @@ module HCloud
25
25
  class ActionFailed < Error; end
26
26
  class CloudResourceIPNotAllowed < Error; end
27
27
  class Conflict < Error; end
28
+ class DeprecatedApiEndpoint < Error; end
28
29
  class FirewallAlreadyApplied < Error; end
29
30
  class FirewallAlreadyRemoved < Error; end
30
31
  class FirewallResourceNotFound < Error; end
@@ -40,6 +41,7 @@ module HCloud
40
41
  class LoadBalancerPublicInterfaceDisabled < Error; end
41
42
  class Locked < Error; end
42
43
  class Maintenance < Error; end
44
+ class MustBeUnassigned < Error; end
43
45
  class NetworksOverlap < Error; end
44
46
  class NoSpaceLeftInLocation < Error; end
45
47
  class NoSubnetAvailable < Error; end
@@ -7,6 +7,7 @@ module HCloud
7
7
 
8
8
  include Concerns
9
9
  include DeprecatedAttributes
10
+ include DeprecatedResource
10
11
  include DynamicAttributes
11
12
  include InspectAttributes
12
13
  include Subresource
@@ -4,27 +4,6 @@ module HCloud
4
4
  ##
5
5
  # Represents an action
6
6
  #
7
- # == List all actions
8
- #
9
- # HCloud::Action.all
10
- # # => [#<HCloud::Action id: 1, ...>, ...]
11
- #
12
- # == Sort actions
13
- #
14
- # HCloud::Action.sort(command: :desc)
15
- # # => [#<HCloud::Action id: 1, ...>, ...]
16
- #
17
- # HCloud::Action.sort(:id, command: :asc)
18
- # # => [#<HCloud::Action id: 1, ...>, ...]
19
- #
20
- # == Search actions
21
- #
22
- # HCloud::Action.where(command: "my_action")
23
- # # => #<HCloud::Action id: 1, ...>
24
- #
25
- # HCloud::Action.where(status: "success")
26
- # # => #<HCloud::Action id: 1, ...>
27
- #
28
7
  # == Find action by ID
29
8
  #
30
9
  # HCloud::Action.find(1)
@@ -46,11 +25,7 @@ module HCloud
46
25
  attribute :resources, :resource, array: true, default: -> { [] }
47
26
 
48
27
  class << self
49
- def all
50
- warn "[DEPRECATION] Starting on 1 October 2023, this endpoint will no longer be available. After that, it won't be possible anymore to list all actions across all resources. As an alternative, you can use the action endpoints of a specific resource to list all actions (e.g. of all servers or of all Load Balancers)."
51
-
52
- super
53
- end
28
+ undef_method :all, :first, :last, :count, :where, :sort, :each, :empty?, :any?
54
29
  end
55
30
  end
56
31
  end
@@ -33,6 +33,8 @@ module HCloud
33
33
  # # => #<HCloud::Datacenter id: 2, ...>
34
34
  #
35
35
  class Datacenter < Resource
36
+ deprecated since: "2026-10-01"
37
+
36
38
  queryable
37
39
 
38
40
  attribute :id, :integer
@@ -184,7 +184,7 @@ module HCloud
184
184
  # TODO: use only for creation
185
185
  attribute :public_interface, :boolean
186
186
 
187
- attribute :private_net, :load_balancer_private_net
187
+ attribute :private_net, :load_balancer_private_net, array: true, default: -> { [] }
188
188
  attribute :public_net, :load_balancer_public_net
189
189
 
190
190
  attribute :services, :service, array: true, default: -> { [] }
@@ -33,6 +33,8 @@ module HCloud
33
33
 
34
34
  attribute :prices, :price, array: true, default: -> { [] }
35
35
 
36
- attribute :deprecated, :datetime
36
+ attribute :deprecation, :deprecation
37
+
38
+ attribute :deprecated, :datetime, deprecated: true
37
39
  end
38
40
  end
@@ -44,6 +44,9 @@ module HCloud
44
44
  # firewall = HCloud::Server.create(name: "my_server", image: "debian-11", server_type: "cx11")
45
45
  # # => #<HCloud::Server id: 1, ...>
46
46
  #
47
+ # # Create a server with a private IP only
48
+ # server = HCloud::Server.create(name: "my_server", image: "debian-11", server_type: "cx11", public_net: { enable_ipv4: false, enable_ipv6: false }, networks: [network_id])
49
+ #
47
50
  # == Update server
48
51
  #
49
52
  # server = HCloud::Server.find(1)
@@ -168,7 +171,7 @@ module HCloud
168
171
  action :request_console
169
172
 
170
173
  def creatable_attributes
171
- [: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]
174
+ [:name, :automount, :start_after_create, :user_data, :labels, :public_net, datacenter: [:id, :name], image: [:id, :name], location: [:id, :name], server_type: [:id, :name], ssh_keys: [:id, :name], firewalls: :id, networks: :id, volumes: :id]
172
175
  end
173
176
 
174
177
  def updatable_attributes
@@ -3,7 +3,7 @@
3
3
  module HCloud
4
4
  # @!visibility private
5
5
  module Version
6
- MAJOR = 5
6
+ MAJOR = 6
7
7
  MINOR = 1
8
8
  PATCH = 0
9
9
  PRE = nil
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: 5.1.0
4
+ version: 6.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Dejonckheere
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-04-03 00:00:00.000000000 Z
11
+ date: 2026-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -102,6 +102,7 @@ files:
102
102
  - lib/hcloud/concerns/creatable.rb
103
103
  - lib/hcloud/concerns/deletable.rb
104
104
  - lib/hcloud/concerns/deprecated_attributes.rb
105
+ - lib/hcloud/concerns/deprecated_resource.rb
105
106
  - lib/hcloud/concerns/dynamic_attributes.rb
106
107
  - lib/hcloud/concerns/inspect_attributes.rb
107
108
  - lib/hcloud/concerns/labelable.rb