hcloud 1.0.3 → 1.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: a461edd72b44398c79ea0fb49a47457864551df5157572f9ce7e41fb8761b2c1
4
- data.tar.gz: 8dcfe208c66dd462d444da2cdcc6e5ef65fa5595cea900c7406fdff0e5da8f7b
3
+ metadata.gz: 0f32bc658bc4cb2d5151d8af866b7f09769b688bdda0fb3626932ba02268dd1c
4
+ data.tar.gz: c9882c417f63c0b7100540cbfb3c86c299674904ac4676a5b85e934d888a72d8
5
5
  SHA512:
6
- metadata.gz: eabc376f9c8d3fe45a8b09aa30195a8d877cdf7bfa18c2a9dab93d19be45e418a745a270aba90213ccf9adf7eee772a6880e9a8e6cacf20bbe26fc5410985438
7
- data.tar.gz: 5e4bb090f48e683bbf0895d091ed8b6e74bb53f8d1f965638a5c8749241d1e562b5e9387dfe4306570666dd9b88c10fae00446a52723ff62b663caf6646707b8
6
+ metadata.gz: d0f0a02ffe7bf1f53b2da59775df790d3340616a4c1a30c15cd24c6556d8412e713286b7d690e9c618ebfa9682b81f2ee1a6543e5c056b02c121f0655db3a818
7
+ data.tar.gz: 3c5e42fdca1fa5e0e1ce8050052583b4055ae5a0b9206a8d020721d5f845ebdc26ffd99696d4fa9fac943cc9cf17f6b0de3306daa74bdc7f87d4fa719f963ac2
data/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # Changelog
2
2
 
