hcloud 0.1.0.pre.alpha0 → 0.1.0.pre.alpha1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hcloud.rb +1 -0
- data/lib/hcloud/abstract_resource.rb +11 -2
- data/lib/hcloud/action_resource.rb +13 -0
- data/lib/hcloud/server.rb +70 -7
- data/lib/hcloud/server_resource.rb +0 -7
- data/lib/hcloud/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 864f8cc69037ab4a88ff373bc5a89fb89176dc32
|
4
|
+
data.tar.gz: e4da295f210321c4021414a50d100edda921b741
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 800337279a9b7d2c0c8a8aace03da6e2ca9b352ce33061533ab79096dd726c709b5c904d79c37754b54eb4f039f0e9728bbd4ca5ffcd3970319370445a0641a1
|
7
|
+
data.tar.gz: 4879ddfb318509306ae1bde0a588935d6086bd613c4306dec4c3f913f82ce4ec02c11b4fd8b08bd236beea7af8802994c43b7fee4f8dfe77c9cca38afc129216
|
data/lib/hcloud.rb
CHANGED
@@ -1,8 +1,17 @@
|
|
1
1
|
module Hcloud
|
2
2
|
class AbstractResource
|
3
|
-
attr_reader :client
|
4
|
-
|
3
|
+
attr_reader :client, :parent, :base_path
|
4
|
+
|
5
|
+
def initialize(client:, parent: nil, base_path: "")
|
5
6
|
@client = client
|
7
|
+
@parent = parent
|
8
|
+
@base_path = base_path
|
9
|
+
end
|
10
|
+
|
11
|
+
def each(&block)
|
12
|
+
all.each do |member|
|
13
|
+
block.call(member)
|
14
|
+
end
|
6
15
|
end
|
7
16
|
|
8
17
|
protected
|
data/lib/hcloud/server.rb
CHANGED
@@ -29,17 +29,80 @@ module Hcloud
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def destroy
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
32
|
+
action(request(base_path, method: :delete))[0]
|
33
|
+
end
|
34
|
+
|
35
|
+
def enable_rescue(type: "linux64", ssh_keys: [])
|
36
|
+
query = {}
|
37
|
+
method(:enable_rescue).parameters.inject(query) do |r,x|
|
38
|
+
(var = eval(x.last.to_s)).nil? ? r : r.merge!(x.last => var)
|
39
|
+
end
|
40
|
+
a , j = action(request(base_path("actions/enable_rescue"), j: query))
|
41
|
+
[a, j["root_password"]]
|
42
|
+
end
|
43
|
+
|
44
|
+
def reset_password
|
45
|
+
a , j = action(request(base_path("actions/reset_password"), method: :post))
|
46
|
+
[a, j["root_password"]]
|
47
|
+
end
|
48
|
+
|
49
|
+
def create_image(description: nil, type: nil)
|
50
|
+
query = {}
|
51
|
+
method(:create_image).parameters.inject(query) do |r,x|
|
52
|
+
(var = eval(x.last.to_s)).nil? ? r : r.merge!(x.last => var)
|
53
|
+
end
|
54
|
+
a , j = action(request(base_path("actions/create_image"), j: query))
|
55
|
+
[a, Image.new(j["image"], parent, client)]
|
56
|
+
end
|
57
|
+
|
58
|
+
def rebuild(image:)
|
59
|
+
a , j = action(request(base_path("actions/rebuild"), j: {image: image}))
|
60
|
+
[a, j["root_password"]]
|
61
|
+
end
|
62
|
+
|
63
|
+
def change_type(server_type:, upgrade_disk: nil)
|
64
|
+
query = {}
|
65
|
+
method(:change_type).parameters.inject(query) do |r,x|
|
66
|
+
(var = eval(x.last.to_s)).nil? ? r : r.merge!(x.last => var)
|
67
|
+
end
|
68
|
+
action(request(base_path("actions/change_type"), j: query))[0]
|
69
|
+
end
|
70
|
+
|
71
|
+
def enable_backup(backup_window:)
|
72
|
+
action(request(base_path("actions/enable_backup"),
|
73
|
+
j: {backup_window: backup_window}))[0]
|
74
|
+
end
|
75
|
+
|
76
|
+
def attach_iso(iso:)
|
77
|
+
action(request(base_path("actions/attach_iso"),
|
78
|
+
j: {iso: iso}))[0]
|
79
|
+
end
|
80
|
+
|
81
|
+
%w(
|
82
|
+
poweron poweroff shutdown reboot reset
|
83
|
+
disable_rescue disable_backup detach_iso
|
84
|
+
).each do |action|
|
85
|
+
define_method(action) do
|
86
|
+
action(request(base_path("actions/#{action}"), method: :post))[0]
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def actions
|
91
|
+
ActionResource.new(client: client, parent: self, base_path: base_path)
|
37
92
|
end
|
38
93
|
|
39
94
|
private
|
40
95
|
|
41
|
-
def
|
42
|
-
|
96
|
+
def action(request)
|
97
|
+
j = Oj.load(request.run.body)
|
98
|
+
[
|
99
|
+
Action.new(j["action"],parent,client),
|
100
|
+
j
|
101
|
+
]
|
102
|
+
end
|
103
|
+
|
104
|
+
def base_path(ext=nil)
|
105
|
+
return ["servers/#{id}",ext].compact.join("/") unless id.nil?
|
43
106
|
raise ResourcePathError, "Unable to build resource path. Id is nil."
|
44
107
|
end
|
45
108
|
|
data/lib/hcloud/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hcloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.pre.
|
4
|
+
version: 0.1.0.pre.alpha1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Foerster
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
11
|
+
date: 2018-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -97,6 +97,7 @@ files:
|
|
97
97
|
- lib/hcloud.rb
|
98
98
|
- lib/hcloud/abstract_resource.rb
|
99
99
|
- lib/hcloud/action.rb
|
100
|
+
- lib/hcloud/action_resource.rb
|
100
101
|
- lib/hcloud/client.rb
|
101
102
|
- lib/hcloud/datacenter.rb
|
102
103
|
- lib/hcloud/entry_loader.rb
|