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.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -2
  3. data/LICENSE +21 -202
  4. data/README.md +3 -20
  5. data/lib/megam/api.rb +154 -169
  6. data/lib/megam/api/accounts.rb +0 -15
  7. data/lib/megam/api/assemblies.rb +0 -15
  8. data/lib/megam/api/assembly.rb +0 -15
  9. data/lib/megam/api/balances.rb +0 -15
  10. data/lib/megam/api/billedhistories.rb +0 -15
  11. data/lib/megam/api/billingtransactions.rb +0 -15
  12. data/lib/megam/api/components.rb +0 -15
  13. data/lib/megam/api/domains.rb +0 -15
  14. data/lib/megam/api/errors.rb +0 -15
  15. data/lib/megam/api/eventsbilling.rb +0 -15
  16. data/lib/megam/api/eventscontainer.rb +0 -15
  17. data/lib/megam/api/eventsstorage.rb +0 -15
  18. data/lib/megam/api/eventsvm.rb +0 -15
  19. data/lib/megam/api/marketplaces.rb +0 -15
  20. data/lib/megam/api/organizations.rb +0 -15
  21. data/lib/megam/api/promos.rb +0 -15
  22. data/lib/megam/api/requests.rb +0 -15
  23. data/lib/megam/api/sensors.rb +0 -15
  24. data/lib/megam/api/snapshots.rb +0 -15
  25. data/lib/megam/api/sshkeys.rb +0 -15
  26. data/lib/megam/api/version.rb +1 -16
  27. data/lib/megam/core/account.rb +241 -60
  28. data/lib/megam/core/assemblies.rb +0 -16
  29. data/lib/megam/core/assemblies_collection.rb +101 -116
  30. data/lib/megam/core/assembly.rb +201 -218
  31. data/lib/megam/core/assembly_collection.rb +101 -116
  32. data/lib/megam/core/balances.rb +182 -197
  33. data/lib/megam/core/balances_collection.rb +101 -116
  34. data/lib/megam/core/billedhistories.rb +186 -201
  35. data/lib/megam/core/billedhistories_collection.rb +101 -116
  36. data/lib/megam/core/billingtransactions.rb +0 -15
  37. data/lib/megam/core/billingtransactions_collection.rb +0 -15
  38. data/lib/megam/core/components.rb +300 -316
  39. data/lib/megam/core/components_collection.rb +0 -15
  40. data/lib/megam/core/domain_collection.rb +1 -16
  41. data/lib/megam/core/domains.rb +115 -131
  42. data/lib/megam/core/error.rb +55 -70
  43. data/lib/megam/core/eventsbilling.rb +0 -16
  44. data/lib/megam/core/eventsbilling_collection.rb +101 -116
  45. data/lib/megam/core/eventscontainer.rb +0 -16
  46. data/lib/megam/core/eventscontainer_collection.rb +101 -116
  47. data/lib/megam/core/eventsstorage.rb +0 -16
  48. data/lib/megam/core/eventsstorage_collection.rb +0 -15
  49. data/lib/megam/core/eventsvm.rb +0 -16
  50. data/lib/megam/core/eventsvm_collection.rb +101 -116
  51. data/lib/megam/core/json_compat.rb +0 -12
  52. data/lib/megam/core/konipai.rb +0 -15
  53. data/lib/megam/core/log.rb +0 -15
  54. data/lib/megam/core/marketplace.rb +224 -241
  55. data/lib/megam/core/marketplace_collection.rb +0 -15
  56. data/lib/megam/core/organizations.rb +0 -16
  57. data/lib/megam/core/organizations_collection.rb +0 -15
  58. data/lib/megam/core/promos.rb +0 -15
  59. data/lib/megam/core/request.rb +0 -15
  60. data/lib/megam/core/request_collection.rb +0 -15
  61. data/lib/megam/core/rest_adapter.rb +0 -15
  62. data/lib/megam/core/sensors.rb +138 -154
  63. data/lib/megam/core/sensors_collection.rb +0 -15
  64. data/lib/megam/core/snapshots.rb +0 -16
  65. data/lib/megam/core/snapshots_collection.rb +0 -15
  66. data/lib/megam/core/sshkey.rb +169 -184
  67. data/lib/megam/core/sshkey_collection.rb +0 -15
  68. data/lib/megam/core/stuff.rb +17 -32
  69. data/lib/megam/core/text.rb +82 -97
  70. data/lib/megam/mixins/assemblies.rb +10 -25
  71. data/lib/megam/mixins/assembly.rb +33 -49
  72. data/lib/megam/mixins/common_deployable.rb +64 -79
  73. data/lib/megam/mixins/components.rb +160 -175
  74. data/lib/megam/mixins/megam_attributes.rb +22 -37
  75. data/lib/megam/mixins/outputs.rb +14 -29
  76. data/lib/megam/mixins/policies.rb +21 -36
  77. data/lib/megam_api.rb +0 -15
  78. data/test/mixins/test_assemblies.rb +1 -2
  79. data/test/test_accounts.rb +84 -29
  80. data/test/test_billingtranscations.rb +17 -21
  81. data/test/test_eventscontainer.rb +19 -23
  82. data/test/test_eventsstorage.rb +8 -10
  83. data/test/test_eventsvm.rb +19 -23
  84. data/test/test_helper.rb +30 -30
  85. data/test/test_snapshots.rb +16 -22
  86. 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