3
+ ## [v1.1.0](https://github.com/tonobo/hcloud-ruby/tree/v1.1.0) (2022-11-29)
4
+
5
+ [Full Changelog](https://github.com/tonobo/hcloud-ruby/compare/v1.0.3...v1.1.0)
6
+
7
+ **Closed issues:**
8
+
9
+ - Doubles tests failure with seed 50938 [\#46](https://github.com/tonobo/hcloud-ruby/issues/46)
10
+ - \[Feature\] Add missing Resources/Endpoints Q1/2022 [\#24](https://github.com/tonobo/hcloud-ruby/issues/24)
11
+ - \[Dependencies\] Unpin activesupport [\#23](https://github.com/tonobo/hcloud-ruby/issues/23)
12
+
13
+ **Merged pull requests:**
14
+
15
+ - handle action array responses for firewall actions [\#48](https://github.com/tonobo/hcloud-ruby/pull/48) ([aufziehvogel](https://github.com/aufziehvogel))
16
+ - fix auto pagination test to always use three pages [\#47](https://github.com/tonobo/hcloud-ruby/pull/47) ([aufziehvogel](https://github.com/aufziehvogel))
17
+ - label support \(create, update, search\) [\#45](https://github.com/tonobo/hcloud-ruby/pull/45) ([aufziehvogel](https://github.com/aufziehvogel))
18
+ - set Github Workflow badge for build status [\#44](https://github.com/tonobo/hcloud-ruby/pull/44) ([aufziehvogel](https://github.com/aufziehvogel))
19
+ - fix rubocop linting warnings [\#42](https://github.com/tonobo/hcloud-ruby/pull/42) ([aufziehvogel](https://github.com/aufziehvogel))
20
+ - Implement firewall support [\#41](https://github.com/tonobo/hcloud-ruby/pull/41) ([aufziehvogel](https://github.com/aufziehvogel))
21
+ - Create unit tests for networks [\#40](https://github.com/tonobo/hcloud-ruby/pull/40) ([aufziehvogel](https://github.com/aufziehvogel))
22
+ - fix typo in exception name ResourceUnavailable [\#39](https://github.com/tonobo/hcloud-ruby/pull/39) ([aufziehvogel](https://github.com/aufziehvogel))
23
+ - Bump rack from 2.2.3 to 2.2.3.1 [\#38](https://github.com/tonobo/hcloud-ruby/pull/38) ([dependabot[bot]](https://github.com/apps/dependabot))
24
+ - dependency: update + unpin activesupport [\#36](https://github.com/tonobo/hcloud-ruby/pull/36) ([RaphaelPour](https://github.com/RaphaelPour))
25
+ - Add MIT license to gemspec [\#34](https://github.com/tonobo/hcloud-ruby/pull/34) ([bastelfreak](https://github.com/bastelfreak))
26
+ - Create LICENSE [\#33](https://github.com/tonobo/hcloud-ruby/pull/33) ([RaphaelPour](https://github.com/RaphaelPour))
27
+ - Update server attributes [\#32](https://github.com/tonobo/hcloud-ruby/pull/32) ([RaphaelPour](https://github.com/RaphaelPour))
28
+
3
29
  ## [v1.0.3](https://github.com/tonobo/hcloud-ruby/tree/v1.0.3) (2022-02-17)
4
30
 
5
31
  [Full Changelog](https://github.com/tonobo/hcloud-ruby/compare/v1.0.2...v1.0.3)
@@ -10,6 +36,7 @@
10
36
 
11
37
  **Merged pull requests:**
12
38
 
39
+ - bump version to v1.0.3 [\#22](https://github.com/tonobo/hcloud-ruby/pull/22) ([RaphaelPour](https://github.com/RaphaelPour))
13
40
  - lib: adjust code to work with 3.x ruby versions [\#21](https://github.com/tonobo/hcloud-ruby/pull/21) ([Kjarrigan](https://github.com/Kjarrigan))
14
41
  - ci: add github workflow [\#20](https://github.com/tonobo/hcloud-ruby/pull/20) ([RaphaelPour](https://github.com/RaphaelPour))
15
42
 
data/Gemfile.lock CHANGED
@@ -3,21 +3,19 @@ PATH
3
3
  specs:
4
4
  hcloud (1.0.3)
5
5
  activemodel
6
- activesupport (= 6.1.4.4)
7
6
  oj
8
7
  typhoeus
9
8
 
10
9
  GEM
11
10
  remote: https://rubygems.org/
12
11
  specs:
13
- activemodel (6.1.4.4)
14
- activesupport (= 6.1.4.4)
15
- activesupport (6.1.4.4)
12
+ activemodel (7.0.3)
13
+ activesupport (= 7.0.3)
14
+ activesupport (7.0.3)
16
15
  concurrent-ruby (~> 1.0, >= 1.0.2)
17
16
  i18n (>= 1.6, < 2)
18
17
  minitest (>= 5.1)
19
18
  tzinfo (~> 2.0)
20
- zeitwerk (~> 2.3)
21
19
  addressable (2.8.0)
22
20
  public_suffix (>= 2.0.2, < 5.0)
23
21
  ast (2.4.2)
@@ -25,12 +23,12 @@ GEM
25
23
  codecov (0.6.0)
26
24
  simplecov (>= 0.15, < 0.22)
27
25
  coderay (1.1.3)
28
- concurrent-ruby (1.1.9)
26
+ concurrent-ruby (1.1.10)
29
27
  crack (0.4.5)
30
28
  rexml
31
29
  diff-lcs (1.5.0)
32
30
  docile (1.4.0)
33
- dry-configurable (0.14.0)
31
+ dry-configurable (0.15.0)
34
32
  concurrent-ruby (~> 1.0)
35
33
  dry-core (~> 0.6)
36
34
  dry-container (0.9.0)
@@ -50,8 +48,8 @@ GEM
50
48
  dry-logic (~> 1.0, >= 1.0.2)
51
49
  ethon (0.15.0)
52
50
  ffi (>= 1.15.0)
53
- faker (2.19.0)
54
- i18n (>= 1.6, < 2)
51
+ faker (2.20.0)
52
+ i18n (>= 1.8.11, < 2)
55
53
  ffi (1.15.5)
56
54
  grape (1.6.2)
57
55
  activesupport
@@ -67,22 +65,22 @@ GEM
67
65
  minitest (5.15.0)
68
66
  mustermann (1.1.1)
69
67
  ruby2_keywords (~> 0.0.1)
70
- mustermann-grape (1.0.1)
68
+ mustermann-grape (1.0.2)
71
69
  mustermann (>= 1.0.0)
72
70
  oj (3.13.11)
73
- parallel (1.21.0)
74
- parser (3.1.0.0)
71
+ parallel (1.22.1)
72
+ parser (3.1.2.0)
75
73
  ast (~> 2.4.1)
76
74
  pry (0.14.1)
77
75
  coderay (~> 1.1)
78
76
  method_source (~> 1.0)
79
- public_suffix (4.0.6)
80
- rack (2.2.3)
77
+ public_suffix (4.0.7)
78
+ rack (2.2.3.1)
81
79
  rack-accept (0.4.5)
82
80
  rack (>= 0.4)
83
81
  rainbow (3.1.1)
84
82
  rake (13.0.6)
85
- regexp_parser (2.2.1)
83
+ regexp_parser (2.4.0)
86
84
  rexml (3.2.5)
87
85
  rspec (3.11.0)
88
86
  rspec-core (~> 3.11.0)
@@ -93,21 +91,21 @@ GEM
93
91
  rspec-expectations (3.11.0)
94
92
  diff-lcs (>= 1.2.0, < 2.0)
95
93
  rspec-support (~> 3.11.0)
96
- rspec-mocks (3.11.0)
94
+ rspec-mocks (3.11.1)
97
95
  diff-lcs (>= 1.2.0, < 2.0)
98
96
  rspec-support (~> 3.11.0)
99
97
  rspec-support (3.11.0)
100
- rubocop (1.25.1)
98
+ rubocop (1.29.0)
101
99
  parallel (~> 1.10)
102
100
  parser (>= 3.1.0.0)
103
101
  rainbow (>= 2.2.2, < 4.0)
104
102
  regexp_parser (>= 1.8, < 3.0)
105
- rexml
106
- rubocop-ast (>= 1.15.1, < 2.0)
103
+ rexml (>= 3.2.5, < 4.0)
104
+ rubocop-ast (>= 1.17.0, < 2.0)
107
105
  ruby-progressbar (~> 1.7)
108
106
  unicode-display_width (>= 1.4.0, < 3.0)
109
- rubocop-ast (1.15.2)
110
- parser (>= 3.0.1.1)
107
+ rubocop-ast (1.17.0)
108
+ parser (>= 3.1.1.0)
111
109
  ruby-progressbar (1.11.0)
112
110
  ruby2_keywords (0.0.5)
113
111
  simplecov (0.21.2)
@@ -125,7 +123,6 @@ GEM
125
123
  addressable (>= 2.8.0)
126
124
  crack (>= 0.3.2)
127
125
  hashdiff (>= 0.4.0, < 2.0.0)
128
- zeitwerk (2.5.4)
129
126
 
130
127
  PLATFORMS
131
128
  ruby
@@ -133,7 +130,6 @@ PLATFORMS
133
130
 
134
131
  DEPENDENCIES
135
132
  activemodel
136
- activesupport (= 6.1.4.4)
137
133
  bundler
138
134
  codecov
139
135
  faker
@@ -146,4 +142,4 @@ DEPENDENCIES
146
142
  webmock
147
143
 
148
144
  BUNDLED WITH
149
- 2.3.7
145
+ 2.3.9
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Tim Foerster
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Hcloud
2
2
 
3
- [![Build Status](https://travis-ci.org/tonobo/hcloud-ruby.svg?branch=master)](https://travis-ci.org/tonobo/hcloud-ruby)
3
+ [![Build Status](https://github.com/tonobo/hcloud-ruby/actions/workflows/ruby.yml/badge.svg)](https://github.com/tonobo/hcloud-ruby/actions/workflows/ruby.yml)
4
4
  [![codecov](https://codecov.io/gh/tonobo/hcloud-ruby/branch/master/graph/badge.svg)](https://codecov.io/gh/tonobo/hcloud-ruby)
5
5
  [![Gem Version](https://badge.fury.io/rb/hcloud.svg)](https://badge.fury.io/rb/hcloud)
6
6
  [![Maintainability](https://api.codeclimate.com/v1/badges/aa67f9d590d86845822f/maintainability)](https://codeclimate.com/github/tonobo/hcloud-ruby/maintainability)
data/bin/console CHANGED
@@ -8,8 +8,8 @@ require 'hcloud'
8
8
  # with your gem easier. You can also use a different console, if you like.
9
9
 
10
10
  # (If you use this, don't forget to add pry to your Gemfile!)
11
- # require "pry"
12
- # Pry.start
11
+ require 'pry'
12
+ Pry.start
13
13
 
14
- require 'irb'
15
- IRB.start(__FILE__)
14
+ # require 'irb'
15
+ # IRB.start(__FILE__)
data/hcloud.gemspec CHANGED
@@ -12,6 +12,7 @@ Gem::Specification.new do |spec|
12
12
 
13
13
  spec.summary = 'HetznerCloud native Ruby client'
14
14
  spec.homepage = 'https://github.com/tonobo/hcloud-ruby'
15
+ spec.license = 'MIT'
15
16
 
16
17
  spec.required_ruby_version = '>= 2.7.0'
17
18
 
@@ -23,14 +24,12 @@ Gem::Specification.new do |spec|
23
24
  spec.require_paths = ['lib']
24
25
 
25
26
  spec.add_development_dependency 'activemodel'
26
- spec.add_development_dependency 'activesupport', '6.1.4.4'
27
27
  spec.add_development_dependency 'bundler'
28
28
  spec.add_development_dependency 'grape'
29
29
  spec.add_development_dependency 'rake'
30
30
  spec.add_development_dependency 'rspec'
31
31
  spec.add_development_dependency 'webmock'
32
32
  spec.add_runtime_dependency 'activemodel'
33
- spec.add_runtime_dependency 'activesupport', '6.1.4.4'
34
33
  spec.add_runtime_dependency 'oj'
35
34
  spec.add_runtime_dependency 'typhoeus'
36
35
  end
data/lib/hcloud/client.rb CHANGED
@@ -94,6 +94,10 @@ module Hcloud
94
94
  NetworkResource.new(client: self)
95
95
  end
96
96
 
97
+ def firewalls
98
+ FirewallResource.new(client: self)
99
+ end
100
+
97
101
  def volumes
98
102
  VolumeResource.new(client: self)
99
103
  end
@@ -74,34 +74,57 @@ module Hcloud
74
74
 
75
75
  def from_response(response, autoload_action: nil)
76
76
  attributes = response.resource_attributes
77
- action = response.parsed_json[:action] if autoload_action
77
+
78
+ action_resp = _try_load_action(response) if autoload_action
79
+ return action_resp unless attributes || action_resp.nil?
80
+
78
81
  client = response.context.client
79
82
  if attributes.is_a?(Array)
80
- results = attributes.map { |item| new(item).tap { |entity| entity.response = response } }
83
+ results = attributes.map do |item|
84
+ new(client, item).tap do |entity|
85
+ entity.response = response
86
+ end
87
+ end
81
88
  results.tap { |ary| ary.extend(Collection) }.response = response
82
89
  return results
83
90
  end
84
91
 
85
- return Action.new(client, action) if attributes.nil? && action
86
- return new(attributes).tap { |entity| entity.response = response } if action.nil?
92
+ if action_resp.nil?
93
+ return new(client, attributes).tap { |entity| entity.response = response }
94
+ end
87
95
 
88
96
  [
89
- Action.new(client, action),
90
- new(attributes).tap { |entity| entity.response = response }
97
+ action_resp,
98
+ new(client, attributes).tap { |entity| entity.response = response }
91
99
  ]
92
100
  end
93
- end
94
101
 
95
- attr_accessor :response
102
+ def _try_load_action(response)
103
+ # some API endpoints return a list of actions (e.g. firewall action
104
+ # apply_to_resources), some a single action (e.g. server action
105
+ # attach_iso)
106
+ actions = response.parsed_json[:actions]
107
+ action = response.parsed_json[:action]
108
+
109
+ client = response.context.client
110
+
111
+ if actions
112
+ return actions.map do |act|
113
+ Action.new(client, act)
114
+ end
115
+ elsif action
116
+ return Action.new(client, action)
117
+ end
96
118
 
97
- def initialize(client = nil, kwargs = {})
98
- if client.is_a?(Hash)
99
- kwargs = client
100
- client = nil
119
+ nil
101
120
  end
121
+ end
122
+
123
+ attr_accessor :response
102
124
 
125
+ def initialize(client = nil, resource = {})
103
126
  @client = client
104
- _load(kwargs)
127
+ _load(resource)
105
128
  end
106
129
 
107
130
  def inspect
@@ -179,7 +202,10 @@ module Hcloud
179
202
  instance_variable_set("@#{key}", value)
180
203
  end
181
204
 
205
+ # rubocop: disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/MethodLength, Metrics/AbcSize
182
206
  def _load(resource)
207
+ return if resource.nil?
208
+
183
209
  @_attributes = {}.with_indifferent_access
184
210
 
185
211
  resource.each do |key, value|
@@ -195,8 +221,30 @@ module Hcloud
195
221
  next
196
222
  end
197
223
 
224
+ # if schema definition is [Class]
225
+ if definition.is_a?(Array) && definition.first.include?(EntryLoader)
226
+
227
+ # just set attribute to an empty array if value is no array or empty
228
+ if !value.is_a?(Array) || value.empty?
229
+ _update_attribute(key, [])
230
+ next
231
+ end
232
+
233
+ if value.first.is_a?(Integer)
234
+ # If value is an integer, this is the id of an object which's class can be
235
+ # retreived from definition. Load a future object that can on access retreive the
236
+ # data from the api and convert it to a proper object.
237
+ _update_attribute(key, value.map { |id| Future.new(client, definition.first, id) })
238
+ else
239
+ # Otherwise the value *is* the content of the object
240
+ _update_attribute(key, value.map { |item| definition.first.new(client, item) })
241
+ end
242
+ next
243
+ end
244
+
198
245
  _update_attribute(key, value.is_a?(Hash) ? value.with_indifferent_access : value)
199
246
  end
200
247
  end
248
+ # rubocop: enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/MethodLength, Metrics/AbcSize
201
249
  end
202
250
  end
data/lib/hcloud/errors.rb CHANGED
@@ -9,7 +9,7 @@ module Hcloud
9
9
  class Locked < Error; end
10
10
  class NotFound < Error; end
11
11
  class RateLimitExceeded < Error; end
12
- class ResourceUnavilable < Error; end
12
+ class ResourceUnavailable < Error; end
13
13
  class ServiceError < Error; end
14
14
  class UniquenessError < Error; end
15
15
  class UnknownError < Error; end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hcloud
4
+ class Firewall
5
+ require 'hcloud/firewall_resource'
6
+
7
+ include EntryLoader
8
+
9
+ updatable :name
10
+ destructible
11
+
12
+ has_actions
13
+
14
+ def set_rules(rules:) # rubocop:disable Naming/AccessorMethodName
15
+ prepare_request('actions/set_rules', j: COLLECT_ARGS.call(__method__, binding))
16
+ end
17
+
18
+ def apply_to_resources(apply_to:)
19
+ prepare_request('actions/apply_to_resources', j: COLLECT_ARGS.call(__method__, binding))
20
+ end
21
+
22
+ def remove_from_resources(remove_from:)
23
+ prepare_request('actions/remove_from_resources', j: COLLECT_ARGS.call(__method__, binding))
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hcloud
4
+ class FirewallResource < AbstractResource
5
+ filter_attributes :name, :label_selector
6
+
7
+ def [](arg)
8
+ case arg
9
+ when Integer then find_by(id: arg)
10
+ when String then find_by(name: arg)
11
+ end
12
+ end
13
+
14
+ def create(name:, rules: [], apply_to: [], labels: {})
15
+ prepare_request(
16
+ 'firewalls', j: COLLECT_ARGS.call(__method__, binding),
17
+ expected_code: 201
18
+ ) do |response|
19
+ Firewall.new(client, response.parsed_json[:firewall])
20
+ end
21
+ end
22
+ end
23
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Hcloud
4
4
  class FloatingIPResource < AbstractResource
5
- filter_attributes :name
5
+ filter_attributes :name, :label_selector
6
6
 
7
7
  bind_to FloatingIP
8
8
 
@@ -13,7 +13,7 @@ module Hcloud
13
13
  end
14
14
  end
15
15
 
16
- def create(type:, server: nil, home_location: nil, description: nil)
16
+ def create(type:, server: nil, home_location: nil, description: nil, labels: {})
17
17
  prepare_request(
18
18
  'floating_ips', j: COLLECT_ARGS.call(__method__, binding),
19
19
  expected_code: 201
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support/core_ext/string/inflections'
4
+
5
+ module Hcloud
6
+ class Future < Delegator
7
+ # rubocop: disable Lint/MissingSuper
8
+ def initialize(client, target_class, id)
9
+ @target_class = target_class
10
+ @id = id
11
+ @__client = client
12
+ end
13
+ # rubocop: enable Lint/MissingSuper
14
+
15
+ def __getobj__
16
+ # pluralize class name and convert it to symbol
17
+ @__getobj__ ||= @__client.public_send(
18
+ @target_class.name # full name of the class including namespaces
19
+ .demodulize # last module name only
20
+ .tableize # convert to table name, split words by _ + downcase
21
+ .pluralize
22
+ .to_sym
23
+ ).find(@id)
24
+ end
25
+ end
26
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Hcloud
4
4
  class ImageResource < AbstractResource
5
- filter_attributes :type, :bound_to, :name
5
+ filter_attributes :type, :bound_to, :name, :label_selector
6
6
 
7
7
  bind_to Image
8
8
 
@@ -19,7 +19,7 @@ module Hcloud
19
19
  end
20
20
 
21
21
  def del_subnet(ip_range:)
22
- prepare_request('actions/del_subnet', j: COLLECT_ARGS.call(__method__, binding))
22
+ prepare_request('actions/delete_subnet', j: COLLECT_ARGS.call(__method__, binding))
23
23
  end
24
24
 
25
25
  def add_route(destination:, gateway:)
@@ -27,7 +27,7 @@ module Hcloud
27
27
  end
28
28
 
29
29
  def del_route(destination:, gateway:)
30
- prepare_request('actions/del_route', j: COLLECT_ARGS.call(__method__, binding))
30
+ prepare_request('actions/delete_route', j: COLLECT_ARGS.call(__method__, binding))
31
31
  end
32
32
  end
33
33
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Hcloud
4
4
  class NetworkResource < AbstractResource
5
- filter_attributes :name
5
+ filter_attributes :name, :label_selector
6
6
 
7
7
  bind_to Network
8
8
 
@@ -13,7 +13,7 @@ module Hcloud
13
13
  end
14
14
  end
15
15
 
16
- def create(name:, ip_range:, subnets: nil, routes: nil)
16
+ def create(name:, ip_range:, subnets: nil, routes: nil, labels: {})
17
17
  prepare_request(
18
18
  'networks', j: COLLECT_ARGS.call(__method__, binding),
19
19
  expected_code: 201
data/lib/hcloud/server.rb CHANGED
@@ -10,7 +10,10 @@ module Hcloud
10
10
  created: :time,
11
11
  server_type: ServerType,
12
12
  datacenter: Datacenter,
13
- image: Image
13
+ image: Image,
14
+ iso: Iso,
15
+ private_net: [Network],
16
+ volumes: [Volume]
14
17
  )
15
18
 
16
19
  protectable :delete, :rebuild
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Hcloud
4
4
  class ServerResource < AbstractResource
5
- filter_attributes :status, :name
5
+ filter_attributes :status, :name, :label_selector
6
6
 
7
7
  bind_to Server
8
8
 
@@ -13,7 +13,8 @@ module Hcloud
13
13
  start_after_create: nil,
14
14
  ssh_keys: [],
15
15
  networks: [],
16
- user_data: nil)
16
+ user_data: nil,
17
+ labels: {})
17
18
  prepare_request('servers', j: COLLECT_ARGS.call(__method__, binding),
18
19
  expected_code: 201) do |response|
19
20
  [
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Hcloud
4
4
  class SSHKeyResource < AbstractResource
5
- filter_attributes :name
5
+ filter_attributes :name, :label_selector
6
6
 
7
7
  def [](arg)
8
8
  case arg
@@ -11,7 +11,7 @@ module Hcloud
11
11
  end
12
12
  end
13
13
 
14
- def create(name:, public_key:)
14
+ def create(name:, public_key:, labels: {})
15
15
  prepare_request(
16
16
  'ssh_keys', j: COLLECT_ARGS.call(__method__, binding),
17
17
  expected_code: 201
@@ -58,7 +58,7 @@ module Hcloud
58
58
  end
59
59
 
60
60
  def pagination
61
- @pagination ||= Pagination.new(parsed_json[:meta].to_h[:pagination])
61
+ @pagination ||= Pagination.new(nil, parsed_json[:meta].to_h[:pagination])
62
62
  end
63
63
 
64
64
  def resource_attributes
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Hcloud
4
- VERSION = '1.0.3'
4
+ VERSION = '1.1.0'
5
5
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Hcloud
4
4
  class VolumeResource < AbstractResource
5
- filter_attributes :name
5
+ filter_attributes :name, :label_selector
6
6
 
7
7
  def [](arg)
8
8
  case arg
@@ -11,7 +11,7 @@ module Hcloud
11
11
  end
12
12
  end
13
13
 
14
- def create(size:, name:, automount: nil, format: nil, location: nil, server: nil)
14
+ def create(size:, name:, automount: nil, format: nil, location: nil, server: nil, labels: {})
15
15
  prepare_request(
16
16
  'volumes', j: COLLECT_ARGS.call(__method__, binding),
17
17
  expected_code: 201
data/lib/hcloud.rb CHANGED
@@ -7,6 +7,7 @@ require 'active_support/core_ext/hash/indifferent_access'
7
7
  module Hcloud
8
8
  autoload :Error, 'hcloud/errors'
9
9
  autoload :Client, 'hcloud/client'
10
+ autoload :Future, 'hcloud/future'
10
11
  autoload :TyphoeusExt, 'hcloud/typhoeus_ext'
11
12
  autoload :AbstractResource, 'hcloud/abstract_resource'
12
13
  autoload :EntryLoader, 'hcloud/entry_loader'
@@ -35,6 +36,9 @@ module Hcloud
35
36
  autoload :Network, 'hcloud/network'
36
37
  autoload :NetworkResource, 'hcloud/network_resource'
37
38
 
39
+ autoload :Firewall, 'hcloud/firewall'
40
+ autoload :FirewallResource, 'hcloud/firewall_resource'
41
+
38
42
  autoload :Volume, 'hcloud/volume'
39
43
  autoload :VolumeResource, 'hcloud/volume_resource'
40
44
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hcloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Foerster
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2022-02-17 00:00:00.000000000 Z
12
+ date: 2022-11-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activemodel
@@ -25,20 +25,6 @@ dependencies:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
27
  version: '0'
28
- - !ruby/object:Gem::Dependency
29
- name: activesupport
30
- requirement: !ruby/object:Gem::Requirement
31
- requirements:
32
- - - '='
33
- - !ruby/object:Gem::Version
34
- version: 6.1.4.4
35
- type: :development
36
- prerelease: false
37
- version_requirements: !ruby/object:Gem::Requirement
38
- requirements:
39
- - - '='
40
- - !ruby/object:Gem::Version
41
- version: 6.1.4.4
42
28
  - !ruby/object:Gem::Dependency
43
29
  name: bundler
44
30
  requirement: !ruby/object:Gem::Requirement
@@ -123,20 +109,6 @@ dependencies:
123
109
  - - ">="
124
110
  - !ruby/object:Gem::Version
125
111
  version: '0'
126
- - !ruby/object:Gem::Dependency
127
- name: activesupport
128
- requirement: !ruby/object:Gem::Requirement
129
- requirements:
130
- - - '='
131
- - !ruby/object:Gem::Version
132
- version: 6.1.4.4
133
- type: :runtime
134
- prerelease: false
135
- version_requirements: !ruby/object:Gem::Requirement
136
- requirements:
137
- - - '='
138
- - !ruby/object:Gem::Version
139
- version: 6.1.4.4
140
112
  - !ruby/object:Gem::Dependency
141
113
  name: oj
142
114
  requirement: !ruby/object:Gem::Requirement
@@ -181,6 +153,7 @@ files:
181
153
  - CHANGELOG.md
182
154
  - Gemfile
183
155
  - Gemfile.lock
156
+ - LICENSE
184
157
  - README.md
185
158
  - Rakefile
186
159
  - bin/console
@@ -195,8 +168,11 @@ files:
195
168
  - lib/hcloud/datacenter_resource.rb
196
169
  - lib/hcloud/entry_loader.rb
197
170
  - lib/hcloud/errors.rb
171
+ - lib/hcloud/firewall.rb
172
+ - lib/hcloud/firewall_resource.rb
198
173
  - lib/hcloud/floating_ip.rb
199
174
  - lib/hcloud/floating_ip_resource.rb
175
+ - lib/hcloud/future.rb
200
176
  - lib/hcloud/image.rb
201
177
  - lib/hcloud/image_resource.rb
202
178
  - lib/hcloud/iso.rb
@@ -217,7 +193,8 @@ files:
217
193
  - lib/hcloud/volume.rb
218
194
  - lib/hcloud/volume_resource.rb
219
195
  homepage: https://github.com/tonobo/hcloud-ruby
220
- licenses: []
196
+ licenses:
197
+ - MIT
221
198
  metadata: {}
222
199
  post_install_message:
223
200
  rdoc_options: []
@@ -234,7 +211,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
234
211
  - !ruby/object:Gem::Version
235
212
  version: '0'
236
213
  requirements: []
237
- rubygems_version: 3.2.22
214
+ rubygems_version: 3.1.6
238
215
  signing_key:
239
216
  specification_version: 4
240
217
  summary: HetznerCloud native Ruby client