runabove 0.0.1 → 0.0.2

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/runabove.rb +225 -10
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8bbd5d9396fc1ec9b3ba82d0ddba716d0e18df24
4
- data.tar.gz: b12e48016f7d874d675aafa0284034dbff233c1c
3
+ metadata.gz: 873504ee076fd6fe4f9c7863bb9c844411ef2327
4
+ data.tar.gz: 744f12bdf8b130cb29f46ab926bc4c83e0d01746
5
5
  SHA512:
6
- metadata.gz: f18ea93fa6a5d36fa31d8c62b128636cdd9b2a44f5dca80990006a030ce207270cd20f38b88f366af17599aca9ae3fa74267eb5d9967e87a0d3f6a1e424e840d
7
- data.tar.gz: 51cc95816057890d4d1705ae7e8d310570ca225a477ce24626ce91f27e0ea5f560fdbe940cc2d81ea6800d82052bcff68a8ccfd2a59b9185bf1a5c70a4ce23f7
6
+ metadata.gz: ad482c7d64364167f2a192211ec7e16eb30bba4d0c0b3a1c3eba55f5ef6baaad0e472ec23da5c12c4cd043e0378260b4330333c89a499dbdfafe85d2fda64432
7
+ data.tar.gz: 2c89168326397877120d6dfafb50dea987f41069ad882e48b444a7afeca7e29706865f26e635434eb0785cd87d670d04f89ea74bded1bb9f685ec9596f808ca0
data/lib/runabove.rb CHANGED
@@ -7,13 +7,33 @@ class Runabove
7
7
  require 'json'
8
8
  require 'digest/sha1'
9
9
 
10
+ attr_reader :me, :flavor, :image, :instance,
11
+ :labs, :price, :project, :region,
12
+ :ssh, :storage, :time, :token
13
+
10
14
  def initialize(appkey, secret, consumerkey = "")
11
15
  @appkey = appkey
12
16
  @secret = secret
13
17
  @consumerkey = consumerkey
14
18
  @baseurl = "https://api.runabove.com/1.0"
15
- @server_time = self.time.to_i
16
- @delta_time = @server_time - Time.now.to_i
19
+ @server_time = self.timeServer.to_i
20
+ @delta_time = @server_time - Time.now.to_i
21
+ self.loadObjects if self.class.to_s == "Runabove"
22
+ end
23
+
24
+ def loadObjects
25
+ @me = RunaboveMe.new @appkey, @secret, @consumerkey
26
+ @flavor = RunaboveFlavor.new @appkey, @secret, @consumerkey
27
+ @image = RunaboveImage.new @appkey, @secret, @consumerkey
28
+ @instance = RunaboveInstance.new @appkey, @secret, @consumerkey
29
+ @labs = RunaboveLabs.new @appkey, @secret, @consumerkey
30
+ @price = RunabovePrice.new @appkey, @secret, @consumerkey
31
+ @project = RunaboveProject.new @appkey, @secret, @consumerkey
32
+ @region = RunaboveRegion.new @appkey, @secret, @consumerkey
33
+ @ssh = RunaboveSsh.new @appkey, @secret, @consumerkey
34
+ @storage = RunaboveStorage.new @appkey, @secret, @consumerkey
35
+ @time = RunaboveTime.new @appkey, @secret, @consumerkey
36
+ @token = RunaboveToken.new @appkey, @secret, @consumerkey
17
37
  end
18
38
 
19
39
  def createConsumerKey
@@ -39,7 +59,7 @@ class Runabove
39
59
  JSON.parse(req.body)
40
60
  end
41
61
 
42
- def time
62
+ def timeServer
43
63
  uri = URI.parse("https://api.runabove.com/1.0/auth/time")
44
64
  http = Net::HTTP.new(uri.host, uri.port)
45
65
  http.use_ssl = true
@@ -51,11 +71,6 @@ class Runabove
51
71
  time = Time.now.to_i + @delta_time
52
72
  body = data.nil? ? "" : data.to_json
53
73
 
54
- puts data.inspect
55
- puts [
56
- @secret, @consumerkey, method.upcase, @baseurl + path, body, time
57
- ].join("+")
58
-
59
74
  sign = "$1$" + Digest::SHA1.hexdigest([
60
75
  @secret, @consumerkey, method.upcase, @baseurl + path, body, time
61
76
  ].join("+"))
@@ -82,6 +97,206 @@ class Runabove
82
97
  req = Net::HTTP::Delete.new(uri.path, initheader = headers)
83
98
  end
84
99
  req.body = body