@@ -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
- class EventsVmCollection
18
- include Enumerable
19
-
20
- attr_reader :iterator
21
- def initialize
22
- @eventsvm = Array.new
23
- @eventsvm_by_name = Hash.new
24
- @insert_after_idx = nil
25
- end
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
- def all_eventsvm
28
- @eventsvm
29
- end
12
+ def all_eventsvm
13
+ @eventsvm
14
+ end
30
15
 
31
- def [](index)
32
- @eventsvm[index]
33
- end
16
+ def [](index)
17
+ @eventsvm[index]
18
+ end
34
19
 
35
- def []=(index, arg)
36
- is_megam_eventsvm(arg)
37
- @eventsvm[index] = arg
38
- @eventsvm_by_name[arg.account_id] = index
39
- end
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
- def <<(*args)
42
- args.flatten.each do |a|
43
- is_megam_events(a)
44
- @eventsvm << a
45
- @eventsvm_by_name[a.account_id] = @eventsvm.length - 1
46
- end
47
- self
48
- end
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
- # 'push' is an alias method to <<
51
- alias_method :push, :<<
52
-
53
- def insert(eventsvm)
54
- is_megam_eventsvm(eventsvm)
55
- if @insert_after_idx
56
- # in the middle of executing a run, so any nodes inserted now should
57
- # be placed after the most recent addition done by the currently executing
58
- # node
59
- @eventsvm.insert(@insert_after_idx + 1, eventsvm)
60
- # update name -> location mappings and register new node
61
- @eventsvm_by_name.each_key do |key|
62
- @eventsvm_by_name[key] += 1 if @eventsvm_by_name[key] > @insert_after_idx
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
- def each
73
- @eventsvm.each do |eventsvm|
74
- yield eventsvm
75
- end
76
- end
57
+ def each
58
+ @eventsvm.each do |eventsvm|
59
+ yield eventsvm
60
+ end
61
+ end
77
62
 
78
- def each_index
79
- @eventsvm.each_index do |i|
80
- yield i
81
- end
82
- end
63
+ def each_index
64
+ @eventsvm.each_index do |i|
65
+ yield i
66
+ end
67
+ end
83
68
 
84
- def empty?
85
- @eventsvm.empty?
86
- end
69
+ def empty?
70
+ @eventsvm.empty?
71
+ end
87
72
 
