megam_api 1.5.rc5 → 1.5.rc7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -2
- data/LICENSE +21 -202
- data/README.md +3 -20
- data/lib/megam/api.rb +154 -169
- data/lib/megam/api/accounts.rb +0 -15
- data/lib/megam/api/assemblies.rb +0 -15
- data/lib/megam/api/assembly.rb +0 -15
- data/lib/megam/api/balances.rb +0 -15
- data/lib/megam/api/billedhistories.rb +0 -15
- data/lib/megam/api/billingtransactions.rb +0 -15
- data/lib/megam/api/components.rb +0 -15
- data/lib/megam/api/domains.rb +0 -15
- data/lib/megam/api/errors.rb +0 -15
- data/lib/megam/api/eventsbilling.rb +0 -15
- data/lib/megam/api/eventscontainer.rb +0 -15
- data/lib/megam/api/eventsstorage.rb +0 -15
- data/lib/megam/api/eventsvm.rb +0 -15
- data/lib/megam/api/marketplaces.rb +0 -15
- data/lib/megam/api/organizations.rb +0 -15
- data/lib/megam/api/promos.rb +0 -15
- data/lib/megam/api/requests.rb +0 -15
- data/lib/megam/api/sensors.rb +0 -15
- data/lib/megam/api/snapshots.rb +0 -15
- data/lib/megam/api/sshkeys.rb +0 -15
- data/lib/megam/api/version.rb +1 -16
- data/lib/megam/core/account.rb +241 -60
- data/lib/megam/core/assemblies.rb +0 -16
- data/lib/megam/core/assemblies_collection.rb +101 -116
- data/lib/megam/core/assembly.rb +201 -218
- data/lib/megam/core/assembly_collection.rb +101 -116
- data/lib/megam/core/balances.rb +182 -197
- data/lib/megam/core/balances_collection.rb +101 -116
- data/lib/megam/core/billedhistories.rb +186 -201
- data/lib/megam/core/billedhistories_collection.rb +101 -116
- data/lib/megam/core/billingtransactions.rb +0 -15
- data/lib/megam/core/billingtransactions_collection.rb +0 -15
- data/lib/megam/core/components.rb +300 -316
- data/lib/megam/core/components_collection.rb +0 -15
- data/lib/megam/core/domain_collection.rb +1 -16
- data/lib/megam/core/domains.rb +115 -131
- data/lib/megam/core/error.rb +55 -70
- data/lib/megam/core/eventsbilling.rb +0 -16
- data/lib/megam/core/eventsbilling_collection.rb +101 -116
- data/lib/megam/core/eventscontainer.rb +0 -16
- data/lib/megam/core/eventscontainer_collection.rb +101 -116
- data/lib/megam/core/eventsstorage.rb +0 -16
- data/lib/megam/core/eventsstorage_collection.rb +0 -15
- data/lib/megam/core/eventsvm.rb +0 -16
- data/lib/megam/core/eventsvm_collection.rb +101 -116
- data/lib/megam/core/json_compat.rb +0 -12
- data/lib/megam/core/konipai.rb +0 -15
- data/lib/megam/core/log.rb +0 -15
- data/lib/megam/core/marketplace.rb +224 -241
- data/lib/megam/core/marketplace_collection.rb +0 -15
- data/lib/megam/core/organizations.rb +0 -16
- data/lib/megam/core/organizations_collection.rb +0 -15
- data/lib/megam/core/promos.rb +0 -15
- data/lib/megam/core/request.rb +0 -15
- data/lib/megam/core/request_collection.rb +0 -15
- data/lib/megam/core/rest_adapter.rb +0 -15
- data/lib/megam/core/sensors.rb +138 -154
- data/lib/megam/core/sensors_collection.rb +0 -15
- data/lib/megam/core/snapshots.rb +0 -16
- data/lib/megam/core/snapshots_collection.rb +0 -15
- data/lib/megam/core/sshkey.rb +169 -184
- data/lib/megam/core/sshkey_collection.rb +0 -15
- data/lib/megam/core/stuff.rb +17 -32
- data/lib/megam/core/text.rb +82 -97
- data/lib/megam/mixins/assemblies.rb +10 -25
- data/lib/megam/mixins/assembly.rb +33 -49
- data/lib/megam/mixins/common_deployable.rb +64 -79
- data/lib/megam/mixins/components.rb +160 -175
- data/lib/megam/mixins/megam_attributes.rb +22 -37
- data/lib/megam/mixins/outputs.rb +14 -29
- data/lib/megam/mixins/policies.rb +21 -36
- data/lib/megam_api.rb +0 -15
- data/test/mixins/test_assemblies.rb +1 -2
- data/test/test_accounts.rb +84 -29
- data/test/test_billingtranscations.rb +17 -21
- data/test/test_eventscontainer.rb +19 -23
- data/test/test_eventsstorage.rb +8 -10
- data/test/test_eventsvm.rb +19 -23
- data/test/test_helper.rb +30 -30
- data/test/test_snapshots.rb +16 -22
- metadata +2 -2
@@ -1,136 +1,121 @@
|
|
1
|
-
##
|
2
|
-
## Copyright 2013-2016 Megam Systems
|
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
1
|
module Megam
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
2
|
+
class BilledhistoriesCollection
|
3
|
+
include Enumerable
|
4
|
+
|
5
|
+
attr_reader :iterator
|
6
|
+
def initialize
|
7
|
+
@billedhistories = Array.new
|
8
|
+
@billedhistories_by_name = Hash.new
|
9
|
+
@insert_after_idx = nil
|
10
|
+
end
|
26
11
|
|
27
|
-
|
28
|
-
|
29
|
-
|
12
|
+
def all_billedhistories
|
13
|
+
@billedhistories
|
14
|
+
end
|
30
15
|
|
31
|
-
|
32
|
-
|
33
|
-
|
16
|
+
def [](index)
|
17
|
+
@billedhistories[index]
|
18
|
+
end
|
34
19
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
20
|
+
def []=(index, arg)
|
21
|
+
is_megam_billedhistories(arg)
|
22
|
+
@billedhistories[index] = arg
|
23
|
+
@billedhistories_by_name[arg.accounts_id] = index
|
24
|
+
end
|
40
25
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
26
|
+
def <<(*args)
|
27
|
+
args.flatten.each do |a|
|
28
|
+
is_megam_billedhistories(a)
|
29
|
+
@billedhistories << a
|
30
|
+
@billedhistories_by_name[a.accounts_id] =@billedhistories.length - 1
|
31
|
+
end
|
32
|
+
self
|
33
|
+
end
|
49
34
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
35
|
+
# 'push' is an alias method to <<
|
36
|
+
alias_method :push, :<<
|
37
|
+
|
38
|
+
def insert(billedhistories)
|
39
|
+
is_megam_billedhistories(billedhistories)
|
40
|
+
if @insert_after_idx
|
41
|
+
# in the middle of executing a run, so any predefs inserted now should
|
42
|
+
# be placed after the most recent addition done by the currently executing
|
43
|
+
# billedhistories
|
44
|
+
@billedhistories.insert(@insert_after_idx + 1, billedhistories)
|
45
|
+
# update name -> location mappings and register new billedhistories
|
46
|
+
@billedhistories_by_name.each_key do |key|
|
47
|
+
@billedhistories_by_name[key] += 1 if@billedhistories_by_name[key] > @insert_after_idx
|
48
|
+
end
|
49
|
+
@billedhistories_by_name[billedhistories.accounts_id] = @insert_after_idx + 1
|
50
|
+
@insert_after_idx += 1
|
51
|
+
else
|
52
|
+
@billedhistories << billedhistories
|
53
|
+
@billedhistories_by_name[billedhistories.accounts_id] =@billedhistories.length - 1
|
54
|
+
end
|
63
55
|
end
|
64
|
-
@billedhistories_by_name[billedhistories.accounts_id] = @insert_after_idx + 1
|
65
|
-
@insert_after_idx += 1
|
66
|
-
else
|
67
|
-
@billedhistories << billedhistories
|
68
|
-
@billedhistories_by_name[billedhistories.accounts_id] =@billedhistories.length - 1
|
69
|
-
end
|
70
|
-
end
|
71
56
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
57
|
+
def each
|
58
|
+
@billedhistories.each do |billedhistories|
|
59
|
+
yield billedhistories
|
60
|
+
end
|
61
|
+
end
|
77
62
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
63
|
+
def each_index
|
64
|
+
@billedhistories.each_index do |i|
|
65
|
+
yield i
|
66
|
+
end
|
67
|
+
end
|
83
68
|
|
84
|
-
|
85
|
-
|
86
|
-
|
69
|
+
def empty?
|
70
|
+
@billedhistories.empty?
|
71
|
+
end
|
87
72
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
73
|
+
def lookup(billedhistories)
|
74
|
+
lookup_by = nil
|
75
|
+
if Billedhistories.kind_of?(Megam::Billedhistories)
|
76
|
+
lookup_by = billedhistories.accounts_id
|
77
|
+
elsif billedhistories.kind_of?(String)
|
78
|
+
lookup_by = billedhistories
|
79
|
+
else
|
80
|
+
raise ArgumentError, "Must pass a Megam::billedhistories or String to lookup"
|
81
|
+
end
|
82
|
+
res =@billedhistories_by_name[lookup_by]
|
83
|
+
unless res
|
84
|
+
raise ArgumentError, "Cannot find a billedhistories matching #{lookup_by} (did you define it first?)"
|
85
|
+
end
|
86
|
+
@billedhistories[res]
|
87
|
+
end
|
103
88
|
|
104
|
-
|
105
|
-
|
106
|
-
|
89
|
+
def to_s
|
90
|
+
@billedhistories.join(", ")
|
91
|
+
end
|
107
92
|
|
108
|
-
|
109
|
-
|
110
|
-
|
93
|
+
def for_json
|
94
|
+
to_a.map { |item| item.to_s }
|
95
|
+
end
|
111
96
|
|
112
|
-
|
113
|
-
|
114
|
-
|
97
|
+
def to_json(*a)
|
98
|
+
Megam::JSONCompat.to_json(for_json, *a)
|
99
|
+
end
|
115
100
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
101
|
+
def self.json_create(o)
|
102
|
+
collection = self.new()
|
103
|
+
o["results"].each do |billedhistories_list|
|
104
|
+
billedhistories_array = billedhistories_list.kind_of?(Array) ? billedhistories_list : [ billedhistories_list ]
|
105
|
+
billedhistories_array.each do |billedhistories|
|
106
|
+
collection.insert(billedhistories)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
collection
|
122
110
|
end
|
123
|
-
end
|
124
|
-
collection
|
125
|
-
end
|
126
111
|
|
127
|
-
|
112
|
+
private
|
128
113
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
114
|
+
def is_megam_billedhistories(arg)
|
115
|
+
unless arg.kind_of?(Megam::Billedhistories)
|
116
|
+
raise ArgumentError, "Members must be Megam::billedhistories's"
|
117
|
+
end
|
118
|
+
true
|
119
|
+
end
|
134
120
|
end
|
135
|
-
end
|
136
121
|
end
|
@@ -1,18 +1,3 @@
|
|
1
|
-
##
|
2
|
-
## Copyright 2013-2016 Megam Systems
|
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
1
|
module Megam
|
17
2
|
class Billingtransactions < Megam::RestAdapter
|
18
3
|
def initialize(o)
|
@@ -1,18 +1,3 @@
|
|
1
|
-
##
|
2
|
-
## Copyright 2013-2016 Megam Systems
|
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
1
|
module Megam
|
17
2
|
class BillingtransactionsCollection
|
18
3
|
include Enumerable
|
@@ -1,319 +1,303 @@
|
|
1
|
-
# Copyright:: Copyright (c) 2013-2016 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
1
|
module Megam
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
2
|
+
class Components < Megam::RestAdapter
|
3
|
+
def initialize(o)
|
4
|
+
@id = nil
|
5
|
+
@name = nil
|
6
|
+
@tosca_type = nil
|
7
|
+
@inputs = []
|
8
|
+
@outputs = []
|
9
|
+
@envs = []
|
10
|
+
@artifacts = {}
|
11
|
+
@artifact_type = nil
|
12
|
+
@content = nil
|
13
|
+
@artifact_requirements = []
|
14
|
+
@related_components = []
|
15
|
+
@operations = []
|
16
|
+
@status = nil
|
17
|
+
@repo = {}
|
18
|
+
@rtype = nil
|
19
|
+
@source = nil
|
20
|
+
@oneclick = nil
|
21
|
+
@url = nil
|
22
|
+
@created_at = nil
|
23
|
+
|
24
|
+
super(o)
|
25
|
+
end
|
26
|
+
|
27
|
+
def components
|
28
|
+
self
|
29
|
+
end
|
30
|
+
|
31
|
+
def id(arg = nil)
|
32
|
+
if !arg.nil?
|
33
|
+
@id = arg
|
34
|
+
else
|
35
|
+
@id
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def name(arg = nil)
|
40
|
+
if !arg.nil?
|
41
|
+
@name = arg
|
42
|
+
else
|
43
|
+
@name
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def tosca_type(arg = nil)
|
48
|
+
if !arg.nil?
|
49
|
+
@tosca_type = arg
|
50
|
+
else
|
51
|
+
@tosca_type
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def inputs(arg = [])
|
56
|
+
if arg != []
|
57
|
+
@inputs = arg
|
58
|
+
else
|
59
|
+
@inputs
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def outputs(arg = [])
|
64
|
+
if arg != []
|
65
|
+
@outputs = arg
|
66
|
+
else
|
67
|
+
@outputs
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def envs(arg = [])
|
72
|
+
if arg != []
|
73
|
+
@envs = arg
|
74
|
+
else
|
75
|
+
@envs
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def artifacts(arg = nil)
|
80
|
+
if !arg.nil?
|
81
|
+
@artifacts = arg
|
82
|
+
else
|
83
|
+
@artifacts
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def artifact_type(arg = nil)
|
88
|
+
if !arg.nil?
|
89
|
+
@artifact_type = arg
|
90
|
+
else
|
91
|
+
@artifact_type
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def content(arg = nil)
|
96
|
+
if !arg.nil?
|
97
|
+
@content = arg
|
98
|
+
else
|
99
|
+
@content
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def artifact_requirements(arg = [])
|
104
|
+
if arg != []
|
105
|
+
@artifact_requirements = arg
|
106
|
+
else
|
107
|
+
@artifact_requirements
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def related_components(arg = [])
|
112
|
+
if arg != []
|
113
|
+
@related_components = arg
|
114
|
+
else
|
115
|
+
@related_components
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
def operations(arg = [])
|
120
|
+
if arg != []
|
121
|
+
@operations = arg
|
122
|
+
else
|
123
|
+
@operations
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
def status(arg = nil)
|
128
|
+
if !arg.nil?
|
129
|
+
@status = arg
|
130
|
+
else
|
131
|
+
@status
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def repo(arg = nil)
|
136
|
+
if !arg.nil?
|
137
|
+
@repo = arg
|
138
|
+
else
|
139
|
+
@repo
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
def rtype(arg = nil)
|
144
|
+
if !arg.nil?
|
145
|
+
@rtype = arg
|
146
|
+
else
|
147
|
+
@rtype
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
def source(arg = nil)
|
152
|
+
if !arg.nil?
|
153
|
+
@source = arg
|
154
|
+
else
|
155
|
+
@source
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
def oneclick(arg = nil)
|
160
|
+
if !arg.nil?
|
161
|
+
@oneclick = arg
|
162
|
+
else
|
163
|
+
@oneclick
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
def url(arg = nil)
|
168
|
+
if !arg.nil?
|
169
|
+
@url = arg
|
170
|
+
else
|
171
|
+
@url
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
def created_at(arg = nil)
|
176
|
+
if !arg.nil?
|
177
|
+
@created_at = arg
|
178
|
+
else
|
179
|
+
@created_at
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
def error?
|
184
|
+
crocked = true if some_msg.key?(:msg_type) && some_msg[:msg_type] == 'error'
|
185
|
+
end
|
186
|
+
|
187
|
+
# Transform the ruby obj -> to a Hash
|
188
|
+
def to_hash
|
189
|
+
index_hash = {}
|
190
|
+
index_hash['json_claz'] = self.class.name
|
191
|
+
index_hash['id'] = id
|
192
|
+
index_hash['name'] = name
|
193
|
+
index_hash['tosca_type'] = tosca_type
|
194
|
+
index_hash['inputs'] = inputs
|
195
|
+
index_hash['outputs'] = outputs
|
196
|
+
index_hash['envs'] = envs
|
197
|
+
index_hash['artifacts'] = artifacts
|
198
|
+
index_hash['related_components'] = related_components
|
199
|
+
index_hash['operations'] = operations
|
200
|
+
index_hash['status'] = status
|
201
|
+
index_hash['repo'] = repo
|
202
|
+
index_hash['created_at'] = created_at
|
203
|
+
index_hash
|
204
|
+
end
|
205
|
+
|
206
|
+
# Serialize this object as a hash: called from JsonCompat.
|
207
|
+
# Verify if this called from JsonCompat during testing.
|
208
|
+
def to_json(*a)
|
209
|
+
for_json.to_json(*a)
|
210
|
+
end
|
211
|
+
|
212
|
+
def for_json
|
213
|
+
result = {
|
214
|
+
'id' => id,
|
215
|
+
'name' => name,
|
216
|
+
'tosca_type' => tosca_type,
|
217
|
+
'inputs' => inputs,
|
218
|
+
'outputs' => outputs,
|
219
|
+
'envs' => envs,
|
220
|
+
'artifacts' => artifacts,
|
221
|
+
'related_components' => related_components,
|
222
|
+
'operations' => operations,
|
223
|
+
'status' => status,
|
224
|
+
'repo' => repo,
|
225
|
+
'created_at' => created_at
|
226
|
+
}
|
227
|
+
result
|
228
|
+
end
|
229
|
+
|
230
|
+
def self.json_create(o)
|
231
|
+
asm = new({})
|
232
|
+
asm.id(o['id']) if o.key?('id')
|
233
|
+
asm.name(o['name']) if o.key?('name')
|
234
|
+
asm.tosca_type(o['tosca_type']) if o.key?('tosca_type')
|
235
|
+
asm.inputs(o['inputs']) if o.key?('inputs')
|
236
|
+
asm.outputs(o['outputs']) if o.key?('outputs')
|
237
|
+
asm.envs(o['envs']) if o.key?('envs')
|
238
|
+
ar = o['artifacts']
|
239
|
+
asm.artifacts[:artifact_type] = ar['artifact_type'] if ar && ar.key?('artifact_type')
|
240
|
+
asm.artifacts[:content] = ar['content'] if ar && ar.key?('content')
|
241
|
+
asm.artifacts[:artifact_requirements] = ar['artifact_requirements'] if ar && ar.key?('artifact_requirements')
|
242
|
+
|
243
|
+
asm.related_components(o['related_components']) if o.key?('related_components')
|
244
|
+
asm.operations(o['operations']) if o.key?('operations')
|
245
|
+
asm.status(o['status']) if o.key?('status')
|
246
|
+
|
247
|
+
ro = o['repo']
|
248
|
+
asm.repo[:rtype] = ro['rtype'] if ro && ro.key?('rtype')
|
249
|
+
asm.repo[:source] = ro['source'] if ro && ro.key?('source')
|
250
|
+
asm.repo[:oneclick] = ro['oneclick'] if ro && ro.key?('oneclick')
|
251
|
+
asm.repo[:url] = ro['url'] if ro && ro.key?('url')
|
252
|
+
asm.created_at(o['created_at']) if o.key?('created_at')
|
253
|
+
asm
|
254
|
+
end
|
255
|
+
|
256
|
+
def self.from_hash(o)
|
257
|
+
asm = new(o)
|
258
|
+
asm.from_hash(o)
|
259
|
+
asm
|
260
|
+
end
|
261
|
+
|
262
|
+
def from_hash(o)
|
263
|
+
@id = o['id'] if o.key?('id')
|
264
|
+
@name = o['name'] if o.key?('name')
|
265
|
+
@tosca_type = o['tosca_type'] if o.key?('tosca_type')
|
266
|
+
@inputs = o['inputs'] if o.key?('inputs')
|
267
|
+
@outputs = o['outputs'] if o.key?('outputs')
|
268
|
+
@envs = o['envs'] if o.key?('envs')
|
269
|
+
@artifacts = o['artifacts'] if o.key?('artifacts')
|
270
|
+
@related_components = o['related_components'] if o.key?('related_components')
|
271
|
+
@operations = o['operations'] if o.key?('operations')
|
272
|
+
@status = o['status'] if o.key?('status')
|
273
|
+
@repo = o['repo'] if o.key?('repo')
|
274
|
+
@created_at = o['created_at'] if o.key?('created_at')
|
275
|
+
self
|
276
|
+
end
|
277
|
+
|
278
|
+
def self.create(params)
|
279
|
+
asm = from_hash(params)
|
280
|
+
asm.create
|
281
|
+
end
|
282
|
+
|
283
|
+
# Load a account by email_p
|
284
|
+
def self.show(params)
|
285
|
+
asm = new(params)
|
286
|
+
asm.megam_rest.get_components(params['id'])
|
287
|
+
end
|
288
|
+
|
289
|
+
def self.update(params)
|
290
|
+
asm = from_hash(params)
|
291
|
+
asm.update
|
292
|
+
end
|
293
|
+
|
294
|
+
# Create the node via the REST API
|
295
|
+
def update
|
296
|
+
megam_rest.update_component(to_hash)
|
297
|
+
end
|
298
|
+
|
299
|
+
def to_s
|
300
|
+
Megam::Stuff.styled_hash(to_hash)
|
301
|
+
end
|
317
302
|
end
|
318
|
-
end
|
319
303
|
end
|