megam_api 0.17 → 0.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/lib/megam/api.rb +20 -35
- data/lib/megam/api/{nodes.rb → assemblies.rb} +9 -9
- data/lib/megam/api/domains.rb +30 -0
- data/lib/megam/api/organizations.rb +30 -0
- data/lib/megam/api/version.rb +1 -1
- data/lib/megam/core/assemblies.rb +180 -0
- data/lib/megam/core/{node_collection.rb → assemblies_collection.rb} +44 -65
- data/lib/megam/core/csar.rb +0 -1
- data/lib/megam/core/domains.rb +129 -0
- data/lib/megam/core/json_compat.rb +17 -4
- data/lib/megam/core/organizations.rb +129 -0
- data/test/test_accounts.rb +1 -1
- data/test/test_assemblies.rb +10 -0
- data/test/test_domains.rb +27 -0
- data/test/test_helper.rb +25 -16
- data/test/test_organizations.rb +26 -0
- metadata +12 -38
- data/lib/megam/api/app_request.rb +0 -27
- data/lib/megam/api/appdefns.rb +0 -47
- data/lib/megam/api/bolt_request.rb +0 -27
- data/lib/megam/api/boltdefns.rb +0 -39
- data/lib/megam/api/cloud_tools.rb +0 -35
- data/lib/megam/api/logs.rb +0 -18
- data/lib/megam/api/predefs.rb +0 -35
- data/lib/megam/builder/delete_node.rb +0 -107
- data/lib/megam/builder/make_node.rb +0 -133
- data/lib/megam/core/app_request.rb +0 -227
- data/lib/megam/core/app_request_collection.rb +0 -148
- data/lib/megam/core/appdefns.rb +0 -182
- data/lib/megam/core/appdefns_collection.rb +0 -148
- data/lib/megam/core/bolt_request.rb +0 -225
- data/lib/megam/core/bolt_request_collection.rb +0 -148
- data/lib/megam/core/boltdefns.rb +0 -207
- data/lib/megam/core/boltdefns_collection.rb +0 -148
- data/lib/megam/core/cloudinstruction.rb +0 -110
- data/lib/megam/core/cloudinstruction_collection.rb +0 -145
- data/lib/megam/core/cloudinstruction_group.rb +0 -99
- data/lib/megam/core/cloudtemplate.rb +0 -127
- data/lib/megam/core/cloudtemplate_collection.rb +0 -145
- data/lib/megam/core/cloudtool.rb +0 -152
- data/lib/megam/core/cloudtool_collection.rb +0 -145
- data/lib/megam/core/node.rb +0 -366
- data/lib/megam/core/predef.rb +0 -201
- data/lib/megam/core/predef_collection.rb +0 -164
- data/test/test_appdefns.rb +0 -35
- data/test/test_appreqs.rb +0 -25
- data/test/test_boltdefns.rb +0 -32
- data/test/test_boltreqs.rb +0 -26
- data/test/test_cloudtools.rb +0 -22
- data/test/test_nodes.rb +0 -140
- data/test/test_predefs.rb +0 -72
data/lib/megam/core/node.rb
DELETED
@@ -1,366 +0,0 @@
|
|
1
|
-
# Copyright:: Copyright (c) 2012, 2014 Megam Systems
|
2
|
-
# License:: Apache License, Version 2.0
|
3
|
-
#
|
4
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
# you may not use this file except in compliance with the License.
|
6
|
-
# You may obtain a copy of the License at
|
7
|
-
#
|
8
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
#
|
10
|
-
# Unless required by applicable law or agreed to in writing, software
|
11
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
# See the License for the specific language governing permissions and
|
14
|
-
# limitations under the License.
|
15
|
-
#
|
16
|
-
require 'hashie'
|
17
|
-
|
18
|
-
module Megam
|
19
|
-
class Node < Megam::ServerAPI
|
20
|
-
def initialize(email=nil, api_key=nil)
|
21
|
-
@id = nil
|
22
|
-
@node_name = nil
|
23
|
-
@accounts_id = nil
|
24
|
-
@node_type = nil
|
25
|
-
@req_type = nil
|
26
|
-
@status=nil
|
27
|
-
@noofinstances=0
|
28
|
-
@request ={}
|
29
|
-
@predefs={}
|
30
|
-
@some_msg = {}
|
31
|
-
@command = Hashie::Mash.new
|
32
|
-
@appdefnsid = nil
|
33
|
-
@boltdefnsid = nil
|
34
|
-
@appdefns = {}
|
35
|
-
@boltdefns = {}
|
36
|
-
@created_at = nil
|
37
|
-
super(email, api_key)
|
38
|
-
end
|
39
|
-
|
40
|
-
def node
|
41
|
-
self
|
42
|
-
end
|
43
|
-
|
44
|
-
|
45
|
-
def node_name(arg=nil)
|
46
|
-
if arg != nil
|
47
|
-
@node_name = arg
|
48
|
-
else
|
49
|
-
@node_name
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def noofinstances(arg=nil)
|
54
|
-
if arg != nil
|
55
|
-
@noofinstances = arg
|
56
|
-
else
|
57
|
-
@noofinstances
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
def command(arg=nil)
|
62
|
-
if arg != nil
|
63
|
-
@command = arg
|
64
|
-
else
|
65
|
-
@command
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
def id(arg=nil)
|
70
|
-
if arg != nil
|
71
|
-
@id = arg
|
72
|
-
else
|
73
|
-
@id
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def accounts_id(arg=nil)
|
78
|
-
if arg != nil
|
79
|
-
@accounts_id = arg
|
80
|
-
else
|
81
|
-
@accounts_id
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
def node_type(arg=nil)
|
86
|
-
if arg != nil
|
87
|
-
@node_type = arg
|
88
|
-
else
|
89
|
-
@node_type
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
def req_type(arg=nil)
|
94
|
-
if arg != nil
|
95
|
-
@req_type = arg
|
96
|
-
else
|
97
|
-
@req_type
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
def status(arg=nil)
|
102
|
-
if arg != nil
|
103
|
-
@status = arg
|
104
|
-
else
|
105
|
-
@status
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
def request(arg=nil)
|
110
|
-
if arg != nil
|
111
|
-
@request = arg
|
112
|
-
else
|
113
|
-
@request
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
def predefs(arg=nil)
|
118
|
-
if arg != nil
|
119
|
-
@predefs = arg
|
120
|
-
else
|
121
|
-
@predefs
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
def appdefns(arg=nil)
|
126
|
-
if arg != nil
|
127
|
-
@appdefns = arg
|
128
|
-
else
|
129
|
-
@appdefns
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
def boltdefns(arg=nil)
|
134
|
-
if arg != nil
|
135
|
-
@boltdefns = arg
|
136
|
-
else
|
137
|
-
@boltdefns
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
def appdefnsid(arg=nil)
|
142
|
-
if arg != nil
|
143
|
-
@appdefnsid = arg
|
144
|
-
else
|
145
|
-
@appdefnsid
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
def boltdefnsid(arg=nil)
|
150
|
-
if arg != nil
|
151
|
-
@boltdefnsid = arg
|
152
|
-
else
|
153
|
-
@boltdefnsid
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
def created_at(arg=nil)
|
158
|
-
if arg != nil
|
159
|
-
@created_at = arg
|
160
|
-
else
|
161
|
-
@created_at
|
162
|
-
end
|
163
|
-
end
|
164
|
-
|
165
|
-
def some_msg(arg=nil)
|
166
|
-
if arg != nil
|
167
|
-
@some_msg = arg
|
168
|
-
else
|
169
|
-
@some_msg
|
170
|
-
end
|
171
|
-
end
|
172
|
-
|
173
|
-
def error?
|
174
|
-
crocked = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error")
|
175
|
-
end
|
176
|
-
|
177
|
-
# Transform the ruby obj -> to a Hash
|
178
|
-
def to_hash
|
179
|
-
index_hash = Hash.new
|
180
|
-
index_hash["json_claz"] = self.class.name
|
181
|
-
index_hash["id"] = id
|
182
|
-
index_hash["node_name"] = node_name
|
183
|
-
index_hash["accounts_id"] = accounts_id
|
184
|
-
index_hash["node_type"] = node_type
|
185
|
-
index_hash["req_type"] = req_type
|
186
|
-
index_hash["status"] = status
|
187
|
-
index_hash["command"] = command
|
188
|
-
index_hash["request"] = request
|
189
|
-
index_hash["predefs"] = predefs
|
190
|
-
index_hash["appdefns"] = appdefns
|
191
|
-
index_hash["boltdefns"] = boltdefns
|
192
|
-
index_hash["some_msg"] = some_msg
|
193
|
-
index_hash["noofinstances"] = noofinstances.to_i
|
194
|
-
index_hash["appdefnsid"] = appdefnsid
|
195
|
-
index_hash["boltdefnsid"] = boltdefnsid
|
196
|
-
index_hash["created_at"] = created_at
|
197
|
-
index_hash
|
198
|
-
end
|
199
|
-
|
200
|
-
# Serialize this object as a hash: called from JsonCompat.
|
201
|
-
# Verify if this called from JsonCompat during testing.
|
202
|
-
def to_json(*a)
|
203
|
-
for_json.to_json(*a)
|
204
|
-
end
|
205
|
-
|
206
|
-
def for_json
|
207
|
-
result = {
|
208
|
-
"id" => id,
|
209
|
-
"node_name" => node_name,
|
210
|
-
"accounts_id" => accounts_id,
|
211
|
-
"node_type" => node_type,
|
212
|
-
"req_type" => req_type,
|
213
|
-
"status" => status,
|
214
|
-
"request" => request,
|
215
|
-
"predefs" => predefs,
|
216
|
-
"appdefns" => appdefns,
|
217
|
-
"boltdefns" => boltdefns,
|
218
|
-
"appdefnsid" => appdefnsid,
|
219
|
-
"boltdefnsid" => boltdefnsid,
|
220
|
-
"noofinstances" => noofinstances,
|
221
|
-
"created_at" => created_at
|
222
|
-
}
|
223
|
-
result
|
224
|
-
end
|
225
|
-
|
226
|
-
# Create a Megam::Node from NodeResult-JSON
|
227
|
-
#
|
228
|
-
#[{
|
229
|
-
#"id":"NOD362212018897289216",
|
230
|
-
#"accounts_id":"ACT362211962353876992",
|
231
|
-
#"json_claz":"Megam::Node",
|
232
|
-
#"request":{
|
233
|
-
#"req_id":"NOD362212018897289216",
|
234
|
-
#"command":"commands"
|
235
|
-
#},
|
236
|
-
#"predefs":{
|
237
|
-
#"name":"",
|
238
|
-
#"scm":"",
|
239
|
-
#"war":"",
|
240
|
-
#"db":"",
|
241
|
-
#"queue":""
|
242
|
-
#}
|
243
|
-
#}]
|
244
|
-
#
|
245
|
-
def self.json_create(o)
|
246
|
-
node = new
|
247
|
-
node.id(o["id"]) if o.has_key?("id")
|
248
|
-
node.node_name(o["node_name"]) if o.has_key?("node_name")
|
249
|
-
node.accounts_id(o["accounts_id"]) if o.has_key?("accounts_id")
|
250
|
-
node.node_type(o["node_type"]) if o.has_key?("node_type")
|
251
|
-
node.req_type(o["req_type"]) if o.has_key?("req_type")
|
252
|
-
node.status(o["status"]) if o.has_key?("status")
|
253
|
-
node.appdefnsid(o["appdefnsid"]) if o.has_key?("appdefnsid")
|
254
|
-
node.boltdefnsid(o["boltdefnsid"]) if o.has_key?("boltdefnsid")
|
255
|
-
node.noofinstances(o["noofinstances"]) if o.has_key?("noofinstances")
|
256
|
-
node.created_at(o["created_at"]) if o.has_key?("created_at")
|
257
|
-
#requests
|
258
|
-
oq = o["request"]
|
259
|
-
node.request[:req_id] = oq["req_id"] if oq && oq.has_key?("req_id")
|
260
|
-
node.request[:req_type] = oq["req_type"] if oq && oq.has_key?("req_type")
|
261
|
-
node.request[:command] = oq["command"] if oq && oq.has_key?("command")
|
262
|
-
|
263
|
-
#Command
|
264
|
-
=begin
|
265
|
-
node.command[:systemprovider][:provider][:prov] = oc["systemprovider"]["provider"]["prov"]
|
266
|
-
node.command[:compute][:cctype] = oc["compute"]["cctype"]
|
267
|
-
node.command[:compute][:cc][:groups] = oc["compute"]["cc"]["groups"]
|
268
|
-
node.command[:compute][:cc][:image] = oc["compute"]["cc"]["image"]
|
269
|
-
node.command[:compute][:cc][:flavor] = oc["compute"]["cc"]["flavor"]
|
270
|
-
node.command[:compute][:access][:ssh_key] = oc["compute"]["access"]["ssh_key"]
|
271
|
-
node.command[:compute][:access][:identity_file] = oc["compute"]["access"]["identity_file"]
|
272
|
-
node.command[:compute][:access][:ssh_user] = oc["compute"]["access"]["ssh_user"]
|
273
|
-
node.command[:cloudtool][:chef][:command] = oc["cloudtool"]["chef"]["command"]
|
274
|
-
node.command[:cloudtool][:chef][:plugin] = oc["cloudtool"]["chef"]["plugin"]
|
275
|
-
node.command[:cloudtool][:chef][:run_list] = oc["cloudtool"]["chef"]["run_list"]
|
276
|
-
node.command[:cloudtool][:chef][:name] = oc["cloudtool"]["chef"]["name"]
|
277
|
-
=end
|
278
|
-
#predef
|
279
|
-
op = o["predefs"]
|
280
|
-
node.predefs[:name] = op["name"] if op && op.has_key?("name")
|
281
|
-
node.predefs[:scm] = op["scm"] if op && op.has_key?("scm")
|
282
|
-
node.predefs[:war]= op["war"] if op && op.has_key?("war")
|
283
|
-
node.predefs[:db] = op["db"] if op && op.has_key?("db")
|
284
|
-
node.predefs[:queue] = op["queue"] if op && op.has_key?("queue")
|
285
|
-
|
286
|
-
#APP DEFINITIONS
|
287
|
-
op = o["appdefns"]
|
288
|
-
node.appdefns[:timetokill] = op["timetokill"] if op && op.has_key?("timetokill")
|
289
|
-
node.appdefns[:metered] = op["metered"] if op && op.has_key?("metered")
|
290
|
-
node.appdefns[:logging]= op["logging"] if op && op.has_key?("logging")
|
291
|
-
node.appdefns[:runtime_exec] = op["runtime_exec"] if op && op.has_key?("runtime_exec")
|
292
|
-
node.appdefns[:env_sh] = op["env_sh"] if op && op.has_key?("env_sh")
|
293
|
-
|
294
|
-
#BOLT DEFINITIONS
|
295
|
-
op = o["boltdefns"]
|
296
|
-
node.boltdefns[:username] = op["username"] if op && op.has_key?("username")
|
297
|
-
node.boltdefns[:apikey] = op["apikey"] if op && op.has_key?("apikey")
|
298
|
-
node.boltdefns[:store_name]= op["store_name"] if op && op.has_key?("store_name")
|
299
|
-
node.boltdefns[:url] = op["url"] if op && op.has_key?("url")
|
300
|
-
node.boltdefns[:timetokill] = op["timetokill"] if op && op.has_key?("timetokill")
|
301
|
-
node.boltdefns[:metered] = op["metered"] if op && op.has_key?("metered")
|
302
|
-
node.boltdefns[:logging]= op["logging"] if op && op.has_key?("logging")
|
303
|
-
node.boltdefns[:runtime_exec] = op["runtime_exec"] if op && op.has_key?("runtime_exec")
|
304
|
-
node.boltdefns[:env_sh] = op["env_sh"] if op && op.has_key?("env_sh")
|
305
|
-
|
306
|
-
#success or error
|
307
|
-
node.some_msg[:code] = o["code"] if o.has_key?("code")
|
308
|
-
node.some_msg[:msg_type] = o["msg_type"] if o.has_key?("msg_type")
|
309
|
-
node.some_msg[:msg]= o["msg"] if o.has_key?("msg")
|
310
|
-
node.some_msg[:links] = o["links"] if o.has_key?("links")
|
311
|
-
|
312
|
-
node
|
313
|
-
end
|
314
|
-
|
315
|
-
def self.from_hash(o,tmp_email=nil, tmp_api_key=nil)
|
316
|
-
node = self.new(tmp_email, tmp_api_key)
|
317
|
-
node.from_hash(o)
|
318
|
-
node
|
319
|
-
end
|
320
|
-
|
321
|
-
def from_hash(o)
|
322
|
-
@node_name = o["node_name"] if o.has_key?("node_name")
|
323
|
-
@command = o["command"] if o.has_key?("command")
|
324
|
-
@id = o["id"] if o.has_key?("id")
|
325
|
-
@accounts_id = o["accounts_id"] if o.has_key?("accounts_id")
|
326
|
-
@node_type = o["node_type"] if o.has_key?("node_type")
|
327
|
-
@req_type = o["req_type"] if o.has_key?("req_type")
|
328
|
-
@request = o["request"] if o.has_key?("request")
|
329
|
-
@predefs = o["predefs"] if o.has_key?("predefs")
|
330
|
-
@appdefns = o["appdefns"] if o.has_key?("appdefns")
|
331
|
-
@boltdefns = o["boltdefns"] if o.has_key?("boltdefns")
|
332
|
-
@appdefnsid = o["appdefnsid"] if o.has_key?("appdefnsid")
|
333
|
-
@boltdefnsid = o["boltdefnsid"] if o.has_key?("boltdefnsid")
|
334
|
-
@noofinstances = o["noofinstances"] if o.has_key?("noofinstances")
|
335
|
-
@created_at = o["created_at"] if o.has_key?("created_at")
|
336
|
-
self
|
337
|
-
end
|
338
|
-
|
339
|
-
def self.create(o,tmp_email=nil, tmp_api_key=nil)
|
340
|
-
acct = from_hash(o, tmp_email, tmp_api_key)
|
341
|
-
acct.create
|
342
|
-
end
|
343
|
-
|
344
|
-
# Create the node via the REST API
|
345
|
-
def create
|
346
|
-
megam_rest.post_node(to_hash)
|
347
|
-
end
|
348
|
-
|
349
|
-
# Load a account by email_p
|
350
|
-
def self.show(node_name, tmp_email=nil, tmp_api_key=nil)
|
351
|
-
node = self.new(tmp_email, tmp_api_key)
|
352
|
-
node.megam_rest.get_node(node_name)
|
353
|
-
end
|
354
|
-
|
355
|
-
def self.list(tmp_email=nil, tmp_api_key=nil)
|
356
|
-
node = self.new(tmp_email, tmp_api_key)
|
357
|
-
node.megam_rest.get_nodes
|
358
|
-
end
|
359
|
-
|
360
|
-
def to_s
|
361
|
-
Megam::Stuff.styled_hash(to_hash)
|
362
|
-
#"---> Megam::Account:[error=#{error?}]\n"+
|
363
|
-
end
|
364
|
-
|
365
|
-
end
|
366
|
-
end
|
data/lib/megam/core/predef.rb
DELETED
@@ -1,201 +0,0 @@
|
|
1
|
-
# Copyright:: Copyright (c) 2012, 2014 Megam Systems
|
2
|
-
# License:: Apache License, Version 2.0
|
3
|
-
#
|
4
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
# you may not use this file except in compliance with the License.
|
6
|
-
# You may obtain a copy of the License at
|
7
|
-
#
|
8
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
#
|
10
|
-
# Unless required by applicable law or agreed to in writing, software
|
11
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
# See the License for the specific language governing permissions and
|
14
|
-
# limitations under the License.
|
15
|
-
#
|
16
|
-
module Megam
|
17
|
-
class Predef < Megam::ServerAPI
|
18
|
-
def initialize(email=nil, api_key=nil)
|
19
|
-
@id = nil
|
20
|
-
@name = nil
|
21
|
-
@provider = nil
|
22
|
-
@provider_role =nil
|
23
|
-
@build_monkey=nil
|
24
|
-
@runtime_exec = nil
|
25
|
-
@created_at = nil
|
26
|
-
@some_msg = {}
|
27
|
-
super(email, api_key)
|
28
|
-
end
|
29
|
-
|
30
|
-
def predef
|
31
|
-
self
|
32
|
-
end
|
33
|
-
|
34
|
-
def id(arg=nil)
|
35
|
-
if arg != nil
|
36
|
-
@id = arg
|
37
|
-
else
|
38
|
-
@id
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def name(arg=nil)
|
43
|
-
if arg != nil
|
44
|
-
@name = arg
|
45
|
-
else
|
46
|
-
@name
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def runtime_exec(arg=nil)
|
51
|
-
if arg != nil
|
52
|
-
@runtime_exec = arg
|
53
|
-
else
|
54
|
-
@runtime_exec
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def provider(arg=nil)
|
59
|
-
if arg != nil
|
60
|
-
@provider = arg
|
61
|
-
else
|
62
|
-
@provider
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
def provider_role(arg=nil)
|
67
|
-
if arg != nil
|
68
|
-
@provider_role = arg
|
69
|
-
else
|
70
|
-
@provider_role
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
def build_monkey(arg=nil)
|
75
|
-
if arg != nil
|
76
|
-
@build_monkey = arg
|
77
|
-
else
|
78
|
-
@build_monkey
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
def created_at(arg=nil)
|
83
|
-
if arg != nil
|
84
|
-
@created_at = arg
|
85
|
-
else
|
86
|
-
@created_at
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
def some_msg(arg=nil)
|
91
|
-
if arg != nil
|
92
|
-
@some_msg = arg
|
93
|
-
else
|
94
|
-
@some_msg
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
def error?
|
99
|
-
crocked = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error")
|
100
|
-
end
|
101
|
-
|
102
|
-
# Transform the ruby obj -> to a Hash
|
103
|
-
def to_hash
|
104
|
-
index_hash = Hash.new
|
105
|
-
index_hash["json_claz"] = self.class.name
|
106
|
-
index_hash["id"] = id
|
107
|
-
index_hash["name"] = name
|
108
|
-
index_hash["provider"] = provider
|
109
|
-
index_hash["provider_role"] = provider_role
|
110
|
-
index_hash["build_monkey"] = build_monkey
|
111
|
-
index_hash["runtime_exec"] = runtime_exec
|
112
|
-
index_hash["created_at"] = created_at
|
113
|
-
index_hash
|
114
|
-
end
|
115
|
-
|
116
|
-
# Serialize this object as a hash: called from JsonCompat.
|
117
|
-
# Verify if this called from JsonCompat during testing.
|
118
|
-
def to_json(*a)
|
119
|
-
for_json.to_json(*a)
|
120
|
-
end
|
121
|
-
|
122
|
-
def for_json
|
123
|
-
result = {
|
124
|
-
"id" => id,
|
125
|
-
"name" => name,
|
126
|
-
"provider" => provider,
|
127
|
-
"provider_role" => provider_role,
|
128
|
-
"build_monkey" => build_monkey,
|
129
|
-
"runtime_exec" => runtime_exec,
|
130
|
-
"created_at" => created_at
|
131
|
-
}
|
132
|
-
result
|
133
|
-
end
|
134
|
-
|
135
|
-
#
|
136
|
-
def self.json_create(o)
|
137
|
-
node = new
|
138
|
-
node.id(o["id"]) if o.has_key?("id")
|
139
|
-
node.name(o["name"]) if o.has_key?("name")
|
140
|
-
node.provider(o["provider"]) if o.has_key?("provider")
|
141
|
-
node.provider_role(o["provider_role"]) if o.has_key?("provider_role")
|
142
|
-
node.build_monkey(o["build_monkey"]) if o.has_key?("build_monkey")
|
143
|
-
node.runtime_exec(o["runtime_exec"]) if o.has_key?("runtime_exec")
|
144
|
-
node.created_at(o["created_at"]) if o.has_key?("created_at")
|
145
|
-
#success or error
|
146
|
-
node.some_msg[:code] = o["code"] if o.has_key?("code")
|
147
|
-
node.some_msg[:msg_type] = o["msg_type"] if o.has_key?("msg_type")
|
148
|
-
node.some_msg[:msg]= o["msg"] if o.has_key?("msg")
|
149
|
-
node.some_msg[:links] = o["links"] if o.has_key?("links")
|
150
|
-
node
|
151
|
-
end
|
152
|
-
|
153
|
-
def self.from_hash(o,tmp_email=nil, tmp_api_key=nil)
|
154
|
-
node = self.new(tmp_email, tmp_api_key)
|
155
|
-
node.from_hash(o)
|
156
|
-
node
|
157
|
-
end
|
158
|
-
|
159
|
-
def from_hash(o)
|
160
|
-
@id = o[:id] if o.has_key?(:id)
|
161
|
-
@name = o[:name] if o.has_key?(:name)
|
162
|
-
@provider = o[:provider] if o.has_key?(:provider)
|
163
|
-
@provider_role = o[:provider_role] if o.has_key?(:provider_role)
|
164
|
-
@build_monkey = o[:build_monkey] if o.has_key?(:build_monkey)
|
165
|
-
@runtime_exec = o[:runtime_exec] if o.has_key?(:runtime_exec)
|
166
|
-
@created_at = o[:created_at] if o.has_key?(:created_at)
|
167
|
-
self
|
168
|
-
end
|
169
|
-
|
170
|
-
def self.create(o,tmp_email=nil, tmp_api_key=nil)
|
171
|
-
predef = from_hash(o,tmp_email, tmp_api_key)
|
172
|
-
predef.create
|
173
|
-
end
|
174
|
-
|
175
|
-
# Create the predef via the REST API
|
176
|
-
def create(predef_input)
|
177
|
-
megam_rest.post_predef(predef_input)
|
178
|
-
self
|
179
|
-
end
|
180
|
-
|
181
|
-
# Load all predefs -
|
182
|
-
# returns a PredefsCollection
|
183
|
-
# don't return self. check if the Megam::PredefCollection is returned.
|
184
|
-
def self.list(tmp_email=nil, tmp_api_key=nil)
|
185
|
-
prede = self.new(tmp_email,tmp_api_key)
|
186
|
-
prede.megam_rest.get_predefs
|
187
|
-
end
|
188
|
-
|
189
|
-
# Show a particular predef by name,
|
190
|
-
# Megam::Predef
|
191
|
-
def self.show(p_name,tmp_email=nil, tmp_api_key=nil)
|
192
|
-
prede = self.new(tmp_email,tmp_api_key)
|
193
|
-
prede.megam_rest.get_predef(p_name)
|
194
|
-
end
|
195
|
-
|
196
|
-
def to_s
|
197
|
-
Megam::Stuff.styled_hash(to_hash)
|
198
|
-
end
|
199
|
-
|
200
|
-
end
|
201
|
-
end
|