88
- def lookup(eventsvm)
89
- lookup_by = nil
90
- if events.kind_of?(Megam::EventsVm)
91
- lookup_by = eventsvm.account_id
92
- elsif events.kind_of?(String)
93
- lookup_by = eventsvm
94
- else
95
- raise ArgumentError, "Must pass a Megam::EventsVm or String to lookup"
96
- end
97
- res = @eventsvm_by_name[lookup_by]
98
- unless res
99
- raise ArgumentError, "Cannot find a node matching #{lookup_by} (did you define it first?)"
100
- end
101
- @eventsvm[res]
102
- end
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
- def to_s
105
- @eventsvm.join(", ")
106
- end
89
+ def to_s
90
+ @eventsvm.join(", ")
91
+ end
107
92
 
108
- def for_json
109
- to_a.map { |item| item.to_s }
110
- end
93
+ def for_json
94
+ to_a.map { |item| item.to_s }
95
+ end
111
96
 
112
- def to_json(*a)
113
- Megam::JSONCompat.to_json(for_json, *a)
114
- end
97
+ def to_json(*a)
98
+ Megam::JSONCompat.to_json(for_json, *a)
99
+ end
115
100
 
116
- def self.json_create(o)
117
- collection = self.new()
118
- o["results"].each do |eventsvm_list|
119
- eventsvm_array = eventsvm_list.kind_of?(Array) ? eventsvm_list : [ eventsvm_list ]
120
- eventsvm_array.each do |eventsvm|
121
- collection.insert(eventsvm)
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
- private
113
+ private
129
114
 
130
- def is_megam_eventsvm(arg)
131
- unless arg.kind_of?(Megam::EventsVm)
132
- raise ArgumentError, "Members must be Megam::EventsVm's"
133
- end
134
- true
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
 
@@ -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
 