85
- JSON.parse(https.request(req).body) rescue ""
100
+ JSON.parse(https.request(req).body) rescue https.request(req).body
101
+ end
102
+ end
103
+
104
+ class RunaboveMe < Runabove
105
+ def info
106
+ raw_call("get", "/me")
107
+ end
108
+
109
+ def api_applications
110
+ raw_call("get", "/me/api/application")
111
+ end
112
+
113
+ def api_application(id)
114
+ raw_call("get", "/me/api/application/#{id}")
115
+ end
116
+
117
+ def api_delete_application(id)
118
+ raw_call("delete", "/me/api/application/#{id}")
119
+ end
120
+
121
+ def api_credentials
122
+ raw_call("get", "/me/api/credential")
123
+ end
124
+
125
+ def api_credential(id)
126
+ raw_call("get", "/me/api/credential/#{id}")
127
+ end
128
+
129
+ def api_delete_credential(id)
130
+ raw_call("delete", "/me/api/credential/#{id}")
131
+ end
132
+
133
+ def api_credential_application(id)
134
+ raw_call("get", "/me/api/credential/#{id}/application")
135
+ end
136
+
137
+ def ask_validation(data = { "validationType" => "sms" })
138
+ raw_call("post", "/me/askValidation", data)
139
+ end
140
+
141
+ def balance
142
+ raw_call("get", "/me/balance")
143
+ end
144
+
145
+ def bills
146
+ raw_call("get", "/me/bill")
147
+ end
148
+
149
+ def bill(id)
150
+ raw_call("get", "/me/bill/#{id}")
151
+ end
152
+
153
+ def bill_details(id)
154
+ raw_call("get", "/me/bill/#{id}/details")
155
+ end
156
+
157
+ def labs
158
+ raw_call("get", "/me/labs")
159
+ end
160
+
161
+ def lab(name)
162
+ raw_call("get", "/me/labs/#{name}")
163
+ end
164
+
165
+ def usage
166
+ raw_call("get", "/me/usage")
167
+ end
168
+
169
+ def validate(data)
170
+ raw_call("post", "/me/validate", data)
171
+ end
172
+ end
173
+
174
+ class RunaboveFlavor < Runabove
175
+ def list
176
+ raw_call("get", "/flavor")
177
+ end
178
+
179
+ def detail(id)
180
+ raw_call("get", "/flavor/#{id}")
181
+ end
182
+ end
183
+
184
+ class RunaboveImage < Runabove
185
+ def list
186
+ raw_call("get", "/image")
187
+ end
188
+
189
+ def detail(id)
190
+ raw_call("get", "/image/#{id}")
191
+ end
192
+ end
193
+
194
+ class RunaboveInstance < Runabove
195
+ def list
196
+ raw_call("get", "/instance")
197
+ end
198
+
199
+ def create(data)
200
+ raw_call("post", "/instance", data)
201
+ end
202
+
203
+ def quota
204
+ raw_call("get", "/instance/quota")
205
+ end
206
+
207
+ def detail(id)
208
+ raw_call("get", "/instance/#{id}")
209
+ end
210
+
211
+ def delete(id)
212
+ raw_call("delete", "/instance/#{id}")
213
+ end
214
+
215
+ def update(id, data)
216
+ raw_call("put", "/instance/#{id}", data)
217
+ end
218
+
219
+ def vnc(id)
220
+ raw_call("get", "/instance/#{id}/vnc")
221
+ end
222
+ end
223
+
224
+ class RunaboveLabs < Runabove
225
+ def list
226
+ raw_call("get", "/labs")
227
+ end
228
+
229
+ def detail(name)
230
+ raw_call("get", "/labs/#{name}")
231
+ end
232
+
233
+ def subscribe(name)
234
+ raw_call("post", "/labs/#{name}")
235
+ end
236
+ end
237
+
238
+ class RunabovePrice < Runabove
239
+ def list
240
+ raw_call("get", "/price/instance")
241
+ end
242
+ end
243
+
244
+ class RunaboveProject < Runabove
245
+ def list
246
+ raw_call("get", "/project")
247
+ end
248
+
249
+ def create
250
+ raw_call("post", "/project")
251
+ end
252
+ end
253
+
254
+ class RunaboveRegion < Runabove
255
+ def list
256
+ raw_call("get", "/region")
257
+ end
258
+ end
259
+
260
+ class RunaboveSsh < Runabove
261
+ def list
262
+ raw_call("get", "/ssh")
263
+ end
264
+
265
+ def create(data)
266
+ raw_call("post", "/ssh", data)
267
+ end
268
+
269
+ def detail(name)
270
+ raw_call("get", "/ssh/#{name}")
271
+ end
272
+
273
+ def delete(name)
274
+ raw_call("delete", "/ssh/#{name}")
275
+ end
276
+ end
277
+
278
+ class RunaboveStorage < Runabove
279
+ def list
280
+ raw_call("get", "/storage")
281
+ end
282
+
283
+ def create(data)
284
+ raw_call("post", "/storage", data)
285
+ end
286
+
287
+ def detail(name)
288
+ raw_call("get", "/storage/#{name}")
289
+ end
290
+ end
291
+
292
+ class RunaboveTime < Runabove
293
+ def now
294
+ raw_call("get", "/time")
295
+ end
296
+ end
297
+
298
+ class RunaboveToken < Runabove
299
+ def list
300
+ raw_call("get", "/token")
86
301
  end
87
- end
302
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runabove
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Olivier BONNAURE
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-23 00:00:00.000000000 Z
11
+ date: 2014-10-24 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A simple runabove wrapper
14
14
  email: olivier@solisoft.net