hcloud 1.0.3 → 1.2.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 +58 -0
- data/Gemfile.lock +56 -63
- data/LICENSE +21 -0
- data/README.md +1 -1
- data/bin/console +4 -4
- data/hcloud.gemspec +1 -3
- data/lib/hcloud/certificate.rb +22 -0
- data/lib/hcloud/certificate_resource.rb +43 -0
- data/lib/hcloud/client.rb +24 -0
- data/lib/hcloud/entry_loader.rb +82 -13
- data/lib/hcloud/errors.rb +1 -1
- data/lib/hcloud/firewall.rb +37 -0
- data/lib/hcloud/firewall_resource.rb +30 -0
- data/lib/hcloud/floating_ip.rb +4 -0
- data/lib/hcloud/floating_ip_resource.rb +7 -2
- data/lib/hcloud/future.rb +26 -0
- data/lib/hcloud/image_resource.rb +1 -1
- data/lib/hcloud/load_balancer.rb +140 -0
- data/lib/hcloud/load_balancer_resource.rb +39 -0
- data/lib/hcloud/load_balancer_type.rb +13 -0
- data/lib/hcloud/load_balancer_type_resource.rb +16 -0
- data/lib/hcloud/network.rb +13 -2
- data/lib/hcloud/network_resource.rb +5 -2
- data/lib/hcloud/placement_group.rb +16 -0
- data/lib/hcloud/placement_group_resource.rb +30 -0
- data/lib/hcloud/primary_ip.rb +35 -0
- data/lib/hcloud/primary_ip_resource.rb +46 -0
- data/lib/hcloud/server.rb +16 -2
- data/lib/hcloud/server_resource.rb +7 -3
- data/lib/hcloud/ssh_key.rb +4 -0
- data/lib/hcloud/ssh_key_resource.rb +8 -2
- data/lib/hcloud/typhoeus_ext.rb +2 -2
- data/lib/hcloud/version.rb +1 -1
- data/lib/hcloud/volume.rb +5 -1
- data/lib/hcloud/volume_resource.rb +8 -2
- data/lib/hcloud.rb +20 -0
- metadata +19 -47
- data/Rakefile +0 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cdd378e8381d39a1fccf8cd2ce72ff3f024985fb5d5599978e928464e0018576
|
|
4
|
+
data.tar.gz: 885c2e766e37f274622be8a3519da323608576a765ba5dd7d104da1fd9c3237d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3e163d935512c077fbc7e3c94281d48aa1ba95eab1e5743190a66ab800e729ab1c8a905a974f86ca78c0e280bd77bc5763b9ec25e3b8b55db4725a8115cbabce
|
|
7
|
+
data.tar.gz: e26b48bb02882a3ec78b4412236466619a0e21759b9ba2f9f518fd17a591a0e1a0f9d3e344f63ef3502cbf3e293fc62577250247cc4f1b04908c2532bdbee7e2
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,62 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [v1.2.0](https://github.com/tonobo/hcloud-ruby/tree/v1.2.0) (2023-10-10)
|
|
4
|
+
|
|
5
|
+
[Full Changelog](https://github.com/tonobo/hcloud-ruby/compare/v1.1.0...v1.2.0)
|
|
6
|
+
|
|
7
|
+
**Closed issues:**
|
|
8
|
+
|
|
9
|
+
- \[Feature\] Add Primary IPs [\#57](https://github.com/tonobo/hcloud-ruby/issues/57)
|
|
10
|
+
- \[Feature\] Add Primary IPs [\#56](https://github.com/tonobo/hcloud-ruby/issues/56)
|
|
11
|
+
- \[Bug\] Firewalls do not expose actions [\#54](https://github.com/tonobo/hcloud-ruby/issues/54)
|
|
12
|
+
- \[Bug\] IPv6 global address is not parsed correctly [\#49](https://github.com/tonobo/hcloud-ruby/issues/49)
|
|
13
|
+
- \[Feature\] Add LoadBalancers and -Types [\#29](https://github.com/tonobo/hcloud-ruby/issues/29)
|
|
14
|
+
- \[Feature\] Add PlacementGroups [\#27](https://github.com/tonobo/hcloud-ruby/issues/27)
|
|
15
|
+
- \[Feature\] Add Certificates [\#26](https://github.com/tonobo/hcloud-ruby/issues/26)
|
|
16
|
+
- \[Feature\] Add Firewalls [\#25](https://github.com/tonobo/hcloud-ruby/issues/25)
|
|
17
|
+
|
|
18
|
+
**Merged pull requests:**
|
|
19
|
+
|
|
20
|
+
- lib: import active\_support before cherry-picking imports [\#77](https://github.com/tonobo/hcloud-ruby/pull/77) ([aufziehvogel](https://github.com/aufziehvogel))
|
|
21
|
+
- Dependencies: Drop rake, as it's unnecessary [\#74](https://github.com/tonobo/hcloud-ruby/pull/74) ([Kjarrigan](https://github.com/Kjarrigan))
|
|
22
|
+
- server: return `next_actions` data on create [\#72](https://github.com/tonobo/hcloud-ruby/pull/72) ([aufziehvogel](https://github.com/aufziehvogel))
|
|
23
|
+
- lib: implement primary IPs [\#65](https://github.com/tonobo/hcloud-ruby/pull/65) ([aufziehvogel](https://github.com/aufziehvogel))
|
|
24
|
+
- lib: implement certificates [\#64](https://github.com/tonobo/hcloud-ruby/pull/64) ([aufziehvogel](https://github.com/aufziehvogel))
|
|
25
|
+
- spec: include context doubles for doubles tests [\#63](https://github.com/tonobo/hcloud-ruby/pull/63) ([aufziehvogel](https://github.com/aufziehvogel))
|
|
26
|
+
- fix: return actions info on firewall create [\#59](https://github.com/tonobo/hcloud-ruby/pull/59) ([aufziehvogel](https://github.com/aufziehvogel))
|
|
27
|
+
- fix: do not interpret leading : in JSON as symbol [\#58](https://github.com/tonobo/hcloud-ruby/pull/58) ([aufziehvogel](https://github.com/aufziehvogel))
|
|
28
|
+
- lib: implement load balancer [\#55](https://github.com/tonobo/hcloud-ruby/pull/55) ([aufziehvogel](https://github.com/aufziehvogel))
|
|
29
|
+
- implement double tests for existing resources [\#53](https://github.com/tonobo/hcloud-ruby/pull/53) ([aufziehvogel](https://github.com/aufziehvogel))
|
|
30
|
+
- Add PlacementGroup [\#52](https://github.com/tonobo/hcloud-ruby/pull/52) ([aufziehvogel](https://github.com/aufziehvogel))
|
|
31
|
+
- firewall: please linter [\#51](https://github.com/tonobo/hcloud-ruby/pull/51) ([RaphaelPour](https://github.com/RaphaelPour))
|
|
32
|
+
|
|
33
|
+
## [v1.1.0](https://github.com/tonobo/hcloud-ruby/tree/v1.1.0) (2022-11-29)
|
|
34
|
+
|
|
35
|
+
[Full Changelog](https://github.com/tonobo/hcloud-ruby/compare/v1.0.3...v1.1.0)
|
|
36
|
+
|
|
37
|
+
**Closed issues:**
|
|
38
|
+
|
|
39
|
+
- Doubles tests failure with seed 50938 [\#46](https://github.com/tonobo/hcloud-ruby/issues/46)
|
|
40
|
+
- \[Feature\] Add missing Resources/Endpoints Q1/2022 [\#24](https://github.com/tonobo/hcloud-ruby/issues/24)
|
|
41
|
+
- \[Dependencies\] Unpin activesupport [\#23](https://github.com/tonobo/hcloud-ruby/issues/23)
|
|
42
|
+
|
|
43
|
+
**Merged pull requests:**
|
|
44
|
+
|
|
45
|
+
- version: bump to v1.1.0 [\#50](https://github.com/tonobo/hcloud-ruby/pull/50) ([aufziehvogel](https://github.com/aufziehvogel))
|
|
46
|
+
- handle action array responses for firewall actions [\#48](https://github.com/tonobo/hcloud-ruby/pull/48) ([aufziehvogel](https://github.com/aufziehvogel))
|
|
47
|
+
- fix auto pagination test to always use three pages [\#47](https://github.com/tonobo/hcloud-ruby/pull/47) ([aufziehvogel](https://github.com/aufziehvogel))
|
|
48
|
+
- label support \(create, update, search\) [\#45](https://github.com/tonobo/hcloud-ruby/pull/45) ([aufziehvogel](https://github.com/aufziehvogel))
|
|
49
|
+
- set Github Workflow badge for build status [\#44](https://github.com/tonobo/hcloud-ruby/pull/44) ([aufziehvogel](https://github.com/aufziehvogel))
|
|
50
|
+
- fix rubocop linting warnings [\#42](https://github.com/tonobo/hcloud-ruby/pull/42) ([aufziehvogel](https://github.com/aufziehvogel))
|
|
51
|
+
- Implement firewall support [\#41](https://github.com/tonobo/hcloud-ruby/pull/41) ([aufziehvogel](https://github.com/aufziehvogel))
|
|
52
|
+
- Create unit tests for networks [\#40](https://github.com/tonobo/hcloud-ruby/pull/40) ([aufziehvogel](https://github.com/aufziehvogel))
|
|
53
|
+
- fix typo in exception name ResourceUnavailable [\#39](https://github.com/tonobo/hcloud-ruby/pull/39) ([aufziehvogel](https://github.com/aufziehvogel))
|
|
54
|
+
- 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))
|
|
55
|
+
- dependency: update + unpin activesupport [\#36](https://github.com/tonobo/hcloud-ruby/pull/36) ([RaphaelPour](https://github.com/RaphaelPour))
|
|
56
|
+
- Add MIT license to gemspec [\#34](https://github.com/tonobo/hcloud-ruby/pull/34) ([bastelfreak](https://github.com/bastelfreak))
|
|
57
|
+
- Create LICENSE [\#33](https://github.com/tonobo/hcloud-ruby/pull/33) ([RaphaelPour](https://github.com/RaphaelPour))
|
|
58
|
+
- Update server attributes [\#32](https://github.com/tonobo/hcloud-ruby/pull/32) ([RaphaelPour](https://github.com/RaphaelPour))
|
|
59
|
+
|
|
3
60
|
## [v1.0.3](https://github.com/tonobo/hcloud-ruby/tree/v1.0.3) (2022-02-17)
|
|
4
61
|
|
|
5
62
|
[Full Changelog](https://github.com/tonobo/hcloud-ruby/compare/v1.0.2...v1.0.3)
|
|
@@ -10,6 +67,7 @@
|
|
|
10
67
|
|
|
11
68
|
**Merged pull requests:**
|
|
12
69
|
|
|
70
|
+
- bump version to v1.0.3 [\#22](https://github.com/tonobo/hcloud-ruby/pull/22) ([RaphaelPour](https://github.com/RaphaelPour))
|
|
13
71
|
- 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
72
|
- ci: add github workflow [\#20](https://github.com/tonobo/hcloud-ruby/pull/20) ([RaphaelPour](https://github.com/RaphaelPour))
|
|
15
73
|
|
data/Gemfile.lock
CHANGED
|
@@ -1,58 +1,52 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
hcloud (1.0
|
|
4
|
+
hcloud (1.2.0)
|
|
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 (
|
|
14
|
-
activesupport (=
|
|
15
|
-
activesupport (
|
|
12
|
+
activemodel (7.0.4)
|
|
13
|
+
activesupport (= 7.0.4)
|
|
14
|
+
activesupport (7.0.4)
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
public_suffix (>= 2.0.2, < 5.0)
|
|
19
|
+
addressable (2.8.1)
|
|
20
|
+
public_suffix (>= 2.0.2, < 6.0)
|
|
23
21
|
ast (2.4.2)
|
|
24
22
|
builder (3.2.4)
|
|
25
23
|
codecov (0.6.0)
|
|
26
24
|
simplecov (>= 0.15, < 0.22)
|
|
27
25
|
coderay (1.1.3)
|
|
28
|
-
concurrent-ruby (1.1.
|
|
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-
|
|
31
|
+
dry-core (1.0.0)
|
|
34
32
|
concurrent-ruby (~> 1.0)
|
|
35
|
-
|
|
36
|
-
dry-
|
|
33
|
+
zeitwerk (~> 2.6)
|
|
34
|
+
dry-inflector (1.0.0)
|
|
35
|
+
dry-logic (1.5.0)
|
|
37
36
|
concurrent-ruby (~> 1.0)
|
|
38
|
-
dry-
|
|
39
|
-
|
|
37
|
+
dry-core (~> 1.0, < 2)
|
|
38
|
+
zeitwerk (~> 2.6)
|
|
39
|
+
dry-types (1.7.0)
|
|
40
40
|
concurrent-ruby (~> 1.0)
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
concurrent-ruby (~> 1.0)
|
|
47
|
-
dry-container (~> 0.3)
|
|
48
|
-
dry-core (~> 0.5, >= 0.5)
|
|
49
|
-
dry-inflector (~> 0.1, >= 0.1.2)
|
|
50
|
-
dry-logic (~> 1.0, >= 1.0.2)
|
|
51
|
-
ethon (0.15.0)
|
|
41
|
+
dry-core (~> 1.0, < 2)
|
|
42
|
+
dry-inflector (~> 1.0, < 2)
|
|
43
|
+
dry-logic (>= 1.4, < 2)
|
|
44
|
+
zeitwerk (~> 2.6)
|
|
45
|
+
ethon (0.16.0)
|
|
52
46
|
ffi (>= 1.15.0)
|
|
53
|
-
faker (
|
|
54
|
-
i18n (>= 1.
|
|
55
|
-
ffi (1.
|
|
47
|
+
faker (3.0.0)
|
|
48
|
+
i18n (>= 1.8.11, < 2)
|
|
49
|
+
ffi (1.16.3)
|
|
56
50
|
grape (1.6.2)
|
|
57
51
|
activesupport
|
|
58
52
|
builder
|
|
@@ -61,53 +55,54 @@ GEM
|
|
|
61
55
|
rack (>= 1.3.0)
|
|
62
56
|
rack-accept
|
|
63
57
|
hashdiff (1.0.1)
|
|
64
|
-
i18n (1.
|
|
58
|
+
i18n (1.12.0)
|
|
65
59
|
concurrent-ruby (~> 1.0)
|
|
60
|
+
json (2.6.2)
|
|
66
61
|
method_source (1.0.0)
|
|
67
|
-
minitest (5.
|
|
68
|
-
mustermann (
|
|
62
|
+
minitest (5.16.3)
|
|
63
|
+
mustermann (3.0.0)
|
|
69
64
|
ruby2_keywords (~> 0.0.1)
|
|
70
|
-
mustermann-grape (1.0.
|
|
65
|
+
mustermann-grape (1.0.2)
|
|
71
66
|
mustermann (>= 1.0.0)
|
|
72
|
-
oj (3.
|
|
73
|
-
parallel (1.
|
|
74
|
-
parser (3.1.
|
|
67
|
+
oj (3.16.1)
|
|
68
|
+
parallel (1.22.1)
|
|
69
|
+
parser (3.1.3.0)
|
|
75
70
|
ast (~> 2.4.1)
|
|
76
71
|
pry (0.14.1)
|
|
77
72
|
coderay (~> 1.1)
|
|
78
73
|
method_source (~> 1.0)
|
|
79
|
-
public_suffix (
|
|
80
|
-
rack (
|
|
74
|
+
public_suffix (5.0.0)
|
|
75
|
+
rack (3.0.1)
|
|
81
76
|
rack-accept (0.4.5)
|
|
82
77
|
rack (>= 0.4)
|
|
83
78
|
rainbow (3.1.1)
|
|
84
|
-
|
|
85
|
-
regexp_parser (2.2.1)
|
|
79
|
+
regexp_parser (2.6.1)
|
|
86
80
|
rexml (3.2.5)
|
|
87
|
-
rspec (3.
|
|
88
|
-
rspec-core (~> 3.
|
|
89
|
-
rspec-expectations (~> 3.
|
|
90
|
-
rspec-mocks (~> 3.
|
|
91
|
-
rspec-core (3.
|
|
92
|
-
rspec-support (~> 3.
|
|
93
|
-
rspec-expectations (3.
|
|
81
|
+
rspec (3.12.0)
|
|
82
|
+
rspec-core (~> 3.12.0)
|
|
83
|
+
rspec-expectations (~> 3.12.0)
|
|
84
|
+
rspec-mocks (~> 3.12.0)
|
|
85
|
+
rspec-core (3.12.0)
|
|
86
|
+
rspec-support (~> 3.12.0)
|
|
87
|
+
rspec-expectations (3.12.0)
|
|
94
88
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
95
|
-
rspec-support (~> 3.
|
|
96
|
-
rspec-mocks (3.
|
|
89
|
+
rspec-support (~> 3.12.0)
|
|
90
|
+
rspec-mocks (3.12.0)
|
|
97
91
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
98
|
-
rspec-support (~> 3.
|
|
99
|
-
rspec-support (3.
|
|
100
|
-
rubocop (1.
|
|
92
|
+
rspec-support (~> 3.12.0)
|
|
93
|
+
rspec-support (3.12.0)
|
|
94
|
+
rubocop (1.39.0)
|
|
95
|
+
json (~> 2.3)
|
|
101
96
|
parallel (~> 1.10)
|
|
102
|
-
parser (>= 3.1.
|
|
97
|
+
parser (>= 3.1.2.1)
|
|
103
98
|
rainbow (>= 2.2.2, < 4.0)
|
|
104
99
|
regexp_parser (>= 1.8, < 3.0)
|
|
105
|
-
rexml
|
|
106
|
-
rubocop-ast (>= 1.
|
|
100
|
+
rexml (>= 3.2.5, < 4.0)
|
|
101
|
+
rubocop-ast (>= 1.23.0, < 2.0)
|
|
107
102
|
ruby-progressbar (~> 1.7)
|
|
108
103
|
unicode-display_width (>= 1.4.0, < 3.0)
|
|
109
|
-
rubocop-ast (1.
|
|
110
|
-
parser (>= 3.
|
|
104
|
+
rubocop-ast (1.23.0)
|
|
105
|
+
parser (>= 3.1.1.0)
|
|
111
106
|
ruby-progressbar (1.11.0)
|
|
112
107
|
ruby2_keywords (0.0.5)
|
|
113
108
|
simplecov (0.21.2)
|
|
@@ -118,14 +113,14 @@ GEM
|
|
|
118
113
|
simplecov_json_formatter (0.1.4)
|
|
119
114
|
typhoeus (1.4.0)
|
|
120
115
|
ethon (>= 0.9.0)
|
|
121
|
-
tzinfo (2.0.
|
|
116
|
+
tzinfo (2.0.5)
|
|
122
117
|
concurrent-ruby (~> 1.0)
|
|
123
|
-
unicode-display_width (2.
|
|
124
|
-
webmock (3.
|
|
118
|
+
unicode-display_width (2.3.0)
|
|
119
|
+
webmock (3.18.1)
|
|
125
120
|
addressable (>= 2.8.0)
|
|
126
121
|
crack (>= 0.3.2)
|
|
127
122
|
hashdiff (>= 0.4.0, < 2.0.0)
|
|
128
|
-
zeitwerk (2.
|
|
123
|
+
zeitwerk (2.6.6)
|
|
129
124
|
|
|
130
125
|
PLATFORMS
|
|
131
126
|
ruby
|
|
@@ -133,17 +128,15 @@ PLATFORMS
|
|
|
133
128
|
|
|
134
129
|
DEPENDENCIES
|
|
135
130
|
activemodel
|
|
136
|
-
activesupport (= 6.1.4.4)
|
|
137
131
|
bundler
|
|
138
132
|
codecov
|
|
139
133
|
faker
|
|
140
134
|
grape
|
|
141
135
|
hcloud!
|
|
142
136
|
pry
|
|
143
|
-
rake
|
|
144
137
|
rspec
|
|
145
138
|
rubocop
|
|
146
139
|
webmock
|
|
147
140
|
|
|
148
141
|
BUNDLED WITH
|
|
149
|
-
2.3.
|
|
142
|
+
2.3.25
|
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
|
-
[](https://github.com/tonobo/hcloud-ruby/actions/workflows/ruby.yml)
|
|
4
4
|
[](https://codecov.io/gh/tonobo/hcloud-ruby)
|
|
5
5
|
[](https://badge.fury.io/rb/hcloud)
|
|
6
6
|
[](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
|
-
|
|
12
|
-
|
|
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,11 @@ 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
|
-
spec.add_development_dependency 'rake'
|
|
30
29
|
spec.add_development_dependency 'rspec'
|
|
31
30
|
spec.add_development_dependency 'webmock'
|
|
32
31
|
spec.add_runtime_dependency 'activemodel'
|
|
33
|
-
spec.add_runtime_dependency 'activesupport', '6.1.4.4'
|
|
34
32
|
spec.add_runtime_dependency 'oj'
|
|
35
33
|
spec.add_runtime_dependency 'typhoeus'
|
|
36
34
|
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Hcloud
|
|
4
|
+
class Certificate
|
|
5
|
+
require 'hcloud/certificate_resource'
|
|
6
|
+
|
|
7
|
+
include EntryLoader
|
|
8
|
+
|
|
9
|
+
schema(
|
|
10
|
+
created: :time
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
updatable :name
|
|
14
|
+
destructible
|
|
15
|
+
|
|
16
|
+
has_actions
|
|
17
|
+
|
|
18
|
+
def retry
|
|
19
|
+
prepare_request('actions/retry', j: COLLECT_ARGS.call(__method__, binding))
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Hcloud
|
|
4
|
+
class CertificateResource < AbstractResource
|
|
5
|
+
filter_attributes :name, :label_selector, :type
|
|
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(
|
|
15
|
+
name:,
|
|
16
|
+
type: :uploaded,
|
|
17
|
+
certificate: nil,
|
|
18
|
+
private_key: nil,
|
|
19
|
+
domain_names: nil,
|
|
20
|
+
labels: {}
|
|
21
|
+
)
|
|
22
|
+
raise Hcloud::Error::InvalidInput, 'no name given' if name.blank?
|
|
23
|
+
|
|
24
|
+
case type
|
|
25
|
+
when :uploaded
|
|
26
|
+
raise Hcloud::Error::InvalidInput, 'no certificate given' if certificate.blank?
|
|
27
|
+
raise Hcloud::Error::InvalidInput, 'no private_key given' if private_key.blank?
|
|
28
|
+
when :managed
|
|
29
|
+
raise Hcloud::Error::InvalidInput, 'no domain_names given' if domain_names.to_a.empty?
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
prepare_request(
|
|
33
|
+
'certificates', j: COLLECT_ARGS.call(__method__, binding),
|
|
34
|
+
expected_code: 201
|
|
35
|
+
) do |response|
|
|
36
|
+
[
|
|
37
|
+
Action.new(client, response.parsed_json[:action]),
|
|
38
|
+
Certificate.new(client, response.parsed_json[:certificate])
|
|
39
|
+
]
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
data/lib/hcloud/client.rb
CHANGED
|
@@ -86,18 +86,42 @@ module Hcloud
|
|
|
86
86
|
SSHKeyResource.new(client: self)
|
|
87
87
|
end
|
|
88
88
|
|
|
89
|
+
def certificates
|
|
90
|
+
CertificateResource.new(client: self)
|
|
91
|
+
end
|
|
92
|
+
|
|
89
93
|
def floating_ips
|
|
90
94
|
FloatingIPResource.new(client: self)
|
|
91
95
|
end
|
|
92
96
|
|
|
97
|
+
def primary_ips
|
|
98
|
+
PrimaryIPResource.new(client: self)
|
|
99
|
+
end
|
|
100
|
+
|
|
93
101
|
def networks
|
|
94
102
|
NetworkResource.new(client: self)
|
|
95
103
|
end
|
|
96
104
|
|
|
105
|
+
def firewalls
|
|
106
|
+
FirewallResource.new(client: self)
|
|
107
|
+
end
|
|
108
|
+
|
|
97
109
|
def volumes
|
|
98
110
|
VolumeResource.new(client: self)
|
|
99
111
|
end
|
|
100
112
|
|
|
113
|
+
def placement_groups
|
|
114
|
+
PlacementGroupResource.new(client: self)
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
def load_balancer_types
|
|
118
|
+
LoadBalancerTypeResource.new(client: self)
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def load_balancers
|
|
122
|
+
LoadBalancerResource.new(client: self)
|
|
123
|
+
end
|
|
124
|
+
|
|
101
125
|
class ResourceFuture < Delegator
|
|
102
126
|
def initialize(request) # rubocop:disable Lint/MissingSuper
|
|
103
127
|
@request = request
|
data/lib/hcloud/entry_loader.rb
CHANGED
|
@@ -68,40 +68,84 @@ module Hcloud
|
|
|
68
68
|
end
|
|
69
69
|
end
|
|
70
70
|
|
|
71
|
+
def has_metrics # rubocop:disable Naming/PredicateName
|
|
72
|
+
define_method(:metrics) do |**kwargs|
|
|
73
|
+
raise Hcloud::Error::InvalidInput, 'no type given' if kwargs[:type].blank?
|
|
74
|
+
raise Hcloud::Error::InvalidInput, 'no start given' if kwargs[:start].blank?
|
|
75
|
+
raise Hcloud::Error::InvalidInput, 'no end given' if kwargs[:end].blank?
|
|
76
|
+
if kwargs[:start] > kwargs[:end]
|
|
77
|
+
raise Hcloud::Error::InvalidInput, 'start time must be before end time'
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
params = {
|
|
81
|
+
type: kwargs[:type],
|
|
82
|
+
start: kwargs[:start].iso8601,
|
|
83
|
+
end: kwargs[:end].iso8601,
|
|
84
|
+
step: kwargs[:step].to_i
|
|
85
|
+
}
|
|
86
|
+
prepare_request('metrics', method: :get, params: params) do |response|
|
|
87
|
+
response.parsed_json[:metrics].with_indifferent_access
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
71
92
|
def resource_class
|
|
72
93
|
ancestors.reverse.find { |const| const.include?(Hcloud::EntryLoader) }
|
|
73
94
|
end
|
|
74
95
|
|
|
75
96
|
def from_response(response, autoload_action: nil)
|
|
76
97
|
attributes = response.resource_attributes
|
|
77
|
-
|
|
98
|
+
|
|
99
|
+
action_resp = _try_load_action(response) if autoload_action
|
|
100
|
+
return action_resp unless attributes || action_resp.nil?
|
|
101
|
+
|
|
78
102
|
client = response.context.client
|
|
79
103
|
if attributes.is_a?(Array)
|
|
80
|
-
results = attributes.map
|
|
104
|
+
results = attributes.map do |item|
|
|
105
|
+
new(client, item).tap do |entity|
|
|
106
|
+
entity.response = response
|
|
107
|
+
end
|
|
108
|
+
end
|
|
81
109
|
results.tap { |ary| ary.extend(Collection) }.response = response
|
|
82
110
|
return results
|
|
83
111
|
end
|
|
84
112
|
|
|
85
|
-
|
|
86
|
-
|
|
113
|
+
if action_resp.nil?
|
|
114
|
+
return new(client, attributes).tap { |entity| entity.response = response }
|
|
115
|
+
end
|
|
87
116
|
|
|
88
117
|
[
|
|
89
|
-
|
|
90
|
-
new(attributes).tap { |entity| entity.response = response }
|
|
118
|
+
action_resp,
|
|
119
|
+
new(client, attributes).tap { |entity| entity.response = response }
|
|
91
120
|
]
|
|
92
121
|
end
|
|
93
|
-
end
|
|
94
122
|
|
|
95
|
-
|
|
123
|
+
def _try_load_action(response)
|
|
124
|
+
# some API endpoints return a list of actions (e.g. firewall action
|
|
125
|
+
# apply_to_resources), some a single action (e.g. server action
|
|
126
|
+
# attach_iso)
|
|
127
|
+
actions = response.parsed_json[:actions]
|
|
128
|
+
action = response.parsed_json[:action]
|
|
129
|
+
|
|
130
|
+
client = response.context.client
|
|
96
131
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
132
|
+
if actions
|
|
133
|
+
return actions.map do |act|
|
|
134
|
+
Action.new(client, act)
|
|
135
|
+
end
|
|
136
|
+
elsif action
|
|
137
|
+
return Action.new(client, action)
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
nil
|
|
101
141
|
end
|
|
142
|
+
end
|
|
102
143
|
|
|
144
|
+
attr_accessor :response
|
|
145
|
+
|
|
146
|
+
def initialize(client = nil, resource = {})
|
|
103
147
|
@client = client
|
|
104
|
-
_load(
|
|
148
|
+
_load(resource)
|
|
105
149
|
end
|
|
106
150
|
|
|
107
151
|
def inspect
|
|
@@ -179,7 +223,10 @@ module Hcloud
|
|
|
179
223
|
instance_variable_set("@#{key}", value)
|
|
180
224
|
end
|
|
181
225
|
|
|
226
|
+
# rubocop: disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/MethodLength, Metrics/AbcSize
|
|
182
227
|
def _load(resource)
|
|
228
|
+
return if resource.nil?
|
|
229
|
+
|
|
183
230
|
@_attributes = {}.with_indifferent_access
|
|
184
231
|
|
|
185
232
|
resource.each do |key, value|
|
|
@@ -195,8 +242,30 @@ module Hcloud
|
|
|
195
242
|
next
|
|
196
243
|
end
|
|
197
244
|
|
|
245
|
+
# if schema definition is [Class]
|
|
246
|
+
if definition.is_a?(Array) && definition.first.include?(EntryLoader)
|
|
247
|
+
|
|
248
|
+
# just set attribute to an empty array if value is no array or empty
|
|
249
|
+
if !value.is_a?(Array) || value.empty?
|
|
250
|
+
_update_attribute(key, [])
|
|
251
|
+
next
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
if value.first.is_a?(Integer)
|
|
255
|
+
# If value is an integer, this is the id of an object which's class can be
|
|
256
|
+
# retreived from definition. Load a future object that can on access retreive the
|
|
257
|
+
# data from the api and convert it to a proper object.
|
|
258
|
+
_update_attribute(key, value.map { |id| Future.new(client, definition.first, id) })
|
|
259
|
+
else
|
|
260
|
+
# Otherwise the value *is* the content of the object
|
|
261
|
+
_update_attribute(key, value.map { |item| definition.first.new(client, item) })
|
|
262
|
+
end
|
|
263
|
+
next
|
|
264
|
+
end
|
|
265
|
+
|
|
198
266
|
_update_attribute(key, value.is_a?(Hash) ? value.with_indifferent_access : value)
|
|
199
267
|
end
|
|
200
268
|
end
|
|
269
|
+
# rubocop: enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/MethodLength, Metrics/AbcSize
|
|
201
270
|
end
|
|
202
271
|
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
|
|
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,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Hcloud
|
|
4
|
+
class Firewall
|
|
5
|
+
require 'hcloud/firewall_resource'
|
|
6
|
+
|
|
7
|
+
include EntryLoader
|
|
8
|
+
|
|
9
|
+
schema(
|
|
10
|
+
created: :time
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
updatable :name
|
|
14
|
+
destructible
|
|
15
|
+
|
|
16
|
+
has_actions
|
|
17
|
+
|
|
18
|
+
def set_rules(rules:)
|
|
19
|
+
# Set rules to empty when nil is passed
|
|
20
|
+
rules = rules.to_a
|
|
21
|
+
|
|
22
|
+
prepare_request('actions/set_rules', j: COLLECT_ARGS.call(__method__, binding))
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def apply_to_resources(apply_to:)
|
|
26
|
+
raise Hcloud::Error::InvalidInput, 'no apply_to resources given' if apply_to.nil?
|
|
27
|
+
|
|
28
|
+
prepare_request('actions/apply_to_resources', j: COLLECT_ARGS.call(__method__, binding))
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def remove_from_resources(remove_from:)
|
|
32
|
+
raise Hcloud::Error::InvalidInput, 'no remove_from resources given' if remove_from.nil?
|
|
33
|
+
|
|
34
|
+
prepare_request('actions/remove_from_resources', j: COLLECT_ARGS.call(__method__, binding))
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|