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
data/lib/hcloud/errors.rb
CHANGED
@@ -12,7 +12,7 @@ module HCloud
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def full_messages
|
15
|
-
return unless data[:details]
|
15
|
+
return unless data[:details] && data[:details][:fields]
|
16
16
|
|
17
17
|
data[:details][:fields].flat_map do |field|
|
18
18
|
Array(field.fetch(:messages, data[:message])).map do |detail|
|
@@ -36,6 +36,7 @@ module HCloud
|
|
36
36
|
class InvalidInput < Error; end
|
37
37
|
class JSONError < Error; end
|
38
38
|
class LoadBalancerNotAttachedToNetwork < Error; end
|
39
|
+
class LoadBalancerPublicInterfaceDisabled < Error; end
|
39
40
|
class Locked < Error; end
|
40
41
|
class Maintenance < Error; end
|
41
42
|
class NetworksOverlap < Error; end
|
data/lib/hcloud/resource.rb
CHANGED
data/lib/hcloud/resource_type.rb
CHANGED
@@ -137,6 +137,16 @@ ActiveModel::Type.register(:server_type_price, HCloud::ResourceType.Type("HCloud
|
|
137
137
|
ActiveModel::Type.register(:service, HCloud::ResourceType.Type("HCloud::Service"))
|
138
138
|
ActiveModel::Type.register(:service_http, HCloud::ResourceType.Type("HCloud::ServiceHTTP"))
|
139
139
|
ActiveModel::Type.register(:ssh_key, HCloud::ResourceType.Type("HCloud::SSHKey"))
|
140
|
+
ActiveModel::Type.register(:storage_box, HCloud::ResourceType.Type("HCloud::StorageBox"))
|
141
|
+
ActiveModel::Type.register(:storage_box_access_settings, HCloud::ResourceType.Type("HCloud::StorageBoxAccessSettings"))
|
142
|
+
ActiveModel::Type.register(:storage_box_price, HCloud::ResourceType.Type("HCloud::StorageBoxPrice"))
|
143
|
+
ActiveModel::Type.register(:storage_box_snapshot_plan, HCloud::ResourceType.Type("HCloud::StorageBoxSnapshotPlan"))
|
144
|
+
ActiveModel::Type.register(:storage_box_stats, HCloud::ResourceType.Type("HCloud::StorageBoxStats"))
|
145
|
+
ActiveModel::Type.register(:storage_box_type, HCloud::ResourceType.Type("HCloud::StorageBoxType"))
|
146
|
+
ActiveModel::Type.register(:storage_box_snapshot, HCloud::ResourceType.Type("HCloud::StorageBoxSnapshot"))
|
147
|
+
ActiveModel::Type.register(:storage_box_snapshot_stats, HCloud::ResourceType.Type("HCloud::StorageBoxSnapshotStats"))
|
148
|
+
ActiveModel::Type.register(:storage_box_subaccount, HCloud::ResourceType.Type("HCloud::StorageBoxSubaccount"))
|
149
|
+
ActiveModel::Type.register(:storage_box_subaccount_access_settings, HCloud::ResourceType.Type("HCloud::StorageBoxSubaccountAccessSettings"))
|
140
150
|
ActiveModel::Type.register(:subnet, HCloud::ResourceType.Type("HCloud::Subnet"))
|
141
151
|
ActiveModel::Type.register(:target, HCloud::ResourceType.Type("HCloud::Target"))
|
142
152
|
ActiveModel::Type.register(:targets, HCloud::ResourceType.Type("HCloud::Targets"))
|
@@ -25,7 +25,7 @@ module HCloud
|
|
25
25
|
# HCloud::Certificate.where(type: "uploaded")
|
26
26
|
# # => #<HCloud::Certificate id: 1, ...>
|
27
27
|
#
|
28
|
-
# HCloud::Certificate.where(label_selector:
|
28
|
+
# HCloud::Certificate.where(label_selector: "environment=production")
|
29
29
|
# # => #<HCloud::Certificate id: 1, ...>
|
30
30
|
#
|
31
31
|
# == Find certificate by ID
|
@@ -22,7 +22,7 @@ module HCloud
|
|
22
22
|
# HCloud::Firewall.where(name: "my_firewall")
|
23
23
|
# # => #<HCloud::Firewall id: 1, ...>
|
24
24
|
#
|
25
|
-
# HCloud::Firewall.where(label_selector:
|
25
|
+
# HCloud::Firewall.where(label_selector: "environment=production")
|
26
26
|
# # => #<HCloud::Firewall id: 1, ...>
|
27
27
|
#
|
28
28
|
# == Find firewall by ID
|
@@ -22,7 +22,7 @@ module HCloud
|
|
22
22
|
# HCloud::FloatingIP.where(name: "my_floating_ip")
|
23
23
|
# # => #<HCloud::FloatingIP id: 1, ...>
|
24
24
|
#
|
25
|
-
# HCloud::FloatingIP.where(label_selector:
|
25
|
+
# HCloud::FloatingIP.where(label_selector: "environment=production")
|
26
26
|
# # => #<HCloud::FloatingIP id: 1, ...>
|
27
27
|
#
|
28
28
|
# == Find floating IP by ID
|
@@ -22,7 +22,7 @@ module HCloud
|
|
22
22
|
# HCloud::LoadBalancer.where(name: "my_load_balancer")
|
23
23
|
# # => #<HCloud::LoadBalancer id: 1, ...>
|
24
24
|
#
|
25
|
-
# HCloud::LoadBalancer.where(label_selector:
|
25
|
+
# HCloud::LoadBalancer.where(label_selector: "environment=production")
|
26
26
|
# # => #<HCloud::LoadBalancer id: 1, ...>
|
27
27
|
#
|
28
28
|
# == Find load balancer by ID
|
@@ -14,7 +14,7 @@ module HCloud
|
|
14
14
|
# HCloud::Network.where(name: "my_network")
|
15
15
|
# # => #<HCloud::Network id: 1, ...>
|
16
16
|
#
|
17
|
-
# HCloud::Network.where(label_selector:
|
17
|
+
# HCloud::Network.where(label_selector: "environment=production")
|
18
18
|
# # => #<HCloud::Network id: 1, ...>
|
19
19
|
#
|
20
20
|
# == Find network by ID
|
@@ -22,7 +22,7 @@ module HCloud
|
|
22
22
|
# HCloud::PlacementGroup.where(name: "my_placement_group")
|
23
23
|
# # => #<HCloud::PlacementGroup id: 2, ...>
|
24
24
|
#
|
25
|
-
# HCloud::PlacementGroup.where(label_selector:
|
25
|
+
# HCloud::PlacementGroup.where(label_selector: "environment=production")
|
26
26
|
# # => #<HCloud::PlacementGroup id: 2, ...>
|
27
27
|
#
|
28
28
|
# == Find placement group by ID
|
@@ -25,7 +25,7 @@ module HCloud
|
|
25
25
|
# HCloud::PrimaryIP.where(ip: "1.2.3.4")
|
26
26
|
# # => #<HCloud::PrimaryIP id: 1, ...>
|
27
27
|
#
|
28
|
-
# HCloud::PrimaryIP.where(label_selector:
|
28
|
+
# HCloud::PrimaryIP.where(label_selector: "environment=production")
|
29
29
|
# # => #<HCloud::PrimaryIP id: 1, ...>
|
30
30
|
#
|
31
31
|
# == Find primary IP by ID
|
@@ -25,7 +25,7 @@ module HCloud
|
|
25
25
|
# HCloud::Server.where(status: "running")
|
26
26
|
# # => #<HCloud::Server id: 1, ...>
|
27
27
|
#
|
28
|
-
# HCloud::Server.where(label_selector:
|
28
|
+
# HCloud::Server.where(label_selector: "environment=production")
|
29
29
|
# # => #<HCloud::Server id: 1, ...>
|
30
30
|
#
|
31
31
|
# == Find server by ID
|
@@ -31,10 +31,6 @@ module HCloud
|
|
31
31
|
attribute :disk, :integer
|
32
32
|
attribute :memory, :integer
|
33
33
|
|
34
|
-
# FIXME: Attribute will return null on 2024-08-05
|
35
|
-
# FIXME: Attribute will be removed on 2024-11-05
|
36
|
-
attribute :included_traffic, :integer, deprecated: true
|
37
|
-
|
38
34
|
attribute :cpu_type
|
39
35
|
attribute :storage_type
|
40
36
|
|
@@ -25,7 +25,7 @@ module HCloud
|
|
25
25
|
# HCloud::SSHKey.where(fingerprint: "B6:6C:CD:DA:A2:24:43:39:98:80:0F:F5:51:17:7E")
|
26
26
|
# # => #<HCloud::SSHKey id: 1, ...>
|
27
27
|
#
|
28
|
-
# HCloud::SSHKey.where(label_selector:
|
28
|
+
# HCloud::SSHKey.where(label_selector: "environment=production")
|
29
29
|
# # => #<HCloud::SSHKey id: 1, ...>
|
30
30
|
#
|
31
31
|
# == Find SSH key by ID
|
@@ -0,0 +1,191 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module HCloud
|
4
|
+
##
|
5
|
+
# Represents a storage box
|
6
|
+
#
|
7
|
+
# == List all storage boxes
|
8
|
+
#
|
9
|
+
# HCloud::StorageBox.all
|
10
|
+
# # => [#<HCloud::StorageBox id: 1, ...>, ...]
|
11
|
+
#
|
12
|
+
# == Search storage boxes
|
13
|
+
#
|
14
|
+
# HCloud::StorageBox.where(name: "my_storage_box")
|
15
|
+
# # => #<HCloud::StorageBox id: 1, ...>
|
16
|
+
#
|
17
|
+
# HCloud::StorageBox.where(label_selector: "environment=production")
|
18
|
+
# # => #<HCloud::StorageBox id: 1, ...>
|
19
|
+
#
|
20
|
+
# == Find storage box by ID
|
21
|
+
#
|
22
|
+
# HCloud::StorageBox.find(1)
|
23
|
+
# # => #<HCloud::StorageBox id: 1, ...>
|
24
|
+
#
|
25
|
+
# == Create storage box
|
26
|
+
#
|
27
|
+
# storage_box = HCloud::StorageBox.new(name: "my_storage_box", storage_box_type: "bx20", location: "fsn1", password: "my_password")
|
28
|
+
# storage_box.create
|
29
|
+
# storage_box.created?
|
30
|
+
# # => true
|
31
|
+
#
|
32
|
+
# storage_box = HCloud::StorageBox.create(name: "my_storage_box", storage_box_type: "bx20", location: "fsn1", password: "my_password")
|
33
|
+
# # => #<HCloud::Action id: 1, ...>
|
34
|
+
#
|
35
|
+
# Note: this endpoint returns an Action rather than the created resource itself
|
36
|
+
#
|
37
|
+
# == Update storage box
|
38
|
+
#
|
39
|
+
# storage_box = HCloud::StorageBox.find(1)
|
40
|
+
# storage_box.name = "another_storage_box"
|
41
|
+
# storage_box.update
|
42
|
+
#
|
43
|
+
# == Delete storage box
|
44
|
+
#
|
45
|
+
# storage_box = HCloud::StorageBox.find(1)
|
46
|
+
# storage_box.delete
|
47
|
+
# storage_box.deleted?
|
48
|
+
# # => true
|
49
|
+
#
|
50
|
+
# == List storage box contents
|
51
|
+
#
|
52
|
+
# storage_box = HCloud::StorageBox.find(1)
|
53
|
+
# storage_box.contents
|
54
|
+
# # => ["photos", "documents", ...]
|
55
|
+
#
|
56
|
+
# storage_box = HCloud::StorageBox.find(1)
|
57
|
+
# storage_box.contents(folder: "photos")
|
58
|
+
# # => ["photo1.jpg", "photo2.jpg", ...]
|
59
|
+
#
|
60
|
+
# = Actions
|
61
|
+
# == List actions
|
62
|
+
#
|
63
|
+
# actions = HCloud::StorageBox.find(1).actions
|
64
|
+
# # => [#<HCloud::Action id: 1, ...>, ...]
|
65
|
+
#
|
66
|
+
# == Sort actions
|
67
|
+
#
|
68
|
+
# HCloud::StorageBox.find(1).actions.sort(finished: :desc)
|
69
|
+
# # => [#<HCloud::Action id: 1, ...>, ...]
|
70
|
+
#
|
71
|
+
# HCloud::StorageBox.find(1).actions.sort(:command, finished: :asc)
|
72
|
+
# # => [#<HCloud::Actions id: 1, ...>, ...]
|
73
|
+
#
|
74
|
+
# == Search actions
|
75
|
+
#
|
76
|
+
# HCloud::StorageBox.find(1).actions.where(command: "start_resource")
|
77
|
+
# # => #<HCloud::Action id: 1, ...>
|
78
|
+
#
|
79
|
+
# HCloud::StorageBox.find(1).actions.where(status: "success")
|
80
|
+
# # => #<HCloud::Action id: 1, ...>
|
81
|
+
#
|
82
|
+
# == Find action by ID
|
83
|
+
#
|
84
|
+
# HCloud::StorageBox.find(1).actions.find(1)
|
85
|
+
# # => #<HCloud::Action id: 1, ...>
|
86
|
+
#
|
87
|
+
# = Resource-specific actions
|
88
|
+
# == Change type
|
89
|
+
#
|
90
|
+
# HCloud::StorageBox.find(1).change_type(storage_box_type: "bx21")
|
91
|
+
# # => #<HCloud::Action id: 1, ...>
|
92
|
+
#
|
93
|
+
# == Reset password
|
94
|
+
#
|
95
|
+
# HCloud::StorageBox.find(1).reset_password(password: "mypassword")
|
96
|
+
# # => #<HCloud::Action id: 1, ...>
|
97
|
+
#
|
98
|
+
# == Update access settings
|
99
|
+
#
|
100
|
+
# HCloud::StorageBox.find(1).update_access_settings(samba_enabled: false, ssh_enabled: true, webdav_enabled: false, zfs_enabled: false, reachable_externally: false)
|
101
|
+
# # => #<HCloud::Action id: 1, ...>
|
102
|
+
#
|
103
|
+
# == Enable snapshot plan
|
104
|
+
#
|
105
|
+
# HCloud::StorageBox.find(1).enable_snapshot_plan(max_snapshots: 10, minute: 30, hour: 3, day_of_week: nil, day_of_month: nil)
|
106
|
+
# # => #<HCloud::Action id: 1, ...>
|
107
|
+
#
|
108
|
+
# == Disable snapshot plan
|
109
|
+
#
|
110
|
+
# HCloud::StorageBox.find(1).disable_snapshot_plan
|
111
|
+
# # => #<HCloud::Action id: 1, ...>
|
112
|
+
#
|
113
|
+
# == Rollback snapshot
|
114
|
+
#
|
115
|
+
# HCloud::StorageBox.find(1).rollback_snapshot(snapshot_id: 42)
|
116
|
+
# # => #<HCloud::Action id: 1, ...>
|
117
|
+
#
|
118
|
+
# == Change protection
|
119
|
+
#
|
120
|
+
# HCloud::StorageBox.find(1).change_protection(delete: true)
|
121
|
+
# # => #<HCloud::Action id: 1, ...>
|
122
|
+
#
|
123
|
+
# = Snapshots
|
124
|
+
#
|
125
|
+
# See {HCloud::StorageBoxSnapshot} for more information on snapshots.
|
126
|
+
#
|
127
|
+
# = Subaccounts
|
128
|
+
#
|
129
|
+
# See {HCloud::StorageBoxSubaccount} for more information on subaccounts.
|
130
|
+
#
|
131
|
+
class StorageBox < Resource
|
132
|
+
actionable
|
133
|
+
queryable
|
134
|
+
creatable
|
135
|
+
updatable
|
136
|
+
deletable
|
137
|
+
labelable
|
138
|
+
|
139
|
+
subresource :snapshot, :storage_box_snapshot
|
140
|
+
subresource :subaccount, :storage_box_subaccount
|
141
|
+
|
142
|
+
attribute :id, :integer
|
143
|
+
attribute :name
|
144
|
+
attribute :location, :location
|
145
|
+
|
146
|
+
attribute :username
|
147
|
+
|
148
|
+
attribute :status
|
149
|
+
|
150
|
+
attribute :storage_box_type, :storage_box_type
|
151
|
+
attribute :access_settings, :storage_box_access_settings
|
152
|
+
|
153
|
+
# String, not a Server resource
|
154
|
+
attribute :server
|
155
|
+
attribute :system
|
156
|
+
|
157
|
+
attribute :stats, :storage_box_stats
|
158
|
+
attribute :snapshot_plan, :storage_box_snapshot_plan
|
159
|
+
|
160
|
+
attribute :protection, :protection
|
161
|
+
|
162
|
+
action :change_type
|
163
|
+
action :reset_password
|
164
|
+
action :update_access_settings
|
165
|
+
|
166
|
+
action :enable_snapshot_plan
|
167
|
+
action :disable_snapshot_plan
|
168
|
+
|
169
|
+
action :rollback_snapshot
|
170
|
+
|
171
|
+
action :change_protection
|
172
|
+
|
173
|
+
def contents(path: nil)
|
174
|
+
client
|
175
|
+
.get("#{resource_path}/#{id}/folders", path: path)
|
176
|
+
.fetch(:folders)
|
177
|
+
end
|
178
|
+
|
179
|
+
def creatable_attributes
|
180
|
+
[:name, :storage_box_type, :password, :ssh_keys, :location, :labels, access_settings: [:samba_enabled, :ssh_enabled, :webdav_enabled, :zfs_enabled, :reachable_externally]]
|
181
|
+
end
|
182
|
+
|
183
|
+
def updatable_attributes
|
184
|
+
[:name, :labels]
|
185
|
+
end
|
186
|
+
|
187
|
+
def self.client
|
188
|
+
HCloud::Client.connection.storage_box_client
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module HCloud
|
4
|
+
##
|
5
|
+
# Represents a storage box's snapshot
|
6
|
+
#
|
7
|
+
# == List all snapshots
|
8
|
+
#
|
9
|
+
# storage_box = HCloud::StorageBox.find(1)
|
10
|
+
# storage_box.snapshots
|
11
|
+
# # => [#<HCloud::StorageBox::Snapshot id: 1, ...>, ...]
|
12
|
+
#
|
13
|
+
# == Search snapshots
|
14
|
+
#
|
15
|
+
# storage_box = HCloud::StorageBox.find(1)
|
16
|
+
# storage_box.snapshots.where(name: "monthly_backup")
|
17
|
+
# # => #<HCloud::StorageBox::Snapshot id: 1, ...>
|
18
|
+
#
|
19
|
+
# storage_box = HCloud::StorageBox.find(1)
|
20
|
+
# storage_box.snapshots.where(label_selector: "environment=production")
|
21
|
+
# # => #<HCloud::StorageBox::Snapshot id: 1, ...>
|
22
|
+
#
|
23
|
+
# == Find snapshot by ID
|
24
|
+
#
|
25
|
+
# storage_box = HCloud::StorageBox.find(1)
|
26
|
+
# storage_box.snapshots.find(1)
|
27
|
+
# # => #<HCloud::StorageBox::Snapshot id: 1, ...>
|
28
|
+
#
|
29
|
+
# == Create snapshot
|
30
|
+
#
|
31
|
+
# storage_box = HCloud::StorageBox.find(1)
|
32
|
+
# snapshot = storage_box.snapshots.new(description: "my_snapshot")
|
33
|
+
# snapshot.create
|
34
|
+
# snapshot.created?
|
35
|
+
# # => false
|
36
|
+
#
|
37
|
+
# Note: this endpoint returns an Action rather than the created resource itself, as the snapshot is created asynchronously.
|
38
|
+
# Reload the snapshot to check if it was created successfully.
|
39
|
+
#
|
40
|
+
# snapshot.reload
|
41
|
+
# snapshot.created?
|
42
|
+
# # => true
|
43
|
+
#
|
44
|
+
# snapshot = storage_box.snapshots.create(description: "my_snapshot")
|
45
|
+
# # => #<HCloud::Action id: 1, ...>
|
46
|
+
#
|
47
|
+
# Note: this endpoint returns an Action rather than the created resource itself
|
48
|
+
#
|
49
|
+
# snapshot = HCloud::StorageBox::Snapshot.create(storage_box: 1, description: "my_snapshot")
|
50
|
+
# # => #<HCloud::Action id: 1, ...>
|
51
|
+
#
|
52
|
+
# Note: this endpoint returns an Action rather than the created resource itself
|
53
|
+
#
|
54
|
+
# == Update snapshot
|
55
|
+
#
|
56
|
+
# storage_box = HCloud::StorageBox.find(1)
|
57
|
+
# snapshot = storage_box.snapshots.find(1)
|
58
|
+
# snapshot.description = "another_snapshot"
|
59
|
+
# snapshot.update
|
60
|
+
#
|
61
|
+
# == Delete snapshot
|
62
|
+
#
|
63
|
+
# storage_box = HCloud::StorageBox.find(1)
|
64
|
+
# snapshot = storage_box.snapshots.find(1)
|
65
|
+
# snapshot.delete
|
66
|
+
# snapshot.deleted?
|
67
|
+
# # => true
|
68
|
+
#
|
69
|
+
class StorageBoxSnapshot < Resource
|
70
|
+
subresource_of :storage_box
|
71
|
+
|
72
|
+
queryable
|
73
|
+
creatable
|
74
|
+
updatable
|
75
|
+
deletable
|
76
|
+
labelable
|
77
|
+
|
78
|
+
attribute :id, :integer
|
79
|
+
attribute :name
|
80
|
+
attribute :description
|
81
|
+
|
82
|
+
attribute :is_automatic, :boolean
|
83
|
+
|
84
|
+
attribute :stats, :storage_box_snapshot_stats
|
85
|
+
|
86
|
+
attribute :protection, :protection
|
87
|
+
|
88
|
+
def creatable_attributes
|
89
|
+
[:description]
|
90
|
+
end
|
91
|
+
|
92
|
+
def updatable_attributes
|
93
|
+
[:description, :labels]
|
94
|
+
end
|
95
|
+
|
96
|
+
def self.resource_name
|
97
|
+
"snapshot"
|
98
|
+
end
|
99
|
+
|
100
|
+
def self.client
|
101
|
+
HCloud::Client.connection.storage_box_client
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,125 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module HCloud
|
4
|
+
##
|
5
|
+
# Represents a storage box's subaccount
|
6
|
+
#
|
7
|
+
# == List all subaccounts
|
8
|
+
#
|
9
|
+
# storage_box = HCloud::StorageBox.find(1)
|
10
|
+
# storage_box.subaccounts
|
11
|
+
# # => [#<HCloud::StorageBox::Subaccount id: 1, ...>, ...]
|
12
|
+
#
|
13
|
+
# == Search subaccounts
|
14
|
+
#
|
15
|
+
# storage_box = HCloud::StorageBox.find(1)
|
16
|
+
# storage_box.subaccounts.where(label_selector: "environment=production")
|
17
|
+
# # => #<HCloud::StorageBox::Subaccount id: 1, ...>
|
18
|
+
#
|
19
|
+
# == Find subaccount by ID
|
20
|
+
#
|
21
|
+
# storage_box = HCloud::StorageBox.find(1)
|
22
|
+
# storage_box.subaccounts.find(1)
|
23
|
+
# # => #<HCloud::StorageBox::Subaccount id: 1, ...>
|
24
|
+
#
|
25
|
+
# == Create subaccount
|
26
|
+
#
|
27
|
+
# storage_box = HCloud::StorageBox.find(1)
|
28
|
+
# subaccount = storage_box.subaccounts.new(password: "my_password", description: "my_subaccount", home_directory: "backup/", access_settings: { samba_enabled: false, ssh_enabled: true, webdav_enabled: false, readonly: false, reachable_externally: false })
|
29
|
+
# subaccount.create
|
30
|
+
# subaccount.created?
|
31
|
+
# # => false
|
32
|
+
#
|
33
|
+
# Note: this endpoint returns an Action rather than the created resource itself, as the subaccount is created asynchronously.
|
34
|
+
# Reload the subaccount to check if it was created successfully.
|
35
|
+
#
|
36
|
+
# subaccount.reload
|
37
|
+
# subaccount.created?
|
38
|
+
# # => true
|
39
|
+
#
|
40
|
+
# subaccount = storage_box.subaccounts.create(password: "my_password", description: "my_subaccount", home_directory: "backup/", access_settings: { samba_enabled: false, ssh_enabled: true, webdav_enabled: false, readonly: false, reachable_externally: false })
|
41
|
+
# # => #<HCloud::Action id: 1, ...>
|
42
|
+
#
|
43
|
+
# Note: this endpoint returns an Action rather than the created resource itself
|
44
|
+
#
|
45
|
+
# subaccount = HCloud::StorageBox::Subaccount.create(storage_box: 1, password: "my_password", description: "my_subaccount", home_directory: "backup/", access_settings: { samba_enabled: false, ssh_enabled: true, webdav_enabled: false, readonly: false, reachable_externally: false })
|
46
|
+
# # => #<HCloud::Action id: 1, ...>
|
47
|
+
#
|
48
|
+
# Note: this endpoint returns an Action rather than the created resource itself
|
49
|
+
#
|
50
|
+
# == Update subaccount
|
51
|
+
#
|
52
|
+
# storage_box = HCloud::StorageBox.find(1)
|
53
|
+
# subaccount = storage_box.subaccounts.find(1)
|
54
|
+
# subaccount.description = "another_subaccount"
|
55
|
+
# subaccount.update
|
56
|
+
#
|
57
|
+
# == Delete subaccount
|
58
|
+
#
|
59
|
+
# storage_box = HCloud::StorageBox.find(1)
|
60
|
+
# subaccount = storage_box.subaccounts.find(1)
|
61
|
+
# subaccount.delete
|
62
|
+
# subaccount.deleted?
|
63
|
+
# # => true
|
64
|
+
#
|
65
|
+
# = Resource-specific actions
|
66
|
+
# == Reset password
|
67
|
+
#
|
68
|
+
# storage_box = HCloud::StorageBox.find(1)
|
69
|
+
# subaccount = storage_box.subaccounts.find(1)
|
70
|
+
# subaccount.reset_subaccount_password(password: "mypassword")
|
71
|
+
# # => #<HCloud::Action id: 1, ...>
|
72
|
+
#
|
73
|
+
# == Update access settings
|
74
|
+
#
|
75
|
+
# storage_box = HCloud::StorageBox.find(1)
|
76
|
+
# subaccount = storage_box.subaccounts.find(1)
|
77
|
+
# subaccount.update_access_settings(samba_enabled: false, ssh_enabled: true, webdav_enabled: false, zfs_enabled: false, reachable_externally: false)
|
78
|
+
# # => #<HCloud::Action id: 1, ...>
|
79
|
+
#
|
80
|
+
class StorageBoxSubaccount < Resource
|
81
|
+
subresource_of :storage_box
|
82
|
+
|
83
|
+
actionable
|
84
|
+
queryable
|
85
|
+
creatable
|
86
|
+
updatable
|
87
|
+
deletable
|
88
|
+
labelable
|
89
|
+
|
90
|
+
attribute :id, :integer
|
91
|
+
attribute :username
|
92
|
+
attribute :home_directory
|
93
|
+
attribute :description
|
94
|
+
attribute :comment
|
95
|
+
|
96
|
+
# String, not a Server resource
|
97
|
+
attribute :server
|
98
|
+
|
99
|
+
attribute :access_settings, :storage_box_subaccount_access_settings
|
100
|
+
|
101
|
+
attribute :protection, :protection
|
102
|
+
|
103
|
+
# Creatable attributes
|
104
|
+
attribute :password
|
105
|
+
|
106
|
+
action :reset_subaccount_password
|
107
|
+
action :update_access_settings
|
108
|
+
|
109
|
+
def creatable_attributes
|
110
|
+
[:password, :home_directory, :description, :labels, :access_settings]
|
111
|
+
end
|
112
|
+
|
113
|
+
def updatable_attributes
|
114
|
+
[:description, :labels]
|
115
|
+
end
|
116
|
+
|
117
|
+
def self.resource_name
|
118
|
+
"subaccount"
|
119
|
+
end
|
120
|
+
|
121
|
+
def self.client
|
122
|
+
HCloud::Client.connection.storage_box_client
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module HCloud
|
4
|
+
##
|
5
|
+
# Represents a storage box type
|
6
|
+
#
|
7
|
+
# == List all storage box types
|
8
|
+
#
|
9
|
+
# HCloud::StorageBoxType.all
|
10
|
+
# # => [#<HCloud::StorageBoxType id: 1, ...>, ...]
|
11
|
+
#
|
12
|
+
# == Search storage box types
|
13
|
+
#
|
14
|
+
# HCloud::StorageBoxType.where(name: "bx11")
|
15
|
+
# # => #<HCloud::StorageBoxType id: 1, ...>
|
16
|
+
#
|
17
|
+
# == Find storage box type by ID
|
18
|
+
#
|
19
|
+
# HCloud::StorageBoxType.find(1)
|
20
|
+
# # => #<HCloud::StorageBoxType id: 1, ...>
|
21
|
+
#
|
22
|
+
class StorageBoxType < Resource
|
23
|
+
queryable
|
24
|
+
|
25
|
+
attribute :id, :integer
|
26
|
+
attribute :name
|
27
|
+
attribute :description
|
28
|
+
|
29
|
+
attribute :size, :integer
|
30
|
+
|
31
|
+
attribute :snapshot_limit, :integer
|
32
|
+
attribute :automatic_snapshot_limit, :integer
|
33
|
+
attribute :subaccounts_limit, :integer
|
34
|
+
|
35
|
+
attribute :prices, :storage_box_price, array: true, default: -> { [] }
|
36
|
+
|
37
|
+
attribute :deprecation, :deprecation
|
38
|
+
|
39
|
+
def self.client
|
40
|
+
HCloud::Client.connection.storage_box_client
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -25,7 +25,7 @@ module HCloud
|
|
25
25
|
# HCloud::Volume.where(status: "available")
|
26
26
|
# # => #<HCloud::Volume id: 1, ...>
|
27
27
|
#
|
28
|
-
# HCloud::Volume.where(label_selector:
|
28
|
+
# HCloud::Volume.where(label_selector: "environment=production")
|
29
29
|
# # => #<HCloud::Volume id: 1, ...>
|
30
30
|
#
|
31
31
|
# == Find volume by ID
|
@@ -40,7 +40,7 @@ module HCloud
|
|
40
40
|
# volume.created?
|
41
41
|
# # => true
|
42
42
|
#
|
43
|
-
#
|
43
|
+
# volume = HCloud::Volume.create(name: "my_volume", size: 10, format: "ext4", automount: false, location: "fsn1")
|
44
44
|
# # => #<HCloud::Volume id: 1, ...>
|
45
45
|
#
|
46
46
|
# == Update volume
|