Class: Megam::Assembly
Instance Attribute Summary
Attributes inherited from ServerAPI
#api_key, #email, #host, #org_id, #password
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from ServerAPI
#megam_rest
Constructor Details
#initialize(o) ⇒ Assembly
Returns a new instance of Assembly.
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/megam/core/assembly.rb', line 19
def initialize(o)
@id = nil
@asms_id = nil
@name = nil
@components = []
@tosca_type = nil
@policies = []
@inputs = []
@outputs = []
@status = nil
@created_at = nil
super(o)
end
|
Class Method Details
.from_hash(o) ⇒ Object
176
177
178
179
180
|
# File 'lib/megam/core/assembly.rb', line 176
def self.from_hash(o)
asm = new(o)
asm.from_hash(o)
asm
end
|
.json_create(o) ⇒ Object
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
# File 'lib/megam/core/assembly.rb', line 161
def self.json_create(o)
asm = new({})
asm.id(o['id']) if o.key?('id')
asm.asms_id(o["asms_id"]) if o.has_key?("asms_id")
asm.name(o['name']) if o.key?('name')
asm.components(o['components']) if o.key?('components')
asm.tosca_type(o['tosca_type']) if o.key?('tosca_type')
asm.policies(o['policies']) if o.key?('policies') asm.inputs(o['inputs']) if o.key?('inputs')
asm.outputs(o['outputs']) if o.key?('outputs')
asm.status(o['status']) if o.key?('status')
asm.created_at(o['created_at']) if o.key?('created_at')
asm
end
|
.show(params) ⇒ Object
196
197
198
199
|
# File 'lib/megam/core/assembly.rb', line 196
def self.show(params)
asm = new(params)
asm.megam_rest.get_one_assembly(params['id'])
end
|
.update(params) ⇒ Object
201
202
203
204
|
# File 'lib/megam/core/assembly.rb', line 201
def self.update(params)
asm = from_hash(params)
asm.update
end
|
.upgrade(params) ⇒ Object
206
207
208
209
|
# File 'lib/megam/core/assembly.rb', line 206
def self.upgrade(params)
asm = from_hash(params)
asm.megam_rest.upgrade_assembly(params['id'])
end
|
Instance Method Details
#asms_id(arg = nil) ⇒ Object
46
47
48
49
50
51
52
|
# File 'lib/megam/core/assembly.rb', line 46
def asms_id(arg=nil)
if arg != nil
@asms_id = arg
else
@asms_id
end
end
|
#assembly ⇒ Object
34
35
36
|
# File 'lib/megam/core/assembly.rb', line 34
def assembly
self
end
|
#components(arg = []) ⇒ Object
70
71
72
73
74
75
76
|
# File 'lib/megam/core/assembly.rb', line 70
def components(arg = [])
if arg != []
@components = arg
else
@components
end
end
|
#created_at(arg = nil) ⇒ Object
110
111
112
113
114
115
116
|
# File 'lib/megam/core/assembly.rb', line 110
def created_at(arg = nil)
if !arg.nil?
@created_at = arg
else
@created_at
end
end
|
#error? ⇒ Boolean
118
119
120
|
# File 'lib/megam/core/assembly.rb', line 118
def error?
crocked = true if some_msg.key?(:msg_type) && some_msg[:msg_type] == 'error'
end
|
#for_json ⇒ Object
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
# File 'lib/megam/core/assembly.rb', line 145
def for_json
result = {
'id' => id,
'name' => name,
'components' => components,
'tosca_type' => tosca_type,
'policies' => policies,
'inputs' => inputs,
'outputs' => outputs,
'status' => status,
'created_at' => created_at
}
result
end
|
#from_hash(o) ⇒ Object
182
183
184
185
186
187
188
189
190
191
192
193
194
|
# File 'lib/megam/core/assembly.rb', line 182
def from_hash(o)
@id = o['id'] if o.key?('id')
@asms_id = o["asms_id"] if o.has_key?("asms_id")
@name = o['name'] if o.key?('name')
@components = o['components'] if o.key?('components')
@tosca_type = o['tosca_type'] if o.key?('tosca_type')
@policies = o['policies'] if o.key?('policies')
@inputs = o['inputs'] if o.key?('inputs')
@outputs = o['outputs'] if o.key?('outputs')
@status = o['status'] if o.key?('status')
@created_at = o['created_at'] if o.key?('created_at')
self
end
|
#id(arg = nil) ⇒ Object
38
39
40
41
42
43
44
|
# File 'lib/megam/core/assembly.rb', line 38
def id(arg = nil)
if !arg.nil?
@id = arg
else
@id
end
end
|
86
87
88
89
90
91
92
|
# File 'lib/megam/core/assembly.rb', line 86
def inputs(arg = [])
if arg != []
@inputs = arg
else
@inputs
end
end
|
#name(arg = nil) ⇒ Object
54
55
56
57
58
59
60
|
# File 'lib/megam/core/assembly.rb', line 54
def name(arg = nil)
if !arg.nil?
@name = arg
else
@name
end
end
|
#outputs(arg = []) ⇒ Object
94
95
96
97
98
99
100
|
# File 'lib/megam/core/assembly.rb', line 94
def outputs(arg = [])
if arg != []
@outputs = arg
else
@outputs
end
end
|
#policies(arg = []) ⇒ Object
78
79
80
81
82
83
84
|
# File 'lib/megam/core/assembly.rb', line 78
def policies(arg = [])
if arg != []
@policies = arg
else
@policies
end
end
|
#status(arg = nil) ⇒ Object
102
103
104
105
106
107
108
|
# File 'lib/megam/core/assembly.rb', line 102
def status(arg = nil)
if !arg.nil?
@status = arg
else
@status
end
end
|
#to_hash ⇒ Object
Transform the ruby obj -> to a Hash
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
# File 'lib/megam/core/assembly.rb', line 123
def to_hash
index_hash = {}
index_hash['json_claz'] = self.class.name
index_hash['id'] = id
index_hash["asms_id"] = asms_id
index_hash['name'] = name
index_hash['components'] = components
index_hash['tosca_type'] = tosca_type
index_hash['policies'] = policies
index_hash['inputs'] = inputs
index_hash['outputs'] = outputs
index_hash['status'] = status
index_hash['created_at'] = created_at
index_hash
end
|
#to_json(*a) ⇒ Object
Serialize this object as a hash: called from JsonCompat. Verify if this called from JsonCompat during testing.
141
142
143
|
# File 'lib/megam/core/assembly.rb', line 141
def to_json(*a)
for_json.to_json(*a)
end
|
#tosca_type(arg = nil) ⇒ Object
62
63
64
65
66
67
68
|
# File 'lib/megam/core/assembly.rb', line 62
def tosca_type(arg = nil)
if !arg.nil?
@tosca_type = arg
else
@tosca_type
end
end
|
#update ⇒ Object
Create the node via the REST API
212
213
214
|
# File 'lib/megam/core/assembly.rb', line 212
def update
megam_rest.update_assembly(to_hash)
end
|