megam_api 0.18 → 0.19
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/assemblies.rb +1 -2
- data/lib/megam/api/assembly.rb +15 -0
- data/lib/megam/api/components.rb +14 -0
- data/lib/megam/api/version.rb +1 -1
- data/lib/megam/api.rb +7 -0
- data/lib/megam/core/assemblies.rb +4 -4
- data/lib/megam/core/assembly.rb +172 -0
- data/lib/megam/core/assembly_collection.rb +145 -0
- data/lib/megam/core/components.rb +433 -0
- data/lib/megam/core/components_collection.rb +145 -0
- data/lib/megam/core/json_compat.rb +40 -88
- data/lib/megam/core/organizations.rb +12 -1
- data/test/test_assemblies.rb +7 -2
- data/test/test_assembly.rb +10 -0
- data/test/test_components.rb +8 -0
- data/test/test_domains.rb +2 -2
- data/test/test_helper.rb +1 -1
- data/test/test_organizations.rb +4 -4
- metadata +10 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ce34e26cf345435dd7f7525248d06e6f39f8ce5
|
4
|
+
data.tar.gz: fe0189ff7e1b6c6150d9dba00e247f3e0037dfed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d68e3d04b97e4de2aeab4aacd0f772f4fafdc95ba9a16d1d9244820d9ff73e81ec4ba903766ccb96c4774ee998827474e34b6c98d39faf27855079fdc6032a9
|
7
|
+
data.tar.gz: d2d5c151fae29057a4e7ebd576e562036e1b0600836ca2019f6070754a013618607bdef5129bbc67f1da0d0142c197e51f97b3b64ce7f34bb15951179ae31004
|
data/lib/megam/api/assemblies.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
module Megam
|
2
2
|
class API
|
3
|
-
|
4
3
|
# GET /nodes
|
5
4
|
def get_assemblies
|
6
5
|
@options = {:path => '/assemblies',:body => ""}.merge(@options)
|
@@ -12,7 +11,7 @@ module Megam
|
|
12
11
|
)
|
13
12
|
end
|
14
13
|
|
15
|
-
def
|
14
|
+
def get_one_assemblies(asm_id)
|
16
15
|
@options = {:path => "/assemblies/#{asm_id}",:body => ""}.merge(@options)
|
17
16
|
|
18
17
|
request(
|
data/lib/megam/api/version.rb
CHANGED
data/lib/megam/api.rb
CHANGED
@@ -28,6 +28,8 @@ require "megam/api/organizations"
|
|
28
28
|
require "megam/api/domains"
|
29
29
|
require "megam/api/csars"
|
30
30
|
require "megam/api/assemblies"
|
31
|
+
require "megam/api/assembly"
|
32
|
+
require "megam/api/components"
|
31
33
|
|
32
34
|
require "megam/core/server_api"
|
33
35
|
require "megam/core/config"
|
@@ -57,6 +59,11 @@ require "megam/core/assemblies_collection"
|
|
57
59
|
require "megam/core/csar"
|
58
60
|
require "megam/core/csar_collection"
|
59
61
|
require "megam/core/konipai"
|
62
|
+
require "megam/core/assembly"
|
63
|
+
require "megam/core/assembly_collection"
|
64
|
+
require "megam/core/components"
|
65
|
+
require "megam/core/components_collection"
|
66
|
+
|
60
67
|
|
61
68
|
|
62
69
|
|
@@ -162,12 +162,12 @@ module Megam
|
|
162
162
|
end
|
163
163
|
|
164
164
|
# Load a account by email_p
|
165
|
-
def self.show(
|
165
|
+
def self.show(one_assemblies_id, tmp_email=nil, tmp_api_key=nil)
|
166
166
|
asm = self.new(tmp_email, tmp_api_key)
|
167
|
-
asm.megam_rest.
|
167
|
+
asm.megam_rest.get_one_assemblies(one_assemblies_id)
|
168
168
|
end
|
169
169
|
|
170
|
-
def self.list(tmp_email=nil, tmp_api_key=nil)
|
170
|
+
def self.list(tmp_email=nil, tmp_api_key=nil, inflated=false)
|
171
171
|
asm = self.new(tmp_email, tmp_api_key)
|
172
172
|
asm.megam_rest.get_assemblies
|
173
173
|
end
|
@@ -177,4 +177,4 @@ module Megam
|
|
177
177
|
end
|
178
178
|
|
179
179
|
end
|
180
|
-
end
|
180
|
+
end
|
@@ -0,0 +1,172 @@
|
|
1
|
+
# Copyright:: Copyright (c) 2012, 2014 Megam Systems
|
2
|
+
# License:: Apache License, Version 2.0
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
module Megam
|
18
|
+
class Assembly < Megam::ServerAPI
|
19
|
+
def initialize(email=nil, api_key=nil)
|
20
|
+
@id = nil
|
21
|
+
@name = nil
|
22
|
+
@components = []
|
23
|
+
@policies={}
|
24
|
+
@inputs = {}
|
25
|
+
@operations = nil
|
26
|
+
@created_at = nil
|
27
|
+
super(email, api_key)
|
28
|
+
end
|
29
|
+
|
30
|
+
def assembly
|
31
|
+
self
|
32
|
+
end
|
33
|
+
|
34
|
+
def id(arg=nil)
|
35
|
+
if arg != nil
|
36
|
+
@id = arg
|
37
|
+
else
|
38
|
+
@id
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def name(arg=nil)
|
43
|
+
if arg != nil
|
44
|
+
@name = arg
|
45
|
+
else
|
46
|
+
@name
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def components(arg=[])
|
51
|
+
if arg != []
|
52
|
+
@components = arg
|
53
|
+
else
|
54
|
+
@components
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def policies(arg=[])
|
59
|
+
if arg != []
|
60
|
+
@policies = arg
|
61
|
+
else
|
62
|
+
@policies
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def inputs(arg=[])
|
67
|
+
if arg != []
|
68
|
+
@inputs = arg
|
69
|
+
else
|
70
|
+
@inputs
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def operations(arg=nil)
|
75
|
+
if arg != nil
|
76
|
+
@operations = arg
|
77
|
+
else
|
78
|
+
@operations
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def created_at(arg=nil)
|
83
|
+
if arg != nil
|
84
|
+
@created_at = arg
|
85
|
+
else
|
86
|
+
@created_at
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def error?
|
91
|
+
crocked = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error")
|
92
|
+
end
|
93
|
+
|
94
|
+
# Transform the ruby obj -> to a Hash
|
95
|
+
def to_hash
|
96
|
+
index_hash = Hash.new
|
97
|
+
index_hash["json_claz"] = self.class.name
|
98
|
+
index_hash["id"] = id
|
99
|
+
index_hash["name"] = name
|
100
|
+
index_hash["components"] = components
|
101
|
+
index_hash["policies"] = policies
|
102
|
+
index_hash["inputs"] = inputs
|
103
|
+
index_hash["operations"] = operations
|
104
|
+
index_hash["created_at"] = created_at
|
105
|
+
index_hash
|
106
|
+
end
|
107
|
+
|
108
|
+
# Serialize this object as a hash: called from JsonCompat.
|
109
|
+
# Verify if this called from JsonCompat during testing.
|
110
|
+
def to_json(*a)
|
111
|
+
for_json.to_json(*a)
|
112
|
+
end
|
113
|
+
|
114
|
+
def for_json
|
115
|
+
result = {
|
116
|
+
"id" => id,
|
117
|
+
"name" => name,
|
118
|
+
"components" => components,
|
119
|
+
"policies" => policies,
|
120
|
+
"inputs" => inputs,
|
121
|
+
"operations" => operations,
|
122
|
+
"created_at" => created_at
|
123
|
+
}
|
124
|
+
|
125
|
+
result
|
126
|
+
end
|
127
|
+
|
128
|
+
def self.json_create(o)
|
129
|
+
asm = new
|
130
|
+
asm.id(o["id"]) if o.has_key?("id")
|
131
|
+
asm.name(o["name"]) if o.has_key?("name")
|
132
|
+
asm.components(o["components"]) if o.has_key?("components")
|
133
|
+
asm.policies(o["policies"]) if o.has_key?("policies") #this will be an array? can hash store array?
|
134
|
+
asm.inputs(o["inputs"]) if o.has_key?("inputs")
|
135
|
+
asm.operations(o["operations"]) if o.has_key?("operations")
|
136
|
+
asm.created_at(o["created_at"]) if o.has_key?("created_at")
|
137
|
+
asm
|
138
|
+
end
|
139
|
+
|
140
|
+
def self.from_hash(o,tmp_email=nil, tmp_api_key=nil)
|
141
|
+
asm = self.new(tmp_email, tmp_api_key)
|
142
|
+
asm.from_hash(o)
|
143
|
+
asm
|
144
|
+
end
|
145
|
+
|
146
|
+
def from_hash(o)
|
147
|
+
@id = o["id"] if o.has_key?("id")
|
148
|
+
@name = o["name"] if o.has_key?("name")
|
149
|
+
@components = o["components"] if o.has_key?("components")
|
150
|
+
@policies = o["policies"] if o.has_key?("policies")
|
151
|
+
@inputs = o["inputs"] if o.has_key?("inputs")
|
152
|
+
@operations = o["operations"] if o.has_key?("operations")
|
153
|
+
@created_at = o["created_at"] if o.has_key?("created_at")
|
154
|
+
self
|
155
|
+
end
|
156
|
+
|
157
|
+
|
158
|
+
def self.show(assembly_id, tmp_email=nil, tmp_api_key=nil)
|
159
|
+
asm = self.new(tmp_email, tmp_api_key)
|
160
|
+
puts "---->>>> "
|
161
|
+
puts #{assembly_id}
|
162
|
+
puts "----------->>>"
|
163
|
+
asm.megam_rest.get_one_assembly(assembly_id)
|
164
|
+
end
|
165
|
+
|
166
|
+
|
167
|
+
def to_s
|
168
|
+
Megam::Stuff.styled_hash(to_hash)
|
169
|
+
end
|
170
|
+
|
171
|
+
end
|
172
|
+
end
|
@@ -0,0 +1,145 @@
|
|
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 AssemblyCollection
|
18
|
+
include Enumerable
|
19
|
+
|
20
|
+
attr_reader :iterator
|
21
|
+
def initialize
|
22
|
+
@assemblys = Array.new
|
23
|
+
@assemblys_by_name = Hash.new
|
24
|
+
@insert_after_idx = nil
|
25
|
+
end
|
26
|
+
|
27
|
+
def all_assemblys
|
28
|
+
@assemblys
|
29
|
+
end
|
30
|
+
|
31
|
+
def [](index)
|
32
|
+
@assemblys[index]
|
33
|
+
end
|
34
|
+
|
35
|
+
def []=(index, arg)
|
36
|
+
is_megam_assemblys(arg)
|
37
|
+
@assemblys[index] = arg
|
38
|
+
@assemblys_by_name[arg.name] = index
|
39
|
+
end
|
40
|
+
|
41
|
+
def <<(*args)
|
42
|
+
args.flatten.each do |a|
|
43
|
+
is_megam_assemblys(a)
|
44
|
+
@assemblys << a
|
45
|
+
@assemblys_by_name[a.name] = @assemblys.length - 1
|
46
|
+
end
|
47
|
+
self
|
48
|
+
end
|
49
|
+
|
50
|
+
# 'push' is an alias method to <<
|
51
|
+
alias_method :push, :<<
|
52
|
+
|
53
|
+
def insert(assemblys)
|
54
|
+
is_megam_assemblys(assemblys)
|
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
|
+
@assemblys.insert(@insert_after_idx + 1, assemblys)
|
60
|
+
# update name -> location mappings and register new node
|
61
|
+
@assemblys_by_name.each_key do |key|
|
62
|
+
@assemblys_by_name[key] += 1 if @assemblys_by_name[key] > @insert_after_idx
|
63
|
+
end
|
64
|
+
@assemblys_by_name[assemblys.name] = @insert_after_idx + 1
|
65
|
+
@insert_after_idx += 1
|
66
|
+
else
|
67
|
+
@assemblys << assemblys
|
68
|
+
@assemblys_by_name[assemblys.name] = @assemblys.length - 1
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def each
|
73
|
+
@assemblys.each do |assemblys|
|
74
|
+
yield assemblys
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def each_index
|
79
|
+
@assemblys.each_index do |i|
|
80
|
+
yield i
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def empty?
|
85
|
+
@assemblys.empty?
|
86
|
+
end
|
87
|
+
|
88
|
+
def lookup(assemblys)
|
89
|
+
lookup_by = nil
|
90
|
+
if assemblys.kind_of?(Megam::Assembly)
|
91
|
+
lookup_by = assemblys.name
|
92
|
+
elsif assemblys.kind_of?(String)
|
93
|
+
lookup_by = assemblys
|
94
|
+
else
|
95
|
+
raise ArgumentError, "Must pass a Megam::Assemblies or String to lookup"
|
96
|
+
end
|
97
|
+
res = @assemblys_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
|
+
@assemblys[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 |assemblys|
|
108
|
+
index_hash[assemblys.name] = assemblys.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
|
+
def self.json_create(o)
|
120
|
+
collection = self.new()
|
121
|
+
o["results"].each do |assemblys_list|
|
122
|
+
assemblys_array = assemblys_list.kind_of?(Array) ? assemblys_list : [ assemblys_list ]
|
123
|
+
assemblys_array.each do |assemblys|
|
124
|
+
collection.insert(assemblys)
|
125
|
+
|
126
|
+
end
|
127
|
+
end
|
128
|
+
collection
|
129
|
+
end
|
130
|
+
|
131
|
+
private
|
132
|
+
|
133
|
+
def is_megam_assemblys(arg)
|
134
|
+
unless arg.kind_of?(Megam::Assembly)
|
135
|
+
raise ArgumentError, "Members must be Megam::Assembly'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
|
@@ -0,0 +1,433 @@
|
|
1
|
+
# Copyright:: Copyright (c) 2012, 2014 Megam Systems
|
2
|
+
# License:: Apache License, Version 2.0
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
module Megam
|
18
|
+
class Components < Megam::ServerAPI
|
19
|
+
def initialize(email=nil, api_key=nil)
|
20
|
+
@id = nil
|
21
|
+
@name =nil
|
22
|
+
@tosca_type = nil
|
23
|
+
@requirements = {}
|
24
|
+
@host = nil
|
25
|
+
@dummy = nil
|
26
|
+
@inputs = {}
|
27
|
+
@domain = nil
|
28
|
+
@port = nil
|
29
|
+
@username = nil
|
30
|
+
@password = nil
|
31
|
+
@version = nil
|
32
|
+
@source = nil
|
33
|
+
@design_inputs = nil
|
34
|
+
@x = nil
|
35
|
+
@y = nil
|
36
|
+
@z = nil
|
37
|
+
@wires = []
|
38
|
+
@service_inputs = nil
|
39
|
+
@dbname = nil
|
40
|
+
@dbpassword = nil
|
41
|
+
@external_management_resource = nil
|
42
|
+
@artifacts = {}
|
43
|
+
@artifact_type = nil
|
44
|
+
@content = nil
|
45
|
+
@artifact_requirements = nil
|
46
|
+
@related_components = nil
|
47
|
+
@operations = {}
|
48
|
+
@operation_type = nil
|
49
|
+
@target_resource = nil
|
50
|
+
@created_at = nil
|
51
|
+
|
52
|
+
super(email, api_key)
|
53
|
+
end
|
54
|
+
|
55
|
+
def components
|
56
|
+
self
|
57
|
+
end
|
58
|
+
|
59
|
+
def id(arg=nil)
|
60
|
+
if arg != nil
|
61
|
+
@id = arg
|
62
|
+
else
|
63
|
+
@id
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def name(arg=nil)
|
68
|
+
if arg != nil
|
69
|
+
@name = arg
|
70
|
+
else
|
71
|
+
@name
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def tosca_type(arg=nil)
|
76
|
+
if arg != nil
|
77
|
+
@tosca_type = arg
|
78
|
+
else
|
79
|
+
@tosca_type
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def requirements(arg=nil)
|
84
|
+
if arg != nil
|
85
|
+
@requirements = arg
|
86
|
+
else
|
87
|
+
@requirements
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def host(arg=nil)
|
92
|
+
if arg != nil
|
93
|
+
@host = arg
|
94
|
+
else
|
95
|
+
@host
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def dummy(arg=nil)
|
100
|
+
if arg != nil
|
101
|
+
@dummy = arg
|
102
|
+
else
|
103
|
+
@dummy
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def inputs(arg=[])
|
108
|
+
if arg != []
|
109
|
+
@inputs = arg
|
110
|
+
else
|
111
|
+
@inputs
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
def domain(arg=nil)
|
116
|
+
if arg != nil
|
117
|
+
@domain = arg
|
118
|
+
else
|
119
|
+
@domain
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
def port(arg=nil)
|
124
|
+
if arg != nil
|
125
|
+
@port = arg
|
126
|
+
else
|
127
|
+
@port
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
def username(arg=nil)
|
132
|
+
if arg != nil
|
133
|
+
@username = arg
|
134
|
+
else
|
135
|
+
@username
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
def password(arg=nil)
|
140
|
+
if arg != nil
|
141
|
+
@password = arg
|
142
|
+
else
|
143
|
+
@password
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
def version(arg=nil)
|
148
|
+
if arg != nil
|
149
|
+
@version = arg
|
150
|
+
else
|
151
|
+
@version
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
def source(arg=nil)
|
156
|
+
if arg != nil
|
157
|
+
@source = arg
|
158
|
+
else
|
159
|
+
@source
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
def design_inputs(arg=nil)
|
164
|
+
if arg != nil
|
165
|
+
@design_inputs = arg
|
166
|
+
else
|
167
|
+
@design_inputs
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
def x(arg=nil)
|
172
|
+
if arg != nil
|
173
|
+
@x = arg
|
174
|
+
else
|
175
|
+
@x
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
def y(arg=nil)
|
180
|
+
if arg != nil
|
181
|
+
@y = arg
|
182
|
+
else
|
183
|
+
@y
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
def z(arg=nil)
|
188
|
+
if arg != nil
|
189
|
+
@z = arg
|
190
|
+
else
|
191
|
+
@z
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
def wires(arg=nil)
|
196
|
+
if arg != nil
|
197
|
+
@wires = arg
|
198
|
+
else
|
199
|
+
@wires
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
def service_inputs(arg=nil)
|
204
|
+
if arg != nil
|
205
|
+
@service_inputs = arg
|
206
|
+
else
|
207
|
+
@service_inputs
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
def dbname(arg=nil)
|
212
|
+
if arg != nil
|
213
|
+
@dbname = arg
|
214
|
+
else
|
215
|
+
@dbname
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
def dbpassword(arg=nil)
|
220
|
+
if arg != nil
|
221
|
+
@dbpassword = arg
|
222
|
+
else
|
223
|
+
@dbpassword
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
def external_management_resource(arg=nil)
|
228
|
+
if arg != nil
|
229
|
+
@external_management_resource = arg
|
230
|
+
else
|
231
|
+
@external_management_resource
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
def artifacts(arg=nil)
|
236
|
+
if arg != nil
|
237
|
+
@artifacts = arg
|
238
|
+
else
|
239
|
+
@artifacts
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
def artifact_type(arg=nil)
|
244
|
+
if arg != nil
|
245
|
+
@artifact_type = arg
|
246
|
+
else
|
247
|
+
@artifact_type
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
251
|
+
def content(arg=nil)
|
252
|
+
if arg != nil
|
253
|
+
@content = arg
|
254
|
+
else
|
255
|
+
@content
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
def artifact_requirements(arg=nil)
|
260
|
+
if arg != nil
|
261
|
+
@artifact_requirements = arg
|
262
|
+
else
|
263
|
+
@artifact_requirements
|
264
|
+
end
|
265
|
+
end
|
266
|
+
|
267
|
+
def related_components(arg=nil)
|
268
|
+
if arg != nil
|
269
|
+
@related_components = arg
|
270
|
+
else
|
271
|
+
@related_components
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
275
|
+
def operations(arg=nil)
|
276
|
+
if arg != nil
|
277
|
+
@operations = arg
|
278
|
+
else
|
279
|
+
@operations
|
280
|
+
end
|
281
|
+
end
|
282
|
+
|
283
|
+
def operation_type(arg=nil)
|
284
|
+
if arg != nil
|
285
|
+
@operation_type = arg
|
286
|
+
else
|
287
|
+
@operation_type
|
288
|
+
end
|
289
|
+
end
|
290
|
+
|
291
|
+
def target_resource(arg=nil)
|
292
|
+
if arg != nil
|
293
|
+
@target_resource = arg
|
294
|
+
else
|
295
|
+
@target_resource
|
296
|
+
end
|
297
|
+
end
|
298
|
+
|
299
|
+
def created_at(arg=nil)
|
300
|
+
if arg != nil
|
301
|
+
@created_at = arg
|
302
|
+
else
|
303
|
+
@created_at
|
304
|
+
end
|
305
|
+
end
|
306
|
+
|
307
|
+
def error?
|
308
|
+
crocked = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error")
|
309
|
+
end
|
310
|
+
|
311
|
+
# Transform the ruby obj -> to a Hash
|
312
|
+
def to_hash
|
313
|
+
index_hash = Hash.new
|
314
|
+
index_hash["json_claz"] = self.class.name
|
315
|
+
index_hash["id"] = id
|
316
|
+
index_hash["name"] = name
|
317
|
+
index_hash["tosca_type"] = tosca_type
|
318
|
+
index_hash["requirements"] = requirements
|
319
|
+
index_hash["inputs"] = inputs
|
320
|
+
index_hash["external_management_resource"] = external_management_resource
|
321
|
+
index_hash["artifacts"] = artifacts
|
322
|
+
index_hash["related_components"] = related_components
|
323
|
+
index_hash["operations"] = operations
|
324
|
+
index_hash["created_at"] = created_at
|
325
|
+
index_hash
|
326
|
+
end
|
327
|
+
|
328
|
+
# Serialize this object as a hash: called from JsonCompat.
|
329
|
+
# Verify if this called from JsonCompat during testing.
|
330
|
+
def to_json(*a)
|
331
|
+
for_json.to_json(*a)
|
332
|
+
end
|
333
|
+
|
334
|
+
def for_json
|
335
|
+
result = {
|
336
|
+
"id" => id,
|
337
|
+
"name" => name,
|
338
|
+
"tosca_type" => tosca_type,
|
339
|
+
"requirements" => requirements,
|
340
|
+
"inputs" => inputs,
|
341
|
+
"external_management_resource" => external_management_resource,
|
342
|
+
"artifacts" => artifacts,
|
343
|
+
"related_components" => related_components,
|
344
|
+
"operations" => operations,
|
345
|
+
"created_at" => created_at
|
346
|
+
}
|
347
|
+
result
|
348
|
+
end
|
349
|
+
|
350
|
+
def self.json_create(o)
|
351
|
+
asm = new
|
352
|
+
asm.id(o["id"]) if o.has_key?("id")
|
353
|
+
asm.name(o["name"]) if o.has_key?("name")
|
354
|
+
asm.tosca_type(o["tosca_type"]) if o.has_key?("tosca_type")
|
355
|
+
|
356
|
+
oq = o["requirements"]
|
357
|
+
asm.requirements[:host] = oq["host"] if oq && oq.has_key?("host")
|
358
|
+
asm.requirements[:dummy] = oq["dummy"] if oq && oq.has_key?("dummy")
|
359
|
+
|
360
|
+
inp = o["inputs"]
|
361
|
+
asm.inputs[:domain] = inp["domain"] if inp && inp.has_key?("domain")
|
362
|
+
asm.inputs[:port] = inp["port"] if inp && inp.has_key?("port")
|
363
|
+
asm.inputs[:username] = inp["username"] if inp && inp.has_key?("username")
|
364
|
+
asm.inputs[:password] = inp["password"] if inp && inp.has_key?("password")
|
365
|
+
asm.inputs[:version] = inp["version"] if inp && inp.has_key?("version")
|
366
|
+
asm.inputs[:source] = inp["source"] if inp && inp.has_key?("source")
|
367
|
+
asm.inputs[:design_inputs] = inp["design_inputs"] if inp && inp.has_key?("design_inputs")
|
368
|
+
asm.inputs[:service_inputs] = inp["service_inputs"] if inp && inp.has_key?("service_inputs")
|
369
|
+
# ind = inp["design_inputs"]
|
370
|
+
# asm.inputs["design_inputs"][:did] = ind["did"] if ind && ind.has_key?("did")
|
371
|
+
# asm.inputs[:design_inputs][:x] = ind["x"] if ind && ind.has_key?("x")
|
372
|
+
# asm.inputs[:design_inputs][:y] = ind["y"] if ind && ind.has_key?("y")
|
373
|
+
# asm.inputs[:design_inputs][:z] = ind["z"] if ind && ind.has_key?("z")
|
374
|
+
# asm.inputs[:design_inputs][:wires] = ind["wires"] if ind && ind.has_key?("wires")
|
375
|
+
# ins = o["inputs"]["service_inputs"]
|
376
|
+
# asm.inputs[:service_inputs][:dbname] = ins["dbname"] if ins && ins.has_key?("dbname")
|
377
|
+
# asm.inputs[:service_inputs][:dbpassword] = ins["dbpassword"] if ins && ins.has_key?("dbpassword")
|
378
|
+
|
379
|
+
asm.external_management_resource(o["external_management_resource"]) if o.has_key?("external_management_resource")
|
380
|
+
|
381
|
+
ar = o["artifacts"]
|
382
|
+
asm.artifacts[:artifact_type] = ar["artifact_type"] if ar && ar.has_key?("artifact_type")
|
383
|
+
asm.artifacts[:content] = ar["content"] if ar && ar.has_key?("content")
|
384
|
+
asm.artifacts[:artifact_requirements] = ar["artifact_requirements"] if ar && ar.has_key?("artifact_requirements")
|
385
|
+
|
386
|
+
asm.related_components(o["related_components"]) if o.has_key?("related_components")
|
387
|
+
|
388
|
+
ope = o["operations"]
|
389
|
+
asm.operations[:operation_type] = ope["operation_type"] if ope && ope.has_key?("operation_type")
|
390
|
+
asm.operations[:target_resource] = ope["target_resource"] if ope && ope.has_key?("target_resource")
|
391
|
+
|
392
|
+
asm.created_at(o["created_at"]) if o.has_key?("created_at")
|
393
|
+
asm
|
394
|
+
end
|
395
|
+
|
396
|
+
def self.from_hash(o,tmp_email=nil, tmp_api_key=nil)
|
397
|
+
asm = self.new(tmp_email, tmp_api_key)
|
398
|
+
asm.from_hash(o)
|
399
|
+
asm
|
400
|
+
end
|
401
|
+
|
402
|
+
def from_hash(o)
|
403
|
+
@id = o["id"] if o.has_key?("id")
|
404
|
+
@name = o["name"] if o.has_key?("name")
|
405
|
+
@tosca_type = o["tosca_type"] if o.has_key?("tosca_type")
|
406
|
+
@inputs = o["inputs"] if o.has_key?("inputs")
|
407
|
+
@external_management_resource = o["external_management_resource"] if o.has_key?("external_management_resource")
|
408
|
+
@artifacts = o["artifacts"] if o.has_key?("artifacts")
|
409
|
+
@related_components = o["related_components"] if o.has_key?("related_components")
|
410
|
+
@operations = o["operations"] if o.has_key?("operations")
|
411
|
+
@created_at = o["created_at"] if o.has_key?("created_at")
|
412
|
+
self
|
413
|
+
end
|
414
|
+
|
415
|
+
def self.create(o,tmp_email=nil, tmp_api_key=nil)
|
416
|
+
asm = from_hash(o, tmp_email, tmp_api_key)
|
417
|
+
asm.create
|
418
|
+
end
|
419
|
+
|
420
|
+
|
421
|
+
# Load a account by email_p
|
422
|
+
def self.show(comp_id, tmp_email=nil, tmp_api_key=nil)
|
423
|
+
asm = self.new(tmp_email, tmp_api_key)
|
424
|
+
asm.megam_rest.get_components(comp_id)
|
425
|
+
end
|
426
|
+
|
427
|
+
|
428
|
+
def to_s
|
429
|
+
Megam::Stuff.styled_hash(to_hash)
|
430
|
+
end
|
431
|
+
|
432
|
+
end
|
433
|
+
end
|
@@ -0,0 +1,145 @@
|
|
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 ComponentsCollection
|
18
|
+
include Enumerable
|
19
|
+
|
20
|
+
attr_reader :iterator
|
21
|
+
def initialize
|
22
|
+
@components = Array.new
|
23
|
+
@components_by_name = Hash.new
|
24
|
+
@insert_after_idx = nil
|
25
|
+
end
|
26
|
+
|
27
|
+
def all_components
|
28
|
+
@components
|
29
|
+
end
|
30
|
+
|
31
|
+
def [](index)
|
32
|
+
@components[index]
|
33
|
+
end
|
34
|
+
|
35
|
+
def []=(index, arg)
|
36
|
+
is_megam_components(arg)
|
37
|
+
@components[index] = arg
|
38
|
+
@components_by_name[arg.name] = index
|
39
|
+
end
|
40
|
+
|
41
|
+
def <<(*args)
|
42
|
+
args.flatten.each do |a|
|
43
|
+
is_megam_components(a)
|
44
|
+
@components << a
|
45
|
+
@components_by_name[a.name] = @components.length - 1
|
46
|
+
end
|
47
|
+
self
|
48
|
+
end
|
49
|
+
|
50
|
+
# 'push' is an alias method to <<
|
51
|
+
alias_method :push, :<<
|
52
|
+
|
53
|
+
def insert(components)
|
54
|
+
is_megam_components(components)
|
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
|
+
@components.insert(@insert_after_idx + 1, components)
|
60
|
+
# update name -> location mappings and register new node
|
61
|
+
@components_by_name.each_key do |key|
|
62
|
+
@components_by_name[key] += 1 if @components_by_name[key] > @insert_after_idx
|
63
|
+
end
|
64
|
+
@components_by_name[components.name] = @insert_after_idx + 1
|
65
|
+
@insert_after_idx += 1
|
66
|
+
else
|
67
|
+
@components << components
|
68
|
+
@components_by_name[components.name] = @components.length - 1
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def each
|
73
|
+
@components.each do |components|
|
74
|
+
yield components
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def each_index
|
79
|
+
@components.each_index do |i|
|
80
|
+
yield i
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def empty?
|
85
|
+
@components.empty?
|
86
|
+
end
|
87
|
+
|
88
|
+
def lookup(components)
|
89
|
+
lookup_by = nil
|
90
|
+
if components.kind_of?(Megam::Components)
|
91
|
+
lookup_by = components.name
|
92
|
+
elsif components.kind_of?(String)
|
93
|
+
lookup_by = components
|
94
|
+
else
|
95
|
+
raise ArgumentError, "Must pass a Megam::components or String to lookup"
|
96
|
+
end
|
97
|
+
res = @components_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
|
+
@components[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 |components|
|
108
|
+
index_hash[components.name] = components.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
|
+
def self.json_create(o)
|
120
|
+
collection = self.new()
|
121
|
+
o["results"].each do |components_list|
|
122
|
+
components_array = components_list.kind_of?(Array) ? components_list : [ components_list ]
|
123
|
+
components_array.each do |components|
|
124
|
+
collection.insert(components)
|
125
|
+
|
126
|
+
end
|
127
|
+
end
|
128
|
+
collection
|
129
|
+
end
|
130
|
+
|
131
|
+
private
|
132
|
+
|
133
|
+
def is_megam_components(arg)
|
134
|
+
unless arg.kind_of?(Megam::Components)
|
135
|
+
raise ArgumentError, "Members must be Megam::components"
|
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
|
@@ -22,47 +22,33 @@ module Megam
|
|
22
22
|
|
23
23
|
JSON_CLAZ = "json_claz".freeze
|
24
24
|
|
25
|
-
MEGAM_AUTH
|
26
|
-
MEGAM_ERROR
|
27
|
-
MEGAM_ACCOUNT
|
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
|
-
MEGAM_CLOUDTOOLSETTINGCOLLECTION = "Megam::CloudToolSettingCollection".freeze
|
53
|
-
MEGAM_CLOUDTEMPLATE = "Megam::CloudTemplate".freeze
|
54
|
-
MEGAM_CLOUDTEMPLATECOLLECTION = "Megam::CloudTemplateCollection".freeze
|
55
|
-
MEGAM_CLOUDINSTRUCTION = "Megam::CloudInstruction".freeze
|
56
|
-
MEGAM_CLOUDINSTRUCTIONCOLLECTION = "Megam::CloudInstructionCollection".freeze
|
57
|
-
MEGAM_CLOUDINSTRUCTIONGROUP = "Megam::CloudInstructionGroup".freeze
|
58
|
-
MEGAM_SSHKEY = "Megam::SshKey".freeze
|
59
|
-
MEGAM_SSHKEYCOLLECTION = "Megam::SshKeyCollection".freeze
|
60
|
-
MEGAM_MARKETPLACE = "Megam::MarketPlace".freeze
|
61
|
-
MEGAM_MARKETPLACECOLLECTION = "Megam::MarketPlaceCollection".freeze
|
62
|
-
MEGAM_MARKETPLACEADDON = "Megam::MarketPlaceAddons".freeze
|
63
|
-
MEGAM_MARKETPLACEADDONCOLLECTION = "Megam::MarketPlaceAddonsCollection".freeze
|
64
|
-
MEGAM_CSAR = "Megam::CSAR".freeze
|
65
|
-
MEGAM_CSARCOLLECTION = "Megam::CSARCollection".freeze
|
25
|
+
MEGAM_AUTH = "Megam::Auth".freeze
|
26
|
+
MEGAM_ERROR = "Megam::Error".freeze
|
27
|
+
MEGAM_ACCOUNT = "Megam::Account".freeze
|
28
|
+
MEGAM_ASSEMBLIES = "Megam::Assemblies".freeze
|
29
|
+
MEGAM_ASSEMBLIESCOLLECTION = "Megam::AssembliesCollection".freeze
|
30
|
+
MEGAM_ASSEMBLY = "Megam::Assembly".freeze
|
31
|
+
MEGAM_ASSEMBLYCOLLECTION = "Megam::AssemblyCollection".freeze
|
32
|
+
MEGAM_COMPONENTS = "Megam::Components".freeze
|
33
|
+
MEGAM_COMPONENTSCOLLECTION = "Megam::ComponentsCollection".freeze
|
34
|
+
MEGAM_REQUEST = "Megam::Request".freeze
|
35
|
+
MEGAM_REQUESTCOLLECTION = "Megam::RequestCollection".freeze
|
36
|
+
MEGAM_ORGANIZATION = "Megam::Organizations".freeze
|
37
|
+
MEGAM_DOMAIN = "Megam::Domains".freeze
|
38
|
+
|
39
|
+
MEGAM_PREDEFCLOUD = "Megam::PredefCloud".freeze
|
40
|
+
MEGAM_PREDEFCLOUDCOLLECTION = "Megam::PredefCloudCollection".freeze
|
41
|
+
MEGAM_CLOUDTOOLSETTING = "Megam::CloudToolSetting".freeze
|
42
|
+
MEGAM_CLOUDTOOLSETTINGCOLLECTION= "Megam::CloudToolSettingCollection".freeze
|
43
|
+
MEGAM_SSHKEY = "Megam::SshKey".freeze
|
44
|
+
MEGAM_SSHKEYCOLLECTION = "Megam::SshKeyCollection".freeze
|
45
|
+
MEGAM_MARKETPLACE = "Megam::MarketPlace".freeze
|
46
|
+
MEGAM_MARKETPLACECOLLECTION = "Megam::MarketPlaceCollection".freeze
|
47
|
+
MEGAM_MARKETPLACEADDON = "Megam::MarketPlaceAddons".freeze
|
48
|
+
MEGAM_MARKETPLACEADDONCOLLECTION= "Megam::MarketPlaceAddonsCollection".freeze
|
49
|
+
MEGAM_CSAR = "Megam::CSAR".freeze
|
50
|
+
MEGAM_CSARCOLLECTION = "Megam::CSARCollection".freeze
|
51
|
+
|
66
52
|
class <<self
|
67
53
|
# Increase the max nesting for JSON, which defaults
|
68
54
|
# to 19, and isn't enough for some (for example, a Node within a Node)
|
@@ -145,56 +131,26 @@ module Megam
|
|
145
131
|
Megam::Auth
|
146
132
|
when MEGAM_ACCOUNT
|
147
133
|
Megam::Account
|
148
|
-
when
|
149
|
-
Megam::
|
150
|
-
when
|
151
|
-
Megam::
|
152
|
-
when
|
153
|
-
Megam::
|
154
|
-
when
|
155
|
-
Megam::
|
156
|
-
when
|
157
|
-
Megam::
|
158
|
-
when
|
159
|
-
Megam::
|
160
|
-
when MEGAM_APPDEFNSCOLLECTION
|
161
|
-
Megam::AppdefnsCollection
|
162
|
-
when MEGAM_APPREQUESTCOLLECTION
|
163
|
-
Megam::AppRequestCollection
|
164
|
-
when MEGAM_BOLTREQUESTCOLLECTION
|
165
|
-
Megam::BoltRequestCollection
|
166
|
-
when MEGAM_BOLTDEFNSCOLLECTION
|
167
|
-
Megam::BoltdefnsCollection
|
134
|
+
when MEGAM_ASSEMBLIES
|
135
|
+
Megam::Assemblies
|
136
|
+
when MEGAM_ASSEMBLIESCOLLECTION
|
137
|
+
Megam::AssembliesCollection
|
138
|
+
when MEGAM_ASSEMBLY
|
139
|
+
Megam::Assembly
|
140
|
+
when MEGAM_ASSEMBLYCOLLECTION
|
141
|
+
Megam::AssemblyCollection
|
142
|
+
when MEGAM_COMPONENTS
|
143
|
+
Megam::Components
|
144
|
+
when MEGAM_COMPONENTSCOLLECTION
|
145
|
+
Megam::ComponentsCollection
|
168
146
|
when MEGAM_REQUEST
|
169
147
|
Megam::Request
|
170
148
|
when MEGAM_REQUESTCOLLECTION
|
171
149
|
Megam::RequestCollection
|
172
|
-
when MEGAM_PREDEF
|
173
|
-
Megam::Predef
|
174
|
-
when MEGAM_PREDEFCOLLECTION
|
175
|
-
Megam::PredefCollection
|
176
150
|
when MEGAM_PREDEFCLOUD
|
177
151
|
Megam::PredefCloud
|
178
152
|
when MEGAM_PREDEFCLOUDCOLLECTION
|
179
153
|
Megam::PredefCloudCollection
|
180
|
-
when MEGAM_CLOUDTOOL
|
181
|
-
Megam::CloudTool
|
182
|
-
when MEGAM_CLOUDTOOLCOLLECTION
|
183
|
-
Megam::CloudToolCollection
|
184
|
-
when MEGAM_CLOUDTOOLSETTING
|
185
|
-
Megam::CloudToolSetting
|
186
|
-
when MEGAM_CLOUDTOOLSETTINGCOLLECTION
|
187
|
-
Megam::CloudToolSettingCollection
|
188
|
-
when MEGAM_CLOUDTEMPLATE
|
189
|
-
Megam::CloudTemplate
|
190
|
-
when MEGAM_CLOUDTEMPLATECOLLECTION
|
191
|
-
Megam::CloudTemplateCollection
|
192
|
-
when MEGAM_CLOUDINSTRUCTION
|
193
|
-
Megam::CloudInstruction
|
194
|
-
when MEGAM_CLOUDINSTRUCTIONGROUP
|
195
|
-
Megam::CloudInstructionGroup
|
196
|
-
when MEGAM_CLOUDINSTRUCTIONCOLLECTION
|
197
|
-
Megam::CloudInstructionCollection
|
198
154
|
when MEGAM_SSHKEY
|
199
155
|
Megam::SshKey
|
200
156
|
when MEGAM_SSHKEYCOLLECTION
|
@@ -214,11 +170,7 @@ module Megam
|
|
214
170
|
when MEGAM_CSARCOLLECTION
|
215
171
|
Megam::CSARCollection
|
216
172
|
when MEGAM_DOMAIN
|
217
|
-
Megam::
|
218
|
-
when MEGAM_ASSEMBLIES
|
219
|
-
Megam::Assemblies
|
220
|
-
when MEGAM_ASSEMBLIESCOLLECTION
|
221
|
-
Megam::AssembliesCollection
|
173
|
+
Megam::Domains
|
222
174
|
else
|
223
175
|
raise JSON::ParserError, "Unsupported `json_class` type '#{json_class}'"
|
224
176
|
end
|
@@ -19,6 +19,7 @@ module Megam
|
|
19
19
|
def initialize(email=nil, api_key=nil)
|
20
20
|
@id = nil
|
21
21
|
@name = nil
|
22
|
+
@accounts_id = nil
|
22
23
|
@created_at = nil
|
23
24
|
super(email, api_key)
|
24
25
|
end
|
@@ -36,7 +37,13 @@ def id(arg=nil)
|
|
36
37
|
end
|
37
38
|
end
|
38
39
|
|
39
|
-
|
40
|
+
def accounts_id(arg=nil)
|
41
|
+
if arg != nil
|
42
|
+
@accounts_id = arg
|
43
|
+
else
|
44
|
+
@accounts_id
|
45
|
+
end
|
46
|
+
end
|
40
47
|
|
41
48
|
def name(arg=nil)
|
42
49
|
if arg != nil
|
@@ -64,6 +71,7 @@ end
|
|
64
71
|
index_hash["json_claz"] = self.class.name
|
65
72
|
index_hash["id"] = id
|
66
73
|
index_hash["name"] = name
|
74
|
+
index_hash["accounts_id"] = accounts_id
|
67
75
|
index_hash["created_at"] = created_at
|
68
76
|
index_hash
|
69
77
|
end
|
@@ -76,6 +84,7 @@ def for_json
|
|
76
84
|
result = {
|
77
85
|
"id" => id,
|
78
86
|
"name" => name,
|
87
|
+
"accounts_id" => accounts_id,
|
79
88
|
"created_at" => created_at
|
80
89
|
}
|
81
90
|
result
|
@@ -86,6 +95,7 @@ def self.json_create(o)
|
|
86
95
|
org = new
|
87
96
|
org.id(o["id"]) if o.has_key?("id")
|
88
97
|
org.name(o["name"]) if o.has_key?("name")
|
98
|
+
org.accounts_id(o["accounts_id"]) if o.has_key?("accounts_id")
|
89
99
|
org.created_at(o["created_at"]) if o.has_key?("created_at")
|
90
100
|
org
|
91
101
|
end
|
@@ -99,6 +109,7 @@ end
|
|
99
109
|
def from_hash(o)
|
100
110
|
@id = o[:id] if o.has_key?(:id)
|
101
111
|
@name = o[:name] if o.has_key?(:name)
|
112
|
+
@accounts_id = o[:accounts_id] if o.has_key?(:accounts_id)
|
102
113
|
@created_at = o[:created_at] if o.has_key?(:created_at)
|
103
114
|
self
|
104
115
|
end
|
data/test/test_assemblies.rb
CHANGED
@@ -3,8 +3,13 @@ require File.expand_path("#{File.dirname(__FILE__)}/test_helper")
|
|
3
3
|
class TestApps < MiniTest::Unit::TestCase
|
4
4
|
|
5
5
|
|
6
|
-
|
7
|
-
response = megams.get_assemblies
|
6
|
+
def test_get_assemblies
|
7
|
+
response = megams.get_assemblies
|
8
|
+
assert_equal(200, response.status)
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_get_assembly
|
12
|
+
response = megams.get_one_assemblies("AMS1133263480544165888")
|
8
13
|
assert_equal(200, response.status)
|
9
14
|
end
|
10
15
|
end
|
data/test/test_domains.rb
CHANGED
@@ -6,7 +6,7 @@ class TestDomains < MiniTest::Unit::TestCase
|
|
6
6
|
$normal = "normal-tom"
|
7
7
|
$tom_email = "tom@gomegam.com"
|
8
8
|
$bob_email = "bob@gomegam.com"
|
9
|
-
|
9
|
+
|
10
10
|
|
11
11
|
def test_get_domains_good
|
12
12
|
response =megams.get_domains(domain_name)
|
@@ -17,7 +17,7 @@ class TestDomains < MiniTest::Unit::TestCase
|
|
17
17
|
|
18
18
|
def test_post_domains_good
|
19
19
|
tmp_hash = {
|
20
|
-
"name" => "
|
20
|
+
"name" => "dmnname1"}
|
21
21
|
|
22
22
|
response =megams.post_domains(tmp_hash)
|
23
23
|
response.body.to_s
|
data/test/test_helper.rb
CHANGED
data/test/test_organizations.rb
CHANGED
@@ -6,21 +6,21 @@ class TestOrganizations < MiniTest::Unit::TestCase
|
|
6
6
|
$normal = "normal-tom"
|
7
7
|
$tom_email = "tom@gomegam.com"
|
8
8
|
$bob_email = "bob@gomegam.com"
|
9
|
-
|
9
|
+
|
10
10
|
|
11
11
|
def test_get_organizations_good
|
12
12
|
response =megams.get_organizations(sandbox_name)
|
13
13
|
response.body.to_s
|
14
14
|
assert_equal(200, response.status)
|
15
15
|
end
|
16
|
-
|
16
|
+
=begin
|
17
17
|
|
18
18
|
def test_post_organizations_good
|
19
19
|
tmp_hash = {
|
20
|
-
"name" => "
|
20
|
+
"name" => "orgname3"}
|
21
21
|
response =megams.post_organizations(tmp_hash)
|
22
22
|
response.body.to_s
|
23
23
|
assert_equal(201, response.status)
|
24
24
|
end
|
25
|
-
|
25
|
+
=end
|
26
26
|
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.19'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kishorekumar Neelamegam, Thomas Alrin, Subash Sethurajan, Rajthilak
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: excon
|
@@ -131,7 +131,9 @@ files:
|
|
131
131
|
- lib/megam/api.rb
|
132
132
|
- lib/megam/api/accounts.rb
|
133
133
|
- lib/megam/api/assemblies.rb
|
134
|
+
- lib/megam/api/assembly.rb
|
134
135
|
- lib/megam/api/cloud_tool_settings.rb
|
136
|
+
- lib/megam/api/components.rb
|
135
137
|
- lib/megam/api/csars.rb
|
136
138
|
- lib/megam/api/domains.rb
|
137
139
|
- lib/megam/api/errors.rb
|
@@ -146,9 +148,13 @@ files:
|
|
146
148
|
- lib/megam/core/account.rb
|
147
149
|
- lib/megam/core/assemblies.rb
|
148
150
|
- lib/megam/core/assemblies_collection.rb
|
151
|
+
- lib/megam/core/assembly.rb
|
152
|
+
- lib/megam/core/assembly_collection.rb
|
149
153
|
- lib/megam/core/auth.rb
|
150
154
|
- lib/megam/core/cloudtoolsetting.rb
|
151
155
|
- lib/megam/core/cloudtoolsetting_collection.rb
|
156
|
+
- lib/megam/core/components.rb
|
157
|
+
- lib/megam/core/components_collection.rb
|
152
158
|
- lib/megam/core/config.rb
|
153
159
|
- lib/megam/core/csar.rb
|
154
160
|
- lib/megam/core/csar_collection.rb
|
@@ -177,7 +183,9 @@ files:
|
|
177
183
|
- megam_api.gemspec
|
178
184
|
- test/test_accounts.rb
|
179
185
|
- test/test_assemblies.rb
|
186
|
+
- test/test_assembly.rb
|
180
187
|
- test/test_cloudtoolsettings.rb
|
188
|
+
- test/test_components.rb
|
181
189
|
- test/test_csars.rb
|
182
190
|
- test/test_domains.rb
|
183
191
|
- test/test_helper.rb
|