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,19 +1,3 @@
|
|
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
2
|
class EventsStorage < Megam::RestAdapter
|
19
3
|
def initialize(o)
|
@@ -1,18 +1,3 @@
|
|
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
1
|
module Megam
|
17
2
|
class EventsStorageCollection
|
18
3
|
include Enumerable
|
data/lib/megam/core/eventsvm.rb
CHANGED
@@ -1,19 +1,3 @@
|
|
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
2
|
class EventsVm < Megam::RestAdapter
|
19
3
|
def initialize(o)
|
@@ -1,137 +1,122 @@
|
|
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
1
|
module Megam
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
2
|
+
class EventsVmCollection
|
3
|
+
include Enumerable
|
4
|
+
|
5
|
+
attr_reader :iterator
|
6
|
+
def initialize
|
7
|
+
@eventsvm = Array.new
|
8
|
+
@eventsvm_by_name = Hash.new
|
9
|
+
@insert_after_idx = nil
|
10
|
+
end
|
26
11
|
|
27
|
-
|
28
|
-
|
29
|
-
|
12
|
+
def all_eventsvm
|
13
|
+
@eventsvm
|
14
|
+
end
|
30
15
|
|
31
|
-
|
32
|
-
|
33
|
-
|
16
|
+
def [](index)
|
17
|
+
@eventsvm[index]
|
18
|
+
end
|
34
19
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
20
|
+
def []=(index, arg)
|
21
|
+
is_megam_eventsvm(arg)
|
22
|
+
@eventsvm[index] = arg
|
23
|
+
@eventsvm_by_name[arg.account_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_events(a)
|
29
|
+
@eventsvm << a
|
30
|
+
@eventsvm_by_name[a.account_id] = @eventsvm.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(eventsvm)
|
39
|
+
is_megam_eventsvm(eventsvm)
|
40
|
+
if @insert_after_idx
|
41
|
+
# in the middle of executing a run, so any nodes inserted now should
|
42
|
+
# be placed after the most recent addition done by the currently executing
|
43
|
+
# node
|
44
|
+
@eventsvm.insert(@insert_after_idx + 1, eventsvm)
|
45
|
+
# update name -> location mappings and register new node
|
46
|
+
@eventsvm_by_name.each_key do |key|
|
47
|
+
@eventsvm_by_name[key] += 1 if @eventsvm_by_name[key] > @insert_after_idx
|
48
|
+
end
|
49
|
+
@eventsvm_by_name[eventsvm.account_id] = @insert_after_idx + 1
|
50
|
+
@insert_after_idx += 1
|
51
|
+
else
|
52
|
+
@eventsvm << eventsvm
|
53
|
+
@eventsvm_by_name[eventsvm.account_id] = @eventsvm.length - 1
|
54
|
+
end
|
63
55
|
end
|
64
|
-
@eventsvm_by_name[eventsvm.account_id] = @insert_after_idx + 1
|
65
|
-
@insert_after_idx += 1
|
66
|
-
else
|
67
|
-
@eventsvm << eventsvm
|
68
|
-
@eventsvm_by_name[eventsvm.account_id] = @eventsvm.length - 1
|
69
|
-
end
|
70
|
-
end
|
71
56
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
57
|
+
def each
|
58
|
+
@eventsvm.each do |eventsvm|
|
59
|
+
yield eventsvm
|
60
|
+
end
|
61
|
+
end
|
77
62
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
63
|
+
def each_index
|
64
|
+
@eventsvm.each_index do |i|
|
65
|
+
yield i
|
66
|
+
end
|
67
|
+
end
|
83
68
|
|
84
|
-
|
85
|
-
|
86
|
-
|
69
|
+
def empty?
|
70
|
+
@eventsvm.empty?
|
71
|
+
end
|
87
72
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
73
|
+
def lookup(eventsvm)
|
74
|
+
lookup_by = nil
|
75
|
+
if events.kind_of?(Megam::EventsVm)
|
76
|
+
lookup_by = eventsvm.account_id
|
77
|
+
elsif events.kind_of?(String)
|
78
|
+
lookup_by = eventsvm
|
79
|
+
else
|
80
|
+
raise ArgumentError, "Must pass a Megam::EventsVm or String to lookup"
|
81
|
+
end
|
82
|
+
res = @eventsvm_by_name[lookup_by]
|
83
|
+
unless res
|
84
|
+
raise ArgumentError, "Cannot find a node matching #{lookup_by} (did you define it first?)"
|
85
|
+
end
|
86
|
+
@eventsvm[res]
|
87
|
+
end
|
103
88
|
|
104
|
-
|
105
|
-
|
106
|
-
|
89
|
+
def to_s
|
90
|
+
@eventsvm.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 |eventsvm_list|
|
104
|
+
eventsvm_array = eventsvm_list.kind_of?(Array) ? eventsvm_list : [ eventsvm_list ]
|
105
|
+
eventsvm_array.each do |eventsvm|
|
106
|
+
collection.insert(eventsvm)
|
122
107
|
|
108
|
+
end
|
109
|
+
end
|
110
|
+
collection
|
123
111
|
end
|
124
|
-
end
|
125
|
-
collection
|
126
|
-
end
|
127
112
|
|
128
|
-
|
113
|
+
private
|
129
114
|
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
115
|
+
def is_megam_eventsvm(arg)
|
116
|
+
unless arg.kind_of?(Megam::EventsVm)
|
117
|
+
raise ArgumentError, "Members must be Megam::EventsVm's"
|
118
|
+
end
|
119
|
+
true
|
120
|
+
end
|
135
121
|
end
|
136
|
-
end
|
137
122
|
end
|
@@ -1,15 +1,3 @@
|
|
1
|
-
#
|
2
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
3
|
-
# you may not use this file except in compliance with the License.
|
4
|
-
# You may obtain a copy of the License at
|
5
|
-
#
|
6
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
7
|
-
#
|
8
|
-
# Unless required by applicable law or agreed to in writing, software
|
9
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
10
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
11
|
-
# See the License for the specific language governing permissions and
|
12
|
-
# limitations under the License.
|
13
1
|
|
14
2
|
# Wrapper class for interacting with JSON.
|
15
3
|
|
data/lib/megam/core/konipai.rb
CHANGED
@@ -1,18 +1,3 @@
|
|
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
1
|
module Megam
|
17
2
|
class KoniPai
|
18
3
|
|
data/lib/megam/core/log.rb
CHANGED
@@ -1,18 +1,3 @@
|
|
1
|
-
#
|
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
1
|
require 'logger'
|
17
2
|
require 'mixlib/log'
|
18
3
|
require 'megam/core/monologger'
|
@@ -1,244 +1,227 @@
|
|
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
|
-
|
18
1
|
module Megam
|
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
|
-
|
2
|
+
class MarketPlace < Megam::RestAdapter
|
3
|
+
def initialize(o)
|
4
|
+
@id = nil
|
5
|
+
@settings_name = nil
|
6
|
+
@cattype = nil
|
7
|
+
@flavor = nil
|
8
|
+
@image = nil
|
9
|
+
@catorder = nil
|
10
|
+
@url = nil
|
11
|
+
@envs = []
|
12
|
+
@options = []
|
13
|
+
@plans = nil
|
14
|
+
@created_at = nil
|
15
|
+
super(o)
|
16
|
+
end
|
17
|
+
|
18
|
+
def market_place
|
19
|
+
self
|
20
|
+
end
|
21
|
+
|
22
|
+
def settings_name(arg = nil)
|
23
|
+
if !arg.nil?
|
24
|
+
@settings_name = arg
|
25
|
+
else
|
26
|
+
@settings_name
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def id(arg = nil)
|
31
|
+
if !arg.nil?
|
32
|
+
@id = arg
|
33
|
+
else
|
34
|
+
@id
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def plans(arg = nil)
|
39
|
+
if !arg.nil?
|
40
|
+
@plans = arg
|
41
|
+
else
|
42
|
+
@plans
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def cattype(arg = nil)
|
47
|
+
if !arg.nil?
|
48
|
+
@cattype = arg
|
49
|
+
else
|
50
|
+
@cattype
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def flavor(arg = nil)
|
55
|
+
if !arg.nil?
|
56
|
+
@flavor = arg
|
57
|
+
else
|
58
|
+
@flavor
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def catorder(arg = nil)
|
63
|
+
if !arg.nil?
|
64
|
+
@catorder = arg
|
65
|
+
else
|
66
|
+
@catorder
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def image(arg = nil)
|
71
|
+
if !arg.nil?
|
72
|
+
@image = arg
|
73
|
+
else
|
74
|
+
@image
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def url(arg = nil)
|
79
|
+
if !arg.nil?
|
80
|
+
@url = arg
|
81
|
+
else
|
82
|
+
@url
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def envs(arg = [])
|
87
|
+
if arg != []
|
88
|
+
@envs = arg
|
89
|
+
else
|
90
|
+
@envs
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def options(arg = [])
|
95
|
+
if arg != []
|
96
|
+
@options = arg
|
97
|
+
else
|
98
|
+
@options
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def created_at(arg = nil)
|
103
|
+
if !arg.nil?
|
104
|
+
@created_at = arg
|
105
|
+
else
|
106
|
+
@created_at
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def some_msg(arg = nil)
|
111
|
+
if !arg.nil?
|
112
|
+
@some_msg = arg
|
113
|
+
else
|
114
|
+
@some_msg
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
def error?
|
119
|
+
crocked = true if some_msg.key?(:msg_type) && some_msg[:msg_type] == 'error'
|
120
|
+
end
|
121
|
+
|
122
|
+
# Transform the ruby obj -> to a Hash
|
123
|
+
def to_hash
|
124
|
+
index_hash = {}
|
125
|
+
index_hash['json_claz'] = self.class.name
|
126
|
+
index_hash['id'] = id
|
127
|
+
index_hash['settings_name'] = settings_name
|
128
|
+
index_hash['cattype'] = cattype
|
129
|
+
index_hash['flavor'] = flavor
|
130
|
+
index_hash['image'] = image
|
131
|
+
index_hash['catorder'] = catorder
|
132
|
+
index_hash['url'] = url
|
133
|
+
index_hash['envs'] = envs
|
134
|
+
index_hash['options'] = options
|
135
|
+
index_hash['plans'] = plans
|
136
|
+
index_hash['created_at'] = created_at
|
137
|
+
index_hash
|
138
|
+
end
|
139
|
+
|
140
|
+
# Serialize this object as a hash: called from JsonCompat.
|
141
|
+
# Verify if this called from JsonCompat during testing.
|
142
|
+
def to_json(*a)
|
143
|
+
for_json.to_json(*a)
|
144
|
+
end
|
145
|
+
|
146
|
+
def for_json
|
147
|
+
result = {
|
148
|
+
'id' => id,
|
149
|
+
'settings_name' => settings_name,
|
150
|
+
'cattype' => cattype,
|
151
|
+
'flavor' => flavor,
|
152
|
+
'image' => image,
|
153
|
+
'catorder' => catorder,
|
154
|
+
'url' => url,
|
155
|
+
'envs' => envs,
|
156
|
+
'options' => options,
|
157
|
+
'plans' => plans,
|
158
|
+
'created_at' => created_at
|
159
|
+
}
|
160
|
+
result
|
161
|
+
end
|
162
|
+
|
163
|
+
def self.json_create(o)
|
164
|
+
app = new({})
|
165
|
+
app.id(o['id']) if o.key?('id')
|
166
|
+
app.settings_name(o['settings_name']) if o.key?('settings_name')
|
167
|
+
app.cattype(o['cattype']) if o.key?('cattype')
|
168
|
+
app.flavor(o['flavor']) if o.key?('flavor')
|
169
|
+
app.image(o['image']) if o.key?('image')
|
170
|
+
app.catorder(o['catorder']) if o.key?('catorder')
|
171
|
+
app.url(o['url']) if o.key?('url')
|
172
|
+
app.envs(o['envs']) if o.key?('envs')
|
173
|
+
app.options(o['options']) if o.key?('options')
|
174
|
+
app.plans(o['plans']) if o.key?('plans')
|
175
|
+
app.created_at(o['created_at']) if o.key?('created_at')
|
176
|
+
|
177
|
+
app
|
178
|
+
end
|
179
|
+
|
180
|
+
def self.from_hash(o)
|
181
|
+
app = new(o)
|
182
|
+
app.from_hash(o)
|
183
|
+
app
|
184
|
+
end
|
185
|
+
|
186
|
+
def from_hash(o)
|
187
|
+
@settings_name = o['settings_name'] if o.key?('settings_name')
|
188
|
+
@id = o['id'] if o.key?('id')
|
189
|
+
@cattype = o['cattype'] if o.key?('cattype')
|
190
|
+
@flavor = o['flavor'] if o.key?('flavor')
|
191
|
+
@image = o['image'] if o.key?('image')
|
192
|
+
@catorder = o['catorder'] if o.key?('catorder')
|
193
|
+
@url = o['url'] if o.key?('url')
|
194
|
+
@envs = o['envs'] if o.key?('envs')
|
195
|
+
@options = o['options'] if o.key?('options')
|
196
|
+
@plans = o['plans'] if o.key?('plans')
|
197
|
+
@created_at = o['created_at'] if o.key?('created_at')
|
198
|
+
self
|
199
|
+
end
|
200
|
+
|
201
|
+
def self.create(params)
|
202
|
+
acct = from_hash(params)
|
203
|
+
acct.create
|
204
|
+
end
|
205
|
+
|
206
|
+
# Create the marketplace app via the REST API
|
207
|
+
def create
|
208
|
+
megam_rest.post_marketplaceapp(to_hash)
|
209
|
+
end
|
210
|
+
|
211
|
+
# Load a account by email_p
|
212
|
+
def self.show(params)
|
213
|
+
app = new(params)
|
214
|
+
app.megam_rest.get_marketplaceapp(params['id'])
|
215
|
+
end
|
216
|
+
|
217
|
+
def self.list(params)
|
218
|
+
app = new(params)
|
219
|
+
app.megam_rest.get_marketplaceapps
|
220
|
+
end
|
221
|
+
|
222
|
+
def to_s
|
223
|
+
Megam::Stuff.styled_hash(to_hash)
|
224
|
+
# "---> Megam::Account:[error=#{error?}]\n"+
|
225
|
+
end
|
242
226
|
end
|
243
|
-
end
|
244
227
|
end
|