@@ -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
- class MarketPlace < Megam::RestAdapter
20
- def initialize(o)
21
- @id = nil
22
- @settings_name = nil
23
- @cattype = nil
24
- @flavor = nil
25
- @image = nil
26
- @catorder = nil
27
- @url = nil
28
- @envs = []
29
- @options = []
30
- @plans = nil
31
- @created_at = nil
32
- super(o)
33
- end
34
-
35
- def market_place
36
- self
37
- end
38
-
39
- def settings_name(arg = nil)
40
- if !arg.nil?
41
- @settings_name = arg
42
- else
43
- @settings_name
44
- end
45
- end
46
-
47
- def id(arg = nil)
48
- if !arg.nil?
49
- @id = arg
50
- else
51
- @id
52
- end
53
- end
54
-
55
- def plans(arg = nil)
56
- if !arg.nil?
57
- @plans = arg
58
- else
59
- @plans
60
- end
61
- end
62
-
63
- def cattype(arg = nil)
64
- if !arg.nil?
65
- @cattype = arg
66
- else
67
- @cattype
68
- end
69
- end
70
-
71
- def flavor(arg = nil)
72
- if !arg.nil?
73
- @flavor = arg
74
- else
75
- @flavor
76
- end
77
- end
78
-
79
- def catorder(arg = nil)
80
- if !arg.nil?
81
- @catorder = arg
82
- else
83
- @catorder
84
- end
85
- end
86
-
87
- def image(arg = nil)
88
- if !arg.nil?
89
- @image = arg
90
- else
91
- @image
92
- end
93
- end
94
-
95
- def url(arg = nil)
96
- if !arg.nil?
97
- @url = arg
98
- else
99
- @url
100
- end
101
- end
102
-
103
- def envs(arg = [])
104
- if arg != []
105
- @envs = arg
106
- else
107
- @envs
108
- end
109
- end
110
-
111
- def options(arg = [])
112
- if arg != []
113
- @options = arg
114
- else
115
- @options
116
- end
117
- end
118
-
119
- def created_at(arg = nil)
120
- if !arg.nil?
121
- @created_at = arg
122
- else
123
- @created_at
124
- end
125
- end
126
-
127
- def some_msg(arg = nil)
128
- if !arg.nil?
129
- @some_msg = arg
130
- else
131
- @some_msg
132
- end
133
- end
134
-
135
- def error?
136
- crocked = true if some_msg.key?(:msg_type) && some_msg[:msg_type] == 'error'
137
- end
138
-
139
- # Transform the ruby obj -> to a Hash
140
- def to_hash
141
- index_hash = {}
142
- index_hash['json_claz'] = self.class.name
143
- index_hash['id'] = id
144
- index_hash['settings_name'] = settings_name
145
- index_hash['cattype'] = cattype
146
- index_hash['flavor'] = flavor
147
- index_hash['image'] = image
148
- index_hash['catorder'] = catorder
149
- index_hash['url'] = url
150
- index_hash['envs'] = envs
151
- index_hash['options'] = options
152
- index_hash['plans'] = plans
153
- index_hash['created_at'] = created_at
154
- index_hash
155
- end
156
-
157
- # Serialize this object as a hash: called from JsonCompat.
158
- # Verify if this called from JsonCompat during testing.
159
- def to_json(*a)
160
- for_json.to_json(*a)
161
- end
162
-
163
- def for_json
164
- result = {
165
- 'id' => id,
166
- 'settings_name' => settings_name,
167
- 'cattype' => cattype,
168
- 'flavor' => flavor,
169
- 'image' => image,
170
- 'catorder' => catorder,
171
- 'url' => url,
172
- 'envs' => envs,
173
- 'options' => options,
174
- 'plans' => plans,
175
- 'created_at' => created_at
176
- }
177
- result
178
- end
179
-
180
- def self.json_create(o)
181
- app = new({})
182
- app.id(o['id']) if o.key?('id')
183
- app.settings_name(o['settings_name']) if o.key?('settings_name')
184
- app.cattype(o['cattype']) if o.key?('cattype')
185
- app.flavor(o['flavor']) if o.key?('flavor')
186
- app.image(o['image']) if o.key?('image')
187
- app.catorder(o['catorder']) if o.key?('catorder')
188
- app.url(o['url']) if o.key?('url')
189
- app.envs(o['envs']) if o.key?('envs')
190
- app.options(o['options']) if o.key?('options')
191
- app.plans(o['plans']) if o.key?('plans')
192
- app.created_at(o['created_at']) if o.key?('created_at')
193
-
194
- app
195
- end
196
-
197
- def self.from_hash(o)
198
- app = new(o)
199
- app.from_hash(o)
200
- app
201
- end
202
-
203
- def from_hash(o)
204
- @settings_name = o['settings_name'] if o.key?('settings_name')
205
- @id = o['id'] if o.key?('id')
206
- @cattype = o['cattype'] if o.key?('cattype')
207
- @flavor = o['flavor'] if o.key?('flavor')
208
- @image = o['image'] if o.key?('image')
209
- @catorder = o['catorder'] if o.key?('catorder')
210
- @url = o['url'] if o.key?('url')
211
- @envs = o['envs'] if o.key?('envs')
212
- @options = o['options'] if o.key?('options')
213
- @plans = o['plans'] if o.key?('plans')
214
- @created_at = o['created_at'] if o.key?('created_at')
215
- self
216
- end
217
-
218
- def self.create(params)
219
- acct = from_hash(params)
220
- acct.create
221
- end
222
-
223
- # Create the marketplace app via the REST API
224
- def create
225
- megam_rest.post_marketplaceapp(to_hash)
226
- end
227
-
228
- # Load a account by email_p
229
- def self.show(params)
230
- app = new(params)
231
- app.megam_rest.get_marketplaceapp(params['id'])
232
- end
233
-
234
- def self.list(params)
235
- app = new(params)
236
- app.megam_rest.get_marketplaceapps
237
- end
238
-
239
- def to_s
240
- Megam::Stuff.styled_hash(to_hash)
241
- # "---> Megam::Account:[error=#{error?}]\n"+
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