megam_api 0.17 → 0.18
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/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
@@ -1,225 +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 BoltRequest < Megam::ServerAPI
|
18
|
-
def initialize(email=nil, api_key=nil)
|
19
|
-
@id = nil
|
20
|
-
@req_type = nil
|
21
|
-
@boltdefns_id = nil
|
22
|
-
@node_name = nil
|
23
|
-
@lc_apply = nil
|
24
|
-
@lc_additional = nil
|
25
|
-
@lc_when = nil
|
26
|
-
@created_at = nil
|
27
|
-
@some_msg = {}
|
28
|
-
super(email, api_key)
|
29
|
-
end
|
30
|
-
|
31
|
-
def boltreqs
|
32
|
-
self
|
33
|
-
end
|
34
|
-
|
35
|
-
|
36
|
-
def id(arg=nil)
|
37
|
-
if arg != nil
|
38
|
-
@id = arg
|
39
|
-
else
|
40
|
-
@id
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def req_type(arg=nil)
|
45
|
-
if arg != nil
|
46
|
-
@req_type = arg
|
47
|
-
else
|
48
|
-
@req_type
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def boltdefns_id(arg=nil)
|
53
|
-
if arg != nil
|
54
|
-
@boltdefns_id = arg
|
55
|
-
else
|
56
|
-
@boltdefns_id
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
def node_name(arg=nil)
|
61
|
-
if arg != nil
|
62
|
-
@node_name = arg
|
63
|
-
else
|
64
|
-
@node_name
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
def lc_apply(arg=nil)
|
69
|
-
if arg != nil
|
70
|
-
@lc_apply = arg
|
71
|
-
else
|
72
|
-
@lc_apply
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
def lc_additional(arg=nil)
|
77
|
-
if arg != nil
|
78
|
-
@lc_additional = arg
|
79
|
-
else
|
80
|
-
@lc_additional
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
def lc_when(arg=nil)
|
85
|
-
if arg != nil
|
86
|
-
@lc_when = arg
|
87
|
-
else
|
88
|
-
@lc_when
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
def created_at(arg=nil)
|
93
|
-
if arg != nil
|
94
|
-
@created_at = arg
|
95
|
-
else
|
96
|
-
@created_at
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
def some_msg(arg=nil)
|
101
|
-
if arg != nil
|
102
|
-
@some_msg = arg
|
103
|
-
else
|
104
|
-
@some_msg
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
def error?
|
109
|
-
crocked = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error")
|
110
|
-
end
|
111
|
-
|
112
|
-
# Transform the ruby obj -> to a Hash
|
113
|
-
def to_hash
|
114
|
-
index_hash = Hash.new
|
115
|
-
index_hash["json_claz"] = self.class.name
|
116
|
-
index_hash["id"] = id
|
117
|
-
index_hash["req_type"] = req_type
|
118
|
-
index_hash["boltdefns_id"] = boltdefns_id
|
119
|
-
index_hash["node_name"] = node_name
|
120
|
-
index_hash["lc_apply"] = lc_apply
|
121
|
-
index_hash["lc_additional"] = lc_additional
|
122
|
-
index_hash["lc_when"] = lc_when
|
123
|
-
index_hash["created_at"] = created_at
|
124
|
-
index_hash["some_msg"] = some_msg
|
125
|
-
index_hash
|
126
|
-
end
|
127
|
-
|
128
|
-
# Serialize this object as a hash: called from JsonCompat.
|
129
|
-
# Verify if this called from JsonCompat during testing.
|
130
|
-
def to_json(*a)
|
131
|
-
for_json.to_json(*a)
|
132
|
-
end
|
133
|
-
|
134
|
-
def for_json
|
135
|
-
result = {
|
136
|
-
"id" => id,
|
137
|
-
"req_type" => req_type,
|
138
|
-
"boltdefns_id" => boltdefns_id,
|
139
|
-
"node_name" => node_name,
|
140
|
-
"lc_apply" => lc_apply,
|
141
|
-
"lc_additional" => lc_additional,
|
142
|
-
"lc_when" => lc_when,
|
143
|
-
"created_at" => created_at
|
144
|
-
}
|
145
|
-
result
|
146
|
-
end
|
147
|
-
|
148
|
-
# Create a Megam::Node from NodeResult-JSON
|
149
|
-
#
|
150
|
-
#[{
|
151
|
-
#"id":"NOD362212018897289216",
|
152
|
-
#"accounts_id":"ACT362211962353876992",
|
153
|
-
#"json_claz":"Megam::Node",
|
154
|
-
#"request":{
|
155
|
-
#"req_id":"NOD362212018897289216",
|
156
|
-
#"command":"commands"
|
157
|
-
#},
|
158
|
-
#"predefs":{
|
159
|
-
#"name":"",
|
160
|
-
#"scm":"",
|
161
|
-
#"war":"",
|
162
|
-
#"db":"",
|
163
|
-
#"queue":""
|
164
|
-
#}
|
165
|
-
#}]
|
166
|
-
#
|
167
|
-
def self.json_create(o)
|
168
|
-
boltreqs = new
|
169
|
-
boltreqs.id(o["id"]) if o.has_key?("id")
|
170
|
-
boltreqs.req_type(o["req_type"]) if o.has_key?("req_type")
|
171
|
-
boltreqs.boltdefns_id(o["boltdefns_id"]) if o.has_key?("boltdefns_id")
|
172
|
-
boltreqs.node_name(o["node_name"]) if o.has_key?("node_name")
|
173
|
-
boltreqs.lc_apply(o["lc_apply"]) if o.has_key?("lc_apply")
|
174
|
-
boltreqs.lc_additional(o["lc_additional"]) if o.has_key?("lc_additional")
|
175
|
-
boltreqs.lc_when(o["lc_when"]) if o.has_key?("lc_when")
|
176
|
-
boltreqs.created_at(o["created_at"]) if o.has_key?("created_at")
|
177
|
-
|
178
|
-
boltreqs.some_msg[:code] = o["code"] if o.has_key?("code")
|
179
|
-
boltreqs.some_msg[:msg_type] = o["msg_type"] if o.has_key?("msg_type")
|
180
|
-
boltreqs.some_msg[:msg]= o["msg"] if o.has_key?("msg")
|
181
|
-
boltreqs.some_msg[:links] = o["links"] if o.has_key?("links")
|
182
|
-
|
183
|
-
boltreqs
|
184
|
-
end
|
185
|
-
|
186
|
-
def self.from_hash(o,tmp_email=nil, tmp_api_key=nil)
|
187
|
-
boltreqs = self.new(tmp_email, tmp_api_key)
|
188
|
-
boltreqs.from_hash(o)
|
189
|
-
boltreqs
|
190
|
-
end
|
191
|
-
|
192
|
-
def from_hash(o)
|
193
|
-
@id = o["id"] if o.has_key?("id")
|
194
|
-
@req_type = o["req_type"] if o.has_key?("req_type")
|
195
|
-
@boltdefns_id = o["boltdefns_id"] if o.has_key?("boltdefns_id")
|
196
|
-
@node_name = o["node_name"] if o.has_key?("node_name")
|
197
|
-
@lc_apply = o["lc_apply"] if o.has_key?("lc_apply")
|
198
|
-
@lc_additional = o["lc_additional"] if o.has_key?("lc_additional")
|
199
|
-
@lc_when = o["lc_when"] if o.has_key?("lc_when")
|
200
|
-
@created_at = o["created_at"] if o.has_key?("created_at")
|
201
|
-
self
|
202
|
-
end
|
203
|
-
|
204
|
-
def self.create(o,tmp_email=nil, tmp_api_key=nil)
|
205
|
-
acct = from_hash(o,tmp_email, tmp_api_key)
|
206
|
-
acct.create
|
207
|
-
end
|
208
|
-
|
209
|
-
# Create the node via the REST API
|
210
|
-
def create
|
211
|
-
megam_rest.post_boltreq(to_hash)
|
212
|
-
end
|
213
|
-
|
214
|
-
# Load a account by email_p
|
215
|
-
def self.list(node_name,tmp_email=nil, tmp_api_key=nil)
|
216
|
-
boltreq = self.new(tmp_email, tmp_api_key)
|
217
|
-
boltreq.megam_rest.get_boltreq(node_name)
|
218
|
-
end
|
219
|
-
|
220
|
-
def to_s
|
221
|
-
Megam::Stuff.styled_hash(to_hash)
|
222
|
-
end
|
223
|
-
|
224
|
-
end
|
225
|
-
end
|
@@ -1,148 +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 boltlicable 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 BoltRequestCollection
|
18
|
-
include Enumerable
|
19
|
-
|
20
|
-
|
21
|
-
attr_reader :iterator
|
22
|
-
def initialize
|
23
|
-
@boltreqs = Array.new
|
24
|
-
@boltreqs_by_name = Hash.new
|
25
|
-
@insert_after_idx = nil
|
26
|
-
end
|
27
|
-
|
28
|
-
def all_boltreqs
|
29
|
-
@boltreqs
|
30
|
-
end
|
31
|
-
|
32
|
-
def [](index)
|
33
|
-
@boltreqs[index]
|
34
|
-
end
|
35
|
-
|
36
|
-
def []=(index, arg)
|
37
|
-
is_megam_boltreq(arg)
|
38
|
-
@boltreqs[index] = arg
|
39
|
-
@boltreqs_by_name[arg.id] = index
|
40
|
-
end
|
41
|
-
|
42
|
-
def <<(*args)
|
43
|
-
args.flatten.each do |a|
|
44
|
-
is_megam_boltreq(a)
|
45
|
-
@boltreqs << a
|
46
|
-
@boltreqs_by_name[a.id] = @boltreqs.length - 1
|
47
|
-
end
|
48
|
-
self
|
49
|
-
end
|
50
|
-
|
51
|
-
# 'push' is an alias method to <<
|
52
|
-
alias_method :push, :<<
|
53
|
-
|
54
|
-
def insert(boltreq)
|
55
|
-
is_megam_boltreq(boltreq)
|
56
|
-
if @insert_after_idx
|
57
|
-
# in the middle of executing a run, so any boltreqss inserted now should
|
58
|
-
# be placed after the most recent addition done by the currently executing
|
59
|
-
# boltreqs
|
60
|
-
@boltreqs.insert(@insert_after_idx + 1, boltreq)
|
61
|
-
# update name -> location mboltings and register new boltreqs
|
62
|
-
@boltreqs_by_name.each_key do |key|
|
63
|
-
@boltreqs_by_name[key] += 1 if @boltreqs_by_name[key] > @insert_after_idx
|
64
|
-
end
|
65
|
-
@boltreqs_by_name[boltreq.id] = @insert_after_idx + 1
|
66
|
-
@insert_after_idx += 1
|
67
|
-
else
|
68
|
-
@boltreqs << boltreq
|
69
|
-
@boltreqs_by_name[boltreq.id] = @boltreqs.length - 1
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
def each
|
74
|
-
@boltreqs.each do |boltreq|
|
75
|
-
yield boltreq
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
def each_index
|
80
|
-
@boltreqs.each_index do |i|
|
81
|
-
yield i
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
def empty?
|
86
|
-
@boltreqs.empty?
|
87
|
-
end
|
88
|
-
|
89
|
-
def lookup(boltreq)
|
90
|
-
lookup_by = nil
|
91
|
-
if boltreq.kind_of?(Megam::BoltRequest)
|
92
|
-
lookup_by = boltreq.id
|
93
|
-
elsif boltreq.kind_of?(String)
|
94
|
-
lookup_by = boltreq
|
95
|
-
else
|
96
|
-
raise ArgumentError, "Must pass a Megam::Boltreqs or String to lookup"
|
97
|
-
end
|
98
|
-
res = @boltreqs_by_name[lookup_by]
|
99
|
-
unless res
|
100
|
-
raise ArgumentError, "Cannot find a boltreq matching #{lookup_by} (did you define it first?)"
|
101
|
-
end
|
102
|
-
@boltreqs[res]
|
103
|
-
end
|
104
|
-
|
105
|
-
# Transform the ruby obj -> to a Hash
|
106
|
-
def to_hash
|
107
|
-
index_hash = Hash.new
|
108
|
-
self.each do |boltreq|
|
109
|
-
index_hash[boltreq.id] = boltreq.to_s
|
110
|
-
end
|
111
|
-
index_hash
|
112
|
-
end
|
113
|
-
|
114
|
-
# Serialize this object as a hash: called from JsonCompat.
|
115
|
-
# Verify if this called from JsonCompat during testing.
|
116
|
-
def to_json(*a)
|
117
|
-
for_json.to_json(*a)
|
118
|
-
end
|
119
|
-
|
120
|
-
|
121
|
-
def self.json_create(o)
|
122
|
-
collection = self.new()
|
123
|
-
o["results"].each do |boltreqs_list|
|
124
|
-
boltreqs_array = boltreqs_list.kind_of?(Array) ? boltreqs_list : [ boltreqs_list ]
|
125
|
-
boltreqs_array.each do |boltreq|
|
126
|
-
collection.insert(boltreq)
|
127
|
-
end
|
128
|
-
end
|
129
|
-
collection
|
130
|
-
end
|
131
|
-
|
132
|
-
private
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
def is_megam_boltreq(arg)
|
137
|
-
unless arg.kind_of?(Megam::BoltRequest)
|
138
|
-
raise ArgumentError, "Members must be Megam::Boltreq's"
|
139
|
-
end
|
140
|
-
true
|
141
|
-
end
|
142
|
-
|
143
|
-
def to_s
|
144
|
-
Megam::Stuff.styled_hash(to_hash)
|
145
|
-
end
|
146
|
-
|
147
|
-
end
|
148
|
-
end
|
data/lib/megam/core/boltdefns.rb
DELETED
@@ -1,207 +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
|
-
|
17
|
-
module Megam
|
18
|
-
class Boltdefns < Megam::ServerAPI
|
19
|
-
def initialize(email=nil, api_key=nil)
|
20
|
-
@id = nil
|
21
|
-
@node_id = nil
|
22
|
-
@node_name = nil
|
23
|
-
@boltdefns ={}
|
24
|
-
@created_at = nil
|
25
|
-
@some_msg = {}
|
26
|
-
super(email,api_key)
|
27
|
-
end
|
28
|
-
|
29
|
-
def boltdefns
|
30
|
-
self
|
31
|
-
end
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
def id(arg=nil)
|
36
|
-
if arg != nil
|
37
|
-
@id = arg
|
38
|
-
else
|
39
|
-
@id
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def node_id(arg=nil)
|
44
|
-
if arg != nil
|
45
|
-
@node_id = arg
|
46
|
-
else
|
47
|
-
@node_id
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def node_name(arg=nil)
|
52
|
-
if arg != nil
|
53
|
-
@node_name = arg
|
54
|
-
else
|
55
|
-
@node_name
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def boltdefns(arg=nil)
|
60
|
-
if arg != nil
|
61
|
-
@boltdefns = arg
|
62
|
-
else
|
63
|
-
@boltdefns
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
def created_at(arg=nil)
|
68
|
-
if arg != nil
|
69
|
-
@created_at = arg
|
70
|
-
else
|
71
|
-
@created_at
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
def some_msg(arg=nil)
|
76
|
-
if arg != nil
|
77
|
-
@some_msg = arg
|
78
|
-
else
|
79
|
-
@some_msg
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
def error?
|
84
|
-
crocked = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error")
|
85
|
-
end
|
86
|
-
|
87
|
-
# Transform the ruby obj -> to a Hash
|
88
|
-
def to_hash
|
89
|
-
index_hash = Hash.new
|
90
|
-
index_hash["json_claz"] = self.class.name
|
91
|
-
index_hash["id"] = id
|
92
|
-
index_hash["node_id"] = node_id
|
93
|
-
index_hash["node_name"] = node_name
|
94
|
-
index_hash["boltdefns"] = boltdefns
|
95
|
-
index_hash["created_at"] = created_at
|
96
|
-
index_hash["some_msg"] = some_msg
|
97
|
-
index_hash
|
98
|
-
end
|
99
|
-
|
100
|
-
# Serialize this object as a hash: called from JsonCompat.
|
101
|
-
# Verify if this called from JsonCompat during testing.
|
102
|
-
def to_json(*a)
|
103
|
-
for_json.to_json(*a)
|
104
|
-
end
|
105
|
-
|
106
|
-
def for_json
|
107
|
-
result = {
|
108
|
-
"id" => id,
|
109
|
-
"node_id" => node_id,
|
110
|
-
"node_name" => node_name,
|
111
|
-
"boltdefns" => boltdefns,
|
112
|
-
"created_at" => created_at
|
113
|
-
}
|
114
|
-
result
|
115
|
-
end
|
116
|
-
|
117
|
-
# Create a Megam::Node from NodeResult-JSON
|
118
|
-
#
|
119
|
-
#[{
|
120
|
-
#"id":"NOD362212018897289216",
|
121
|
-
#"accounts_id":"ACT362211962353876992",
|
122
|
-
#"json_claz":"Megam::Node",
|
123
|
-
#"request":{
|
124
|
-
#"req_id":"NOD362212018897289216",
|
125
|
-
#"command":"commands"
|
126
|
-
#},
|
127
|
-
#"predefs":{
|
128
|
-
#"name":"",
|
129
|
-
#"scm":"",
|
130
|
-
#"war":"",
|
131
|
-
#"db":"",
|
132
|
-
#"queue":""
|
133
|
-
#}
|
134
|
-
#}]
|
135
|
-
#
|
136
|
-
def self.json_create(o)
|
137
|
-
boltdefns = new
|
138
|
-
boltdefns.id(o["id"]) if o.has_key?("id")
|
139
|
-
boltdefns.node_id(o["node_id"]) if o.has_key?("node_id")
|
140
|
-
boltdefns.node_name(o["node_name"]) if o.has_key?("node_name")
|
141
|
-
boltdefns.created_at(o["created_at"]) if o.has_key?("created_at")
|
142
|
-
|
143
|
-
#APP DEFINITIONS
|
144
|
-
op = o["boltdefns"]
|
145
|
-
boltdefns.boltdefns[:username] = op["username"] if op && op.has_key?("username")
|
146
|
-
boltdefns.boltdefns[:apikey] = op["apikey"] if op && op.has_key?("apikey")
|
147
|
-
boltdefns.boltdefns[:store_name]= op["store_name"] if op && op.has_key?("store_name")
|
148
|
-
boltdefns.boltdefns[:url] = op["url"] if op && op.has_key?("url")
|
149
|
-
boltdefns.boltdefns[:prime] = op["prime"] if op && op.has_key?("prime")
|
150
|
-
|
151
|
-
boltdefns.boltdefns[:timetokill] = op["timetokill"] if op && op.has_key?("timetokill")
|
152
|
-
boltdefns.boltdefns[:metered] = op["metered"] if op && op.has_key?("metered")
|
153
|
-
boltdefns.boltdefns[:logging]= op["logging"] if op && op.has_key?("logging")
|
154
|
-
boltdefns.boltdefns[:runtime_exec] = op["runtime_exec"] if op && op.has_key?("runtime_exec")
|
155
|
-
boltdefns.boltdefns[:env_sh] = op["env_sh"] if op && op.has_key?("env_sh")
|
156
|
-
|
157
|
-
boltdefns.some_msg[:code] = o["code"] if o.has_key?("code")
|
158
|
-
boltdefns.some_msg[:msg_type] = o["msg_type"] if o.has_key?("msg_type")
|
159
|
-
boltdefns.some_msg[:msg]= o["msg"] if o.has_key?("msg")
|
160
|
-
boltdefns.some_msg[:links] = o["links"] if o.has_key?("links")
|
161
|
-
|
162
|
-
boltdefns
|
163
|
-
end
|
164
|
-
|
165
|
-
def self.from_hash(o,tmp_email=nil, tmp_api_key=nil)
|
166
|
-
boltdefns = self.new(tmp_email, tmp_api_key)
|
167
|
-
boltdefns.from_hash(o)
|
168
|
-
boltdefns
|
169
|
-
end
|
170
|
-
|
171
|
-
def from_hash(o)
|
172
|
-
@id = o["id"] if o.has_key?("id")
|
173
|
-
@node_id = o["node_id"] if o.has_key?("node_id")
|
174
|
-
@node_name = o["node_name"] if o.has_key?("node_name")
|
175
|
-
@boltdefns = o["boltdefns"] if o.has_key?("boltdefns")
|
176
|
-
@created_at = o["created_at"] if o.has_key?("created_at")
|
177
|
-
self
|
178
|
-
end
|
179
|
-
|
180
|
-
def self.create(o,tmp_email=nil, tmp_api_key=nil)
|
181
|
-
acct = from_hash(o,tmp_email, tmp_api_key)
|
182
|
-
acct.create
|
183
|
-
end
|
184
|
-
|
185
|
-
# Create the node via the REST API
|
186
|
-
def create
|
187
|
-
megam_rest.post_boltdefn(to_hash)
|
188
|
-
end
|
189
|
-
|
190
|
-
# Show all bolt defns by [node_name]/email
|
191
|
-
def self.show(node_name,tmp_email=nil, tmp_api_key=nil)
|
192
|
-
boltdefns = self.new(tmp_email, tmp_api_key)
|
193
|
-
boltdefns.megam_rest.get_boltdefn(node_name)
|
194
|
-
end
|
195
|
-
|
196
|
-
# Show a bolt defn by [node_name, defn id] for an email
|
197
|
-
def self.show_by_node(node_name,id,tmp_email=nil, tmp_api_key=nil)
|
198
|
-
boltdefns = self.new(tmp_email, tmp_api_key)
|
199
|
-
boltdefns.megam_rest.get_boltdefn(node_name,id)
|
200
|
-
end
|
201
|
-
|
202
|
-
def to_s
|
203
|
-
Megam::Stuff.styled_hash(to_hash)
|
204
|
-
end
|
205
|
-
|
206
|
-
end
|
207
|
-
end
|