megam_api 0.66 → 0.67
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/lib/megam/api.rb +1 -7
- data/lib/megam/api/version.rb +1 -1
- data/lib/megam/core/json_compat.rb +0 -12
- data/lib/megam/core/request.rb +31 -2
- data/test/test_requests.rb +14 -3
- metadata +2 -8
- data/lib/megam/api/cat_requests.rb +0 -16
- data/lib/megam/api/predef_clouds.rb +0 -45
- data/lib/megam/core/cat_requests.rb +0 -193
- data/lib/megam/core/cat_requests_collection.rb +0 -145
- data/lib/megam/core/predefcloud.rb +0 -234
- data/lib/megam/core/predefcloud_collection.rb +0 -168
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e00bb71803aef7d8bdb70e6bd34bb3905063198
|
4
|
+
data.tar.gz: 8c3ffaf027aef6644cda60ba0b3c5d5d80a78912
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30100983eb3bb08b74fb597e38930d0fbd065cdcf892094ca21e80b5c2d13daf69c9c79c49df9634cbceee8663e7942d4b2ada17330ca8bbf3fb887bf159c7d9
|
7
|
+
data.tar.gz: acca1e4576c358f672f1275064329a0500203e2f7792391db72cea1203d78c789609ba8fbbbd271cb371dfc4f0a0b693b81b0f94966ef14f657b70f0f7f4d6e1
|
data/lib/megam/api.rb
CHANGED
@@ -14,8 +14,6 @@ require 'megam/api/errors'
|
|
14
14
|
require 'megam/api/version'
|
15
15
|
require 'megam/api/accounts'
|
16
16
|
require 'megam/api/requests'
|
17
|
-
require 'megam/api/cat_requests'
|
18
|
-
require 'megam/api/predef_clouds'
|
19
17
|
require 'megam/api/cloud_tool_settings'
|
20
18
|
require 'megam/api/sshkeys'
|
21
19
|
require 'megam/api/marketplaces'
|
@@ -47,8 +45,6 @@ require 'megam/core/error'
|
|
47
45
|
require 'megam/core/account'
|
48
46
|
require 'megam/core/request'
|
49
47
|
require 'megam/core/request_collection'
|
50
|
-
require 'megam/core/predefcloud'
|
51
|
-
require 'megam/core/predefcloud_collection'
|
52
48
|
require 'megam/core/cloudtoolsetting'
|
53
49
|
require 'megam/core/cloudtoolsetting_collection'
|
54
50
|
require 'megam/core/sshkey'
|
@@ -69,8 +65,6 @@ require 'megam/core/assembly'
|
|
69
65
|
require 'megam/core/assembly_collection'
|
70
66
|
require 'megam/core/components'
|
71
67
|
require 'megam/core/components_collection'
|
72
|
-
require 'megam/core/cat_requests'
|
73
|
-
require 'megam/core/cat_requests_collection'
|
74
68
|
require 'megam/core/event'
|
75
69
|
|
76
70
|
require 'megam/core/availableunits_collection'
|
@@ -129,7 +123,7 @@ module Megam
|
|
129
123
|
# 2. The options as passed via the instantiation of API will override global options. The ones that are passed are :email and :api_key and will
|
130
124
|
# be merged into a class variable @options
|
131
125
|
# 3. Upon merge of the options, the api_key, email as available in the @options is deleted.
|
132
|
-
def initialize(options = {})
|
126
|
+
def initialize(options = {})
|
133
127
|
@options = OPTIONS.merge(options)
|
134
128
|
puts @options
|
135
129
|
@api_key = @options.delete(:api_key) || ENV['MEGAM_API_KEY']
|
data/lib/megam/api/version.rb
CHANGED
@@ -36,8 +36,6 @@ module Megam
|
|
36
36
|
MEGAM_BILLINGHISTORIESCOLLECTION = "Megam::BillinghistoriesCollection".freeze
|
37
37
|
MEGAM_BILLINGS = "Megam::Billings".freeze
|
38
38
|
MEGAM_BILLINGSCOLLECTION = "Megam::BillingsCollection".freeze
|
39
|
-
MEGAM_CATREQUESTS = "Megam::CatRequests".freeze
|
40
|
-
MEGAM_CATREQUESTSCOLLECTION = "Megam::CatRequestsCollection".freeze
|
41
39
|
MEGAM_CLOUDTOOLSETTING = "Megam::CloudToolSetting".freeze
|
42
40
|
MEGAM_CLOUDTOOLSETTINGCOLLECTION = "Megam::CloudToolSettingCollection".freeze
|
43
41
|
MEGAM_COMPONENTS = "Megam::Components".freeze
|
@@ -57,8 +55,6 @@ module Megam
|
|
57
55
|
MEGAM_MARKETPLACEADDONCOLLECTION = "Megam::MarketPlaceAddonsCollection".freeze
|
58
56
|
MEGAM_ORGANIZATION = "Megam::Organizations".freeze
|
59
57
|
MEGAM_ORGANIZATIONSCOLLECTION = "Megam::OrganizationsCollection".freeze
|
60
|
-
MEGAM_PREDEFCLOUD = "Megam::PredefCloud".freeze
|
61
|
-
MEGAM_PREDEFCLOUDCOLLECTION = "Megam::PredefCloudCollection".freeze
|
62
58
|
MEGAM_REQUEST = "Megam::Request".freeze
|
63
59
|
MEGAM_REQUESTCOLLECTION = "Megam::RequestCollection".freeze
|
64
60
|
MEGAM_SSHKEY = "Megam::SshKey".freeze
|
@@ -166,10 +162,6 @@ module Megam
|
|
166
162
|
Megam::Request
|
167
163
|
when MEGAM_REQUESTCOLLECTION
|
168
164
|
Megam::RequestCollection
|
169
|
-
when MEGAM_PREDEFCLOUD
|
170
|
-
Megam::PredefCloud
|
171
|
-
when MEGAM_PREDEFCLOUDCOLLECTION
|
172
|
-
Megam::PredefCloudCollection
|
173
165
|
when MEGAM_SSHKEY
|
174
166
|
Megam::SshKey
|
175
167
|
when MEGAM_SSHKEYCOLLECTION
|
@@ -192,10 +184,6 @@ module Megam
|
|
192
184
|
Megam::CSARCollection
|
193
185
|
when MEGAM_DOMAIN
|
194
186
|
Megam::Domains
|
195
|
-
when MEGAM_CATREQUESTS
|
196
|
-
Megam::CatRequests
|
197
|
-
when MEGAM_CATREQUESTSCOLLECTION
|
198
|
-
Megam::CatRequestsCollection
|
199
187
|
when MEGAM_EVENT
|
200
188
|
Megam::Event
|
201
189
|
when MEGAM_AVAILABLEUNITS
|
data/lib/megam/core/request.rb
CHANGED
@@ -21,6 +21,8 @@ module Megam
|
|
21
21
|
@name = nil
|
22
22
|
@cattype = nil
|
23
23
|
@command =nil
|
24
|
+
@action = nil
|
25
|
+
@category = nil
|
24
26
|
@some_msg = {}
|
25
27
|
@created_at = nil
|
26
28
|
super(email, api_key, host)
|
@@ -30,7 +32,7 @@ module Megam
|
|
30
32
|
self
|
31
33
|
end
|
32
34
|
|
33
|
-
|
35
|
+
|
34
36
|
def id(arg=nil)
|
35
37
|
if arg != nil
|
36
38
|
@id = arg
|
@@ -61,6 +63,25 @@ module Megam
|
|
61
63
|
@cattype
|
62
64
|
end
|
63
65
|
end
|
66
|
+
|
67
|
+
def action(arg=nil)
|
68
|
+
if arg != nil
|
69
|
+
@action = arg
|
70
|
+
else
|
71
|
+
@action
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
def category(arg=nil)
|
77
|
+
if arg != nil
|
78
|
+
@category = arg
|
79
|
+
else
|
80
|
+
@category
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
|
64
85
|
def created_at(arg=nil)
|
65
86
|
if arg != nil
|
66
87
|
@created_at = arg
|
@@ -97,6 +118,8 @@ module Megam
|
|
97
118
|
index_hash["cat_id"] = cat_id
|
98
119
|
index_hash["name"] = name
|
99
120
|
index_hash["cattype"] = cattype
|
121
|
+
index_hash["action"] = action
|
122
|
+
index_hash["category"] = category
|
100
123
|
index_hash["command"] = command
|
101
124
|
index_hash["created_at"] = created_at
|
102
125
|
index_hash
|
@@ -114,6 +137,8 @@ module Megam
|
|
114
137
|
"cat_id" => cat_id,
|
115
138
|
"name" => name,
|
116
139
|
"cattype" => cattype,
|
140
|
+
"action" => action,
|
141
|
+
"category" => category,
|
117
142
|
"command" => command,
|
118
143
|
"created_at" => created_at
|
119
144
|
}
|
@@ -127,6 +152,8 @@ module Megam
|
|
127
152
|
node.cat_id(o["cat_id"]) if o.has_key?("cat_id")
|
128
153
|
node.name(o["name"]) if o.has_key?("name")
|
129
154
|
node.cattype(o["cattype"]) if o.has_key?("cattype")
|
155
|
+
node.action(o["action"]) if o.has_key?("action")
|
156
|
+
node.category(o["category"]) if o.has_key?("category")
|
130
157
|
node.command(o["command"]) if o.has_key?("command")
|
131
158
|
node.created_at(o["created_at"]) if o.has_key?("created_at")
|
132
159
|
#success or error
|
@@ -148,6 +175,8 @@ module Megam
|
|
148
175
|
@cat_id = o[:cat_id] if o.has_key?(:cat_id)
|
149
176
|
@name = o[:name] if o.has_key?(:name)
|
150
177
|
@cattype = o[:cattype] if o.has_key?(:cattype)
|
178
|
+
@action = o[:action] if o.has_key?(:action)
|
179
|
+
@category = o[:category] if o.has_key?(:category)
|
151
180
|
@command = o[:command] if o.has_key?(:command)
|
152
181
|
@created_at = o[:created_at] if o.has_key?(:created_at)
|
153
182
|
self
|
@@ -166,7 +195,7 @@ module Megam
|
|
166
195
|
megam_rest.post_request(to_hash)
|
167
196
|
end
|
168
197
|
|
169
|
-
|
198
|
+
|
170
199
|
def self.show(params)
|
171
200
|
prede = self.new(params["email"] || params[:email], params["api_key"] || params[:api_key], params["host"] || params[:host])
|
172
201
|
prede.megam_rest.get_requests
|
data/test/test_requests.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require File.expand_path("#{File.dirname(__FILE__)}/test_helper")
|
2
2
|
|
3
3
|
class TestApps < MiniTest::Unit::TestCase
|
4
|
-
|
4
|
+
=begin
|
5
5
|
def test_get_requests
|
6
6
|
response = megams.get_requests
|
7
7
|
assert_equal(200, response.status)
|
@@ -66,19 +66,30 @@ class TestApps < MiniTest::Unit::TestCase
|
|
66
66
|
"appreq" => {},
|
67
67
|
"boltreq" => {}
|
68
68
|
}
|
69
|
+
=end
|
70
|
+
|
71
|
+
@@tmp_hash = {
|
72
|
+
|
73
|
+
"cat_id" => "ASM",
|
74
|
+
"cattype" => "app",
|
75
|
+
"name" => "yeshapp",
|
76
|
+
"action" => "delete",
|
77
|
+
"category" => "normal" #normal(create, delete), state, control, policy
|
78
|
+
}
|
79
|
+
|
69
80
|
|
70
81
|
def test_request_node_delete
|
71
82
|
|
72
83
|
response = megams.post_request(@@tmp_hash)
|
73
84
|
assert_equal(201, response.status)
|
74
85
|
end
|
75
|
-
|
86
|
+
=begin
|
76
87
|
def test_request_node_stop
|
77
88
|
@@tmp_hash["req_type"] = "stop"
|
78
89
|
@@tmp_hash["command"]["cloudtool"]["chef"]["plugin"] = "ec2 server stop"
|
79
90
|
response = megams.post_request(@@tmp_hash)
|
80
91
|
assert_equal(201, response.status)
|
81
92
|
end
|
82
|
-
|
93
|
+
=end
|
83
94
|
|
84
95
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: megam_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.67'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rajthilak, Kishorekumar Neelamegam, Thomas Alrin, Yeshwanth Kumar, Subash Sethurajan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: excon
|
@@ -137,7 +137,6 @@ files:
|
|
137
137
|
- lib/megam/api/balances.rb
|
138
138
|
- lib/megam/api/billinghistories.rb
|
139
139
|
- lib/megam/api/billings.rb
|
140
|
-
- lib/megam/api/cat_requests.rb
|
141
140
|
- lib/megam/api/cloud_tool_settings.rb
|
142
141
|
- lib/megam/api/components.rb
|
143
142
|
- lib/megam/api/credithistories.rb
|
@@ -150,7 +149,6 @@ files:
|
|
150
149
|
- lib/megam/api/marketplace_addons.rb
|
151
150
|
- lib/megam/api/marketplaces.rb
|
152
151
|
- lib/megam/api/organizations.rb
|
153
|
-
- lib/megam/api/predef_clouds.rb
|
154
152
|
- lib/megam/api/promos.rb
|
155
153
|
- lib/megam/api/requests.rb
|
156
154
|
- lib/megam/api/sshkeys.rb
|
@@ -170,8 +168,6 @@ files:
|
|
170
168
|
- lib/megam/core/billinghistories_collection.rb
|
171
169
|
- lib/megam/core/billings.rb
|
172
170
|
- lib/megam/core/billings_collection.rb
|
173
|
-
- lib/megam/core/cat_requests.rb
|
174
|
-
- lib/megam/core/cat_requests_collection.rb
|
175
171
|
- lib/megam/core/cloudtoolsetting.rb
|
176
172
|
- lib/megam/core/cloudtoolsetting_collection.rb
|
177
173
|
- lib/megam/core/components.rb
|
@@ -196,8 +192,6 @@ files:
|
|
196
192
|
- lib/megam/core/monologger.rb
|
197
193
|
- lib/megam/core/organizations.rb
|
198
194
|
- lib/megam/core/organizations_collection.rb
|
199
|
-
- lib/megam/core/predefcloud.rb
|
200
|
-
- lib/megam/core/predefcloud_collection.rb
|
201
195
|
- lib/megam/core/promos.rb
|
202
196
|
- lib/megam/core/request.rb
|
203
197
|
- lib/megam/core/request_collection.rb
|
@@ -1,16 +0,0 @@
|
|
1
|
-
module Megam
|
2
|
-
class API
|
3
|
-
|
4
|
-
def post_catrequest(new_req)
|
5
|
-
@options = {:path => '/catrequests/content',
|
6
|
-
:body => Megam::JSONCompat.to_json(new_req)}.merge(@options)
|
7
|
-
|
8
|
-
request(
|
9
|
-
:expects => 201,
|
10
|
-
:method => :post,
|
11
|
-
:body => @options[:body]
|
12
|
-
)
|
13
|
-
end
|
14
|
-
|
15
|
-
end
|
16
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
module Megam
|
2
|
-
class API
|
3
|
-
def get_predefclouds
|
4
|
-
@options = {:path => '/predefclouds',:body => ""}.merge(@options)
|
5
|
-
|
6
|
-
request(
|
7
|
-
:expects => 200,
|
8
|
-
:method => :get,
|
9
|
-
:body => @options[:body]
|
10
|
-
)
|
11
|
-
end
|
12
|
-
|
13
|
-
def get_predefcloud(predefcloud_name)
|
14
|
-
@options = {:path => "/predefclouds/#{predefcloud_name}",:body => ""}.merge(@options)
|
15
|
-
|
16
|
-
request(
|
17
|
-
:expects => 200,
|
18
|
-
:method => :get,
|
19
|
-
:body => @options[:body]
|
20
|
-
)
|
21
|
-
end
|
22
|
-
|
23
|
-
def delete_predefcloud(predefcloud_name)
|
24
|
-
@options = {:path => "/predefclouds/#{predefcloud_name}",:body => ""}.merge(@options)
|
25
|
-
|
26
|
-
request(
|
27
|
-
:expects => 200,
|
28
|
-
:method => :delete,
|
29
|
-
:body => @options[:body]
|
30
|
-
)
|
31
|
-
end
|
32
|
-
|
33
|
-
def post_predefcloud(new_predefcloud)
|
34
|
-
@options = {:path => '/predefclouds/content',
|
35
|
-
:body => Megam::JSONCompat.to_json(new_predefcloud)}.merge(@options)
|
36
|
-
|
37
|
-
request(
|
38
|
-
:expects => 201,
|
39
|
-
:method => :post,
|
40
|
-
:body => @options[:body]
|
41
|
-
)
|
42
|
-
end
|
43
|
-
|
44
|
-
end
|
45
|
-
end
|
@@ -1,193 +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 CatRequests < Megam::ServerAPI
|
18
|
-
|
19
|
-
def initialize(email=nil, api_key=nil, host=nil)
|
20
|
-
@id = nil
|
21
|
-
@cat_id = nil
|
22
|
-
@cattype = nil
|
23
|
-
@name = nil
|
24
|
-
@action = nil
|
25
|
-
@category = nil
|
26
|
-
@some_msg = {}
|
27
|
-
@created_at = nil
|
28
|
-
super(email, api_key, host)
|
29
|
-
end
|
30
|
-
|
31
|
-
def cat_request
|
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 cat_id(arg=nil)
|
45
|
-
if arg != nil
|
46
|
-
@cat_id = arg
|
47
|
-
else
|
48
|
-
@cat_id
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
|
53
|
-
def cattype(arg=nil)
|
54
|
-
if arg != nil
|
55
|
-
@cattype = arg
|
56
|
-
else
|
57
|
-
@cattype
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
|
62
|
-
def name(arg=nil)
|
63
|
-
if arg != nil
|
64
|
-
@name = arg
|
65
|
-
else
|
66
|
-
@name
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
def action(arg=nil)
|
71
|
-
if arg != nil
|
72
|
-
@action = arg
|
73
|
-
else
|
74
|
-
@action
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
def category(arg=nil)
|
79
|
-
if arg != nil
|
80
|
-
@category = arg
|
81
|
-
else
|
82
|
-
@category
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
def created_at(arg=nil)
|
89
|
-
if arg != nil
|
90
|
-
@created_at = arg
|
91
|
-
else
|
92
|
-
@created_at
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
def some_msg(arg=nil)
|
97
|
-
if arg != nil
|
98
|
-
@some_msg = arg
|
99
|
-
else
|
100
|
-
@some_msg
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
def error?
|
105
|
-
crocked = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error")
|
106
|
-
end
|
107
|
-
|
108
|
-
# Transform the ruby obj -> to a Hash
|
109
|
-
def to_hash
|
110
|
-
index_hash = Hash.new
|
111
|
-
index_hash["json_claz"] = self.class.name
|
112
|
-
index_hash["id"] = id
|
113
|
-
index_hash["cat_id"] = cat_id
|
114
|
-
index_hash["cattype"] = cattype
|
115
|
-
index_hash["name"] = name
|
116
|
-
index_hash["action"] = action
|
117
|
-
index_hash["category"] = category
|
118
|
-
index_hash["created_at"] = created_at
|
119
|
-
index_hash
|
120
|
-
end
|
121
|
-
|
122
|
-
# Serialize this object as a hash: called from JsonCompat.
|
123
|
-
# Verify if this called from JsonCompat during testing.
|
124
|
-
def to_json(*a)
|
125
|
-
for_json.to_json(*a)
|
126
|
-
end
|
127
|
-
|
128
|
-
def for_json
|
129
|
-
result = {
|
130
|
-
"id" => id,
|
131
|
-
"cat_id" => cat_id,
|
132
|
-
"cattype" => cattype,
|
133
|
-
"name" => name,
|
134
|
-
"action" => action,
|
135
|
-
"category" => category,
|
136
|
-
"created_at" => created_at
|
137
|
-
}
|
138
|
-
result
|
139
|
-
end
|
140
|
-
|
141
|
-
#
|
142
|
-
def self.json_create(o)
|
143
|
-
node = new
|
144
|
-
node.id(o["id"]) if o.has_key?("id")
|
145
|
-
node.cat_id(o["cat_id"]) if o.has_key?("cat_id")
|
146
|
-
node.cattype(o["cattype"]) if o.has_key?("cattype")
|
147
|
-
node.name(o["name"]) if o.has_key?("name")
|
148
|
-
node.action(o["action"]) if o.has_key?("action")
|
149
|
-
node.action(o["category"]) if o.has_key?("category")
|
150
|
-
node.created_at(o["created_at"]) if o.has_key?("created_at")
|
151
|
-
#success or error
|
152
|
-
node.some_msg[:code] = o["code"] if o.has_key?("code")
|
153
|
-
node.some_msg[:msg_type] = o["msg_type"] if o.has_key?("msg_type")
|
154
|
-
node.some_msg[:msg]= o["msg"] if o.has_key?("msg")
|
155
|
-
node.some_msg[:links] = o["links"] if o.has_key?("links")
|
156
|
-
node
|
157
|
-
end
|
158
|
-
|
159
|
-
def self.from_hash(o,tmp_email=nil, tmp_api_key=nil, tmp_host=nil)
|
160
|
-
node = self.new(tmp_email, tmp_api_key, tmp_host)
|
161
|
-
node.from_hash(o)
|
162
|
-
node
|
163
|
-
end
|
164
|
-
|
165
|
-
def from_hash(o)
|
166
|
-
@id = o[:id] if o.has_key?(:id)
|
167
|
-
@cat_id = o[:cat_id] if o.has_key?(:cat_id)
|
168
|
-
@cattype = o[:cattype] if o.has_key?(:cattype)
|
169
|
-
@name = o[:name] if o.has_key?(:name)
|
170
|
-
@action = o[:action] if o.has_key?(:action)
|
171
|
-
@category = o[:category] if o.has_key?(:category)
|
172
|
-
@created_at = o[:created_at] if o.has_key?(:created_at)
|
173
|
-
self
|
174
|
-
end
|
175
|
-
|
176
|
-
|
177
|
-
def self.create(o)
|
178
|
-
acct = from_hash(o, o["email"], o["api_key"], o["host"])
|
179
|
-
acct.create
|
180
|
-
end
|
181
|
-
|
182
|
-
# Create the node via the REST API
|
183
|
-
def create
|
184
|
-
megam_rest.post_catrequest(to_hash)
|
185
|
-
end
|
186
|
-
|
187
|
-
|
188
|
-
def to_s
|
189
|
-
Megam::Stuff.styled_hash(to_hash)
|
190
|
-
end
|
191
|
-
|
192
|
-
end
|
193
|
-
end
|
@@ -1,145 +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 CatRequestsCollection
|
18
|
-
include Enumerable
|
19
|
-
|
20
|
-
attr_reader :iterator
|
21
|
-
def initialize
|
22
|
-
@catrequests = Array.new
|
23
|
-
@catrequests_by_name = Hash.new
|
24
|
-
@insert_after_idx = nil
|
25
|
-
end
|
26
|
-
|
27
|
-
def all_requests
|
28
|
-
@catrequests
|
29
|
-
end
|
30
|
-
|
31
|
-
def [](index)
|
32
|
-
@catrequests[index]
|
33
|
-
end
|
34
|
-
|
35
|
-
def []=(index, arg)
|
36
|
-
is_megam_request(arg)
|
37
|
-
@catrequests[index] = arg
|
38
|
-
@catrequests_by_name[arg.cat_id] = index
|
39
|
-
end
|
40
|
-
|
41
|
-
def <<(*args)
|
42
|
-
args.flatten.each do |a|
|
43
|
-
is_megam_request(a)
|
44
|
-
@catrequests << a
|
45
|
-
@catrequests_by_name[a.cat_id] = @catrequests.length - 1
|
46
|
-
end
|
47
|
-
self
|
48
|
-
end
|
49
|
-
|
50
|
-
# 'push' is an alias method to <<
|
51
|
-
alias_method :push, :<<
|
52
|
-
|
53
|
-
def insert(request)
|
54
|
-
is_megam_request(request)
|
55
|
-
if @insert_after_idx
|
56
|
-
# in the middle of executing a run, so any requests inserted now should
|
57
|
-
# be placed after the most recent addition done by the currently executing
|
58
|
-
# request
|
59
|
-
@catrequests.insert(@insert_after_idx + 1, request)
|
60
|
-
# update name -> location mappings and register new request
|
61
|
-
@catrequests_by_name.each_key do |key|
|
62
|
-
@catrequests_by_name[key] += 1 if @catrequests_by_name[key] > @insert_after_idx
|
63
|
-
end
|
64
|
-
@catrequests_by_name[request.cat_id] = @insert_after_idx + 1
|
65
|
-
@insert_after_idx += 1
|
66
|
-
else
|
67
|
-
@catrequests << request
|
68
|
-
@catrequests_by_name[request.cat_id] = @catrequests.length - 1
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
def each
|
73
|
-
@catrequests.each do |request|
|
74
|
-
yield request
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
def each_index
|
79
|
-
@catrequests.each_index do |i|
|
80
|
-
yield i
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
def empty?
|
85
|
-
@catrequests.empty?
|
86
|
-
end
|
87
|
-
|
88
|
-
def lookup(request)
|
89
|
-
lookup_by = nil
|
90
|
-
if request.kind_of?(Megam::CatRequests)
|
91
|
-
lookup_by = request.cat_id
|
92
|
-
elsif request.kind_of?(String)
|
93
|
-
lookup_by = request
|
94
|
-
else
|
95
|
-
raise ArgumentError, "Must pass a Megam::CatRequests or String to lookup"
|
96
|
-
end
|
97
|
-
res = @catrequests_by_name[lookup_by]
|
98
|
-
unless res
|
99
|
-
raise ArgumentError, "Cannot find a request matching #{lookup_by} (did you define it first?)"
|
100
|
-
end
|
101
|
-
@catrequests[res]
|
102
|
-
end
|
103
|
-
|
104
|
-
# Transform the ruby obj -> to a Hash
|
105
|
-
def to_hash
|
106
|
-
index_hash = Hash.new
|
107
|
-
self.each do |request|
|
108
|
-
index_hash[request.cat_id] = request.to_s
|
109
|
-
end
|
110
|
-
index_hash
|
111
|
-
end
|
112
|
-
|
113
|
-
# Serialize this object as a hash: called from JsonCompat.
|
114
|
-
# Verify if this called from JsonCompat during testing.
|
115
|
-
def to_json(*a)
|
116
|
-
for_json.to_json(*a)
|
117
|
-
end
|
118
|
-
|
119
|
-
|
120
|
-
def self.json_create(o)
|
121
|
-
collection = self.new()
|
122
|
-
o["results"].each do |requests_list|
|
123
|
-
requests_array = requests_list.kind_of?(Array) ? requests_list : [ requests_list ]
|
124
|
-
requests_array.each do |request|
|
125
|
-
collection.insert(request)
|
126
|
-
end
|
127
|
-
end
|
128
|
-
collection
|
129
|
-
end
|
130
|
-
|
131
|
-
private
|
132
|
-
|
133
|
-
def is_megam_request(arg)
|
134
|
-
unless arg.kind_of?(Megam::CatRequests)
|
135
|
-
raise ArgumentError, "Members must be Megam::CatRequests's"
|
136
|
-
end
|
137
|
-
true
|
138
|
-
end
|
139
|
-
|
140
|
-
def to_s
|
141
|
-
Megam::Stuff.styled_hash(to_hash)
|
142
|
-
end
|
143
|
-
|
144
|
-
end
|
145
|
-
end
|
@@ -1,234 +0,0 @@
|
|
1
|
-
|
2
|
-
# Copyright:: Copyright (c) 2012, 2014 Megam Systems
|
3
|
-
# License:: Apache License, Version 2.0
|
4
|
-
#
|
5
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
-
# you may not use this file except in compliance with the License.
|
7
|
-
# You may obtain a copy of the License at
|
8
|
-
#
|
9
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
#
|
11
|
-
# Unless required by applicable law or agreed to in writing, software
|
12
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
-
# See the License for the specific language governing permissions and
|
15
|
-
# limitations under the License.
|
16
|
-
#
|
17
|
-
module Megam
|
18
|
-
class PredefCloud < Megam::ServerAPI
|
19
|
-
def initialize(email=nil, api_key=nil, host=nil)
|
20
|
-
@id = nil
|
21
|
-
@name = nil
|
22
|
-
@accounts_id = nil
|
23
|
-
@spec = {}
|
24
|
-
@access = {}
|
25
|
-
#@ideal=nil
|
26
|
-
#@performance = nil
|
27
|
-
@created_at = nil
|
28
|
-
@some_msg = {}
|
29
|
-
super(email, api_key, host)
|
30
|
-
end
|
31
|
-
|
32
|
-
def predef_cloud
|
33
|
-
self
|
34
|
-
end
|
35
|
-
|
36
|
-
|
37
|
-
def id(arg=nil)
|
38
|
-
if arg != nil
|
39
|
-
@id = arg
|
40
|
-
else
|
41
|
-
@id
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def name(arg=nil)
|
46
|
-
if arg != nil
|
47
|
-
@name = arg
|
48
|
-
else
|
49
|
-
@name
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def accounts_id(arg=nil)
|
54
|
-
if arg != nil
|
55
|
-
@accounts_id= arg
|
56
|
-
else
|
57
|
-
@accounts_id
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
def spec(arg=nil)
|
62
|
-
if arg != nil
|
63
|
-
@spec = arg
|
64
|
-
else
|
65
|
-
@spec
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
def access(arg=nil)
|
70
|
-
if arg != nil
|
71
|
-
@access = arg
|
72
|
-
else
|
73
|
-
@access
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def ideal(arg=nil)
|
78
|
-
if arg != nil
|
79
|
-
@ideal= arg
|
80
|
-
else
|
81
|
-
@ideal
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
def performance(arg=nil)
|
86
|
-
if arg != nil
|
87
|
-
@performance= arg
|
88
|
-
else
|
89
|
-
@performance
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
def created_at(arg=nil)
|
94
|
-
if arg != nil
|
95
|
-
@created_at = arg
|
96
|
-
else
|
97
|
-
@created_at
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
def some_msg(arg=nil)
|
102
|
-
if arg != nil
|
103
|
-
@some_msg = arg
|
104
|
-
else
|
105
|
-
@some_msg
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
def error?
|
110
|
-
crocked = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error")
|
111
|
-
end
|
112
|
-
|
113
|
-
# Transform the ruby obj -> to a Hash
|
114
|
-
def to_hash
|
115
|
-
index_hash = Hash.new
|
116
|
-
index_hash["json_claz"] = self.class.name
|
117
|
-
index_hash["id"] = id
|
118
|
-
index_hash["name"] = name
|
119
|
-
index_hash["accounts_id"] = accounts_id
|
120
|
-
index_hash["spec"] = spec
|
121
|
-
index_hash["access"] = access
|
122
|
-
# index_hash["ideal"] = ideal
|
123
|
-
# index_hash["performance"] = performance
|
124
|
-
index_hash["created_at"] = created_at
|
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
|
-
"name" => name,
|
138
|
-
"accounts_id" => accounts_id,
|
139
|
-
"spec" => spec,
|
140
|
-
"access" => access,
|
141
|
-
# "ideal" => ideal,
|
142
|
-
# "performance" => performance,
|
143
|
-
"created_at" => created_at
|
144
|
-
}
|
145
|
-
result
|
146
|
-
end
|
147
|
-
|
148
|
-
#
|
149
|
-
def self.json_create(o)
|
150
|
-
predefcd = new
|
151
|
-
predefcd.id(o["id"]) if o.has_key?("id")
|
152
|
-
predefcd.name(o["name"]) if o.has_key?("name")
|
153
|
-
#requests
|
154
|
-
oq = o["spec"]
|
155
|
-
predefcd.spec[:type_name] = oq["type_name"] if oq && oq.has_key?("type_name")
|
156
|
-
predefcd.spec[:groups] = oq["groups"] if oq && oq.has_key?("groups")
|
157
|
-
predefcd.spec[:image] = oq["image"] if oq && oq.has_key?("image")
|
158
|
-
predefcd.spec[:flavor] = oq["flavor"] if oq && oq.has_key?("flavor")
|
159
|
-
predefcd.spec[:tenant_id] = oq["tenant_id"] if oq && oq.has_key?("tenant_id")
|
160
|
-
#predef
|
161
|
-
op = o["access"]
|
162
|
-
predefcd.access[:ssh_key] = op["ssh_key"] if op && op.has_key?("ssh_key")
|
163
|
-
predefcd.access[:identity_file] = op["identity_file"] if op && op.has_key?("identity_file")
|
164
|
-
predefcd.access[:ssh_user]= op["ssh_user"] if op && op.has_key?("ssh_user")
|
165
|
-
predefcd.access[:vault_location]= op["vault_location"] if op && op.has_key?("vault_location")
|
166
|
-
predefcd.access[:sshpub_location]= op["sshpub_location"] if op && op.has_key?("sshpub_location")
|
167
|
-
predefcd.access[:zone]= op["zone"] if op && op.has_key?("zone")
|
168
|
-
predefcd.access[:region]= op["region"] if op && op.has_key?("region")
|
169
|
-
#access
|
170
|
-
# predefcd.ideal(o["ideal"]) if o.has_key?("ideal")
|
171
|
-
# predefcd.performance(o["performance"]) if o.has_key?("performance")
|
172
|
-
predefcd.created_at(o["created_at"]) if o.has_key?("created_at")
|
173
|
-
#success or error
|
174
|
-
predefcd.some_msg[:code] = o["code"] if o.has_key?("code")
|
175
|
-
predefcd.some_msg[:msg_type] = o["msg_type"] if o.has_key?("msg_type")
|
176
|
-
predefcd.some_msg[:msg]= o["msg"] if o.has_key?("msg")
|
177
|
-
predefcd.some_msg[:links] = o["links"] if o.has_key?("links")
|
178
|
-
predefcd
|
179
|
-
end
|
180
|
-
|
181
|
-
def self.from_hash(o,tmp_email=nil, tmp_api_key=nil, tmp_host=nil)
|
182
|
-
predefcd = self.new(tmp_email, tmp_api_key, tmp_host)
|
183
|
-
predefcd.from_hash(o)
|
184
|
-
predefcd
|
185
|
-
end
|
186
|
-
|
187
|
-
def from_hash(o)
|
188
|
-
@id = o[:id] if o.has_key?(:id)
|
189
|
-
@name = o[:name] if o.has_key?(:name)
|
190
|
-
@spec = o[:spec] if o.has_key?(:spec)
|
191
|
-
@access = o[:access] if o.has_key?(:access)
|
192
|
-
# @ideal = o[:ideal] if o.has_key?(:ideal)
|
193
|
-
# @performance = o[:performance] if o.has_key?(:performance)
|
194
|
-
@created_at = o[:created_at] if o.has_key?(:created_at)
|
195
|
-
self
|
196
|
-
end
|
197
|
-
|
198
|
-
def self.create(o,tmp_email=nil, tmp_api_key=nil, tmp_host=nil)
|
199
|
-
acct = from_hash(o,tmp_email, tmp_api_key, tmp_host)
|
200
|
-
acct.create
|
201
|
-
end
|
202
|
-
|
203
|
-
# Create the predef via the REST API
|
204
|
-
def create
|
205
|
-
megam_rest.post_predefcloud(to_hash)
|
206
|
-
end
|
207
|
-
|
208
|
-
# Load all predefs -
|
209
|
-
# returns a PredefsCollection
|
210
|
-
# don't return self. check if the Megam::PredefCollection is returned.
|
211
|
-
def self.list(tmp_email=nil, tmp_api_key=nil, tmp_host=nil)
|
212
|
-
predef = self.new(tmp_email,tmp_api_key,tmp_host)
|
213
|
-
predef.megam_rest.get_predefclouds
|
214
|
-
end
|
215
|
-
|
216
|
-
# Show a particular predef by name,
|
217
|
-
# Megam::Predef
|
218
|
-
def self.show(p_name,tmp_email=nil, tmp_api_key=nil, tmp_host=nil)
|
219
|
-
pre = self.new(tmp_email,tmp_api_key,tmp_host)
|
220
|
-
pre.megam_rest.get_predefcloud(p_name)
|
221
|
-
end
|
222
|
-
|
223
|
-
def self.delete(p_name,tmp_email=nil, tmp_api_key=nil, tmp_host=nil)
|
224
|
-
pre = self.new(tmp_email,tmp_api_key,tmp_host)
|
225
|
-
pre.megam_rest.delete_predefcloud(p_name)
|
226
|
-
end
|
227
|
-
|
228
|
-
def to_s
|
229
|
-
Megam::Stuff.styled_hash(to_hash)
|
230
|
-
#"---> Megam::Account:[error=#{error?}]\n"+
|
231
|
-
end
|
232
|
-
|
233
|
-
end
|
234
|
-
end
|
@@ -1,168 +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 PredefCloudCollection
|
18
|
-
include Enumerable
|
19
|
-
|
20
|
-
attr_reader :iterator
|
21
|
-
def initialize
|
22
|
-
@predefclouds = Array.new
|
23
|
-
@predefclouds_by_name = Hash.new
|
24
|
-
@insert_after_idx = nil
|
25
|
-
end
|
26
|
-
|
27
|
-
def all_predefclouds
|
28
|
-
@predefclouds
|
29
|
-
end
|
30
|
-
|
31
|
-
def [](index)
|
32
|
-
@predefclouds[index]
|
33
|
-
end
|
34
|
-
|
35
|
-
def []=(index, arg)
|
36
|
-
is_megam_predefclouds(arg)
|
37
|
-
@predefclouds[index] = arg
|
38
|
-
@predefclouds_by_name[arg.name] = index
|
39
|
-
end
|
40
|
-
|
41
|
-
def <<(*args)
|
42
|
-
args.flatten.each do |a|
|
43
|
-
is_megam_predefclouds(a)
|
44
|
-
@predefclouds << a
|
45
|
-
@predefclouds_by_name[a.name] =@predefclouds.length - 1
|
46
|
-
end
|
47
|
-
self
|
48
|
-
end
|
49
|
-
|
50
|
-
# 'push' is an alias method to <<
|
51
|
-
alias_method :push, :<<
|
52
|
-
|
53
|
-
def insert(predefclouds)
|
54
|
-
is_megam_predefclouds(predefclouds)
|
55
|
-
if @insert_after_idx
|
56
|
-
# in the middle of executing a run, so any predefs inserted now should
|
57
|
-
# be placed after the most recent addition done by the currently executing
|
58
|
-
# predefclouds
|
59
|
-
@predefclouds.insert(@insert_after_idx + 1, predefclouds)
|
60
|
-
# update name -> location mappings and register new predefclouds
|
61
|
-
@predefclouds_by_name.each_key do |key|
|
62
|
-
@predefclouds_by_name[key] += 1 if@predefclouds_by_name[key] > @insert_after_idx
|
63
|
-
end
|
64
|
-
@predefclouds_by_name[predefclouds.name] = @insert_after_idx + 1
|
65
|
-
@insert_after_idx += 1
|
66
|
-
else
|
67
|
-
@predefclouds << predefclouds
|
68
|
-
@predefclouds_by_name[predefclouds.name] =@predefclouds.length - 1
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
def each
|
73
|
-
@predefclouds.each do |predefclouds|
|
74
|
-
yield predefclouds
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
def each_index
|
79
|
-
@predefclouds.each_index do |i|
|
80
|
-
yield i
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
def empty?
|
85
|
-
@predefclouds.empty?
|
86
|
-
end
|
87
|
-
|
88
|
-
def lookup(predefclouds)
|
89
|
-
lookup_by = nil
|
90
|
-
if predefclouds.kind_of?(Megam::PredefCloud)
|
91
|
-
lookup_by = predefclouds.name
|
92
|
-
elsif predefclouds.kind_of?(String)
|
93
|
-
lookup_by = predefclouds
|
94
|
-
else
|
95
|
-
raise ArgumentError, "Must pass a Megam::PredefClouds or String to lookup"
|
96
|
-
end
|
97
|
-
res =@predefclouds_by_name[lookup_by]
|
98
|
-
unless res
|
99
|
-
raise ArgumentError, "Cannot find a predefclouds matching #{lookup_by} (did you define it first?)"
|
100
|
-
end
|
101
|
-
@predefclouds[res]
|
102
|
-
end
|
103
|
-
|
104
|
-
# Transform the ruby obj -> to a Hash
|
105
|
-
def to_hash
|
106
|
-
index_hash = Hash.new
|
107
|
-
self.each do |predefclouds|
|
108
|
-
index_hash[predefclouds.name] = predefclouds.to_s
|
109
|
-
end
|
110
|
-
index_hash
|
111
|
-
end
|
112
|
-
|
113
|
-
# Serialize this object as a hash: called from JsonCompat.
|
114
|
-
# Verify if this called from JsonCompat during testing.
|
115
|
-
def to_json(*a)
|
116
|
-
for_json.to_json(*a)
|
117
|
-
end
|
118
|
-
|
119
|
-
=begin
|
120
|
-
{
|
121
|
-
"json_claz":"Megam::PredefCloudCollection",
|
122
|
-
"results":[{
|
123
|
-
"id":"NOD362554470640386048",
|
124
|
-
"name":"ec2_rails",
|
125
|
-
"account_id":"ACT362544229488001024",
|
126
|
-
"json_claz":"Megam::PredefCloud",
|
127
|
-
"spec":{
|
128
|
-
"type_name":"sensor-type",
|
129
|
-
"groups":"sens-group",
|
130
|
-
"image":"sens-image",
|
131
|
-
"flavor":"sens-flvr"
|
132
|
-
},
|
133
|
-
"access":{
|
134
|
-
"ssh_key":"sens-ssh",
|
135
|
-
"identity_file":"sens-identity-file",
|
136
|
-
"ssh_user":"sens-sshuser"
|
137
|
-
},
|
138
|
-
"ideal":"",
|
139
|
-
"performance":""
|
140
|
-
}]
|
141
|
-
}
|
142
|
-
=end
|
143
|
-
def self.json_create(o)
|
144
|
-
collection = self.new()
|
145
|
-
o["results"].each do |predefclouds_list|
|
146
|
-
predefclouds_array = predefclouds_list.kind_of?(Array) ? predefclouds_list : [ predefclouds_list ]
|
147
|
-
predefclouds_array.each do |predefclouds|
|
148
|
-
collection.insert(predefclouds)
|
149
|
-
end
|
150
|
-
end
|
151
|
-
collection
|
152
|
-
end
|
153
|
-
|
154
|
-
private
|
155
|
-
|
156
|
-
def is_megam_predefclouds(arg)
|
157
|
-
unless arg.kind_of?(Megam::PredefCloud)
|
158
|
-
raise ArgumentError, "Members must be Megam::PredefClouds's"
|
159
|
-
end
|
160
|
-
true
|
161
|
-
end
|
162
|
-
|
163
|
-
def to_s
|
164
|
-
Megam::Stuff.styled_hash(to_hash)
|
165
|
-
end
|
166
|
-
|
167
|
-
end
|
168
|
-
end
|