Class: Megam::Assembly
- Defined in:
- lib/megam/core/assembly.rb
Instance Attribute Summary
Attributes inherited from ServerAPI
Class Method Summary collapse
- .from_hash(o, tmp_email = nil, tmp_api_key = nil, tmp_host = nil) ⇒ Object
- .json_create(o) ⇒ Object
- .show(params) ⇒ Object
- .update(params) ⇒ Object
Instance Method Summary collapse
- #asms_id(arg = nil) ⇒ Object
- #assembly ⇒ Object
- #components(arg = []) ⇒ Object
- #created_at(arg = nil) ⇒ Object
- #error? ⇒ Boolean
- #for_json ⇒ Object
- #from_hash(o) ⇒ Object
- #id(arg = nil) ⇒ Object
-
#initialize(email = nil, api_key = nil, host = nil) ⇒ Assembly
constructor
A new instance of Assembly.
- #inputs(arg = []) ⇒ Object
- #name(arg = nil) ⇒ Object
- #operations(arg = nil) ⇒ Object
- #outputs(arg = []) ⇒ Object
- #policies(arg = []) ⇒ Object
- #requirements(arg = []) ⇒ Object
- #status(arg = nil) ⇒ Object
-
#to_hash ⇒ Object
Transform the ruby obj -> to a Hash.
-
#to_json(*a) ⇒ Object
Serialize this object as a hash: called from JsonCompat.
- #to_s ⇒ Object
- #tosca_type(arg = nil) ⇒ Object
-
#update ⇒ Object
Create the node via the REST API.
Methods inherited from ServerAPI
Constructor Details
#initialize(email = nil, api_key = nil, host = nil) ⇒ Assembly
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/megam/core/assembly.rb', line 19 def initialize(email=nil, api_key=nil, host=nil) @id = nil @asms_id = nil @name = nil @tosca_type = nil @components = [] @requirements = [] @policies=[] @inputs = [] @operations = [] @outputs = [] @status = nil @created_at = nil super(email, api_key, host) end |
Class Method Details
.from_hash(o, tmp_email = nil, tmp_api_key = nil, tmp_host = nil) ⇒ Object
199 200 201 202 203 |
# File 'lib/megam/core/assembly.rb', line 199 def self.from_hash(o,tmp_email=nil, tmp_api_key=nil, tmp_host=nil) asm = self.new(tmp_email, tmp_api_key, tmp_host) asm.from_hash(o) asm end |
.json_create(o) ⇒ Object
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
# File 'lib/megam/core/assembly.rb', line 182 def self.json_create(o) asm = new asm.id(o["id"]) if o.has_key?("id") asm.asms_id(o["asms_id"]) if o.has_key?("asms_id") asm.name(o["name"]) if o.has_key?("name") asm.tosca_type(o["tosca_type"]) if o.has_key?("tosca_type") asm.components(o["components"]) if o.has_key?("components") asm.requirements(o["requirements"]) if o.has_key?("requirements") asm.policies(o["policies"]) if o.has_key?("policies") #this will be an array? can hash store array? asm.inputs(o["inputs"]) if o.has_key?("inputs") asm.operations(o["operations"]) if o.has_key?("operations") asm.outputs(o["outputs"]) if o.has_key?("outputs") asm.status(o["status"]) if o.has_key?("status") asm.created_at(o["created_at"]) if o.has_key?("created_at") asm end |
.show(params) ⇒ Object
222 223 224 225 |
# File 'lib/megam/core/assembly.rb', line 222 def self.show(params) asm = self.new(params["email"], params["api_key"], params["host"]) asm.megam_rest.get_one_assembly(params["id"]) end |
.update(params) ⇒ Object
227 228 229 230 |
# File 'lib/megam/core/assembly.rb', line 227 def self.update(params) asm = from_hash(params, params["email"] || params[:email], params["api_key"] || params[:api_key], params["host"] || params[:host]) asm.update end |
Instance Method Details
#asms_id(arg = nil) ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/megam/core/assembly.rb', line 47 def asms_id(arg=nil) if arg != nil @asms_id = arg else @asms_id end end |
#assembly ⇒ Object
35 36 37 |
# File 'lib/megam/core/assembly.rb', line 35 def assembly self end |
#components(arg = []) ⇒ Object
71 72 73 74 75 76 77 |
# File 'lib/megam/core/assembly.rb', line 71 def components(arg=[]) if arg != [] @components = arg else @components end end |
#created_at(arg = nil) ⇒ Object
127 128 129 130 131 132 133 |
# File 'lib/megam/core/assembly.rb', line 127 def created_at(arg=nil) if arg != nil @created_at = arg else @created_at end end |
#error? ⇒ Boolean
135 136 137 |
# File 'lib/megam/core/assembly.rb', line 135 def error? crocked = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error") end |
#for_json ⇒ Object
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/megam/core/assembly.rb', line 164 def for_json result = { "id" => id, "name" => name, "tosca_type" => tosca_type, "components" => components, "requirements" => requirements, "policies" => policies, "inputs" => inputs, "operations" => operations, "outputs" => outputs, "status" => status, "created_at" => created_at } result end |
#from_hash(o) ⇒ Object
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
# File 'lib/megam/core/assembly.rb', line 205 def from_hash(o) @id = o["id"] if o.has_key?("id") @asms_id = o["asmd_id"] if o.has_key?("asms_id") @name = o["name"] if o.has_key?("name") @tosca_type = o["tosca_type"] if o.has_key?("tosca_type") @components = o["components"] if o.has_key?("components") @requirements = o["requirements"] if o.has_key?("requirements") @policies = o["policies"] if o.has_key?("policies") @inputs = o["inputs"] if o.has_key?("inputs") @operations = o["operations"] if o.has_key?("operations") @outputs = o["outputs"] if o.has_key?("outputs") @status = o["status"] if o.has_key?("status") @created_at = o["created_at"] if o.has_key?("created_at") self end |
#id(arg = nil) ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/megam/core/assembly.rb', line 39 def id(arg=nil) if arg != nil @id = arg else @id end end |
#inputs(arg = []) ⇒ Object
95 96 97 98 99 100 101 |
# File 'lib/megam/core/assembly.rb', line 95 def inputs(arg=[]) if arg != [] @inputs = arg else @inputs end end |
#name(arg = nil) ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/megam/core/assembly.rb', line 55 def name(arg=nil) if arg != nil @name = arg else @name end end |
#operations(arg = nil) ⇒ Object
103 104 105 106 107 108 109 |
# File 'lib/megam/core/assembly.rb', line 103 def operations(arg=nil) if arg != nil @operations = arg else @operations end end |
#outputs(arg = []) ⇒ Object
111 112 113 114 115 116 117 |
# File 'lib/megam/core/assembly.rb', line 111 def outputs(arg=[]) if arg != [] @outputs = arg else @outputs end end |
#policies(arg = []) ⇒ Object
87 88 89 90 91 92 93 |
# File 'lib/megam/core/assembly.rb', line 87 def policies(arg=[]) if arg != [] @policies = arg else @policies end end |
#requirements(arg = []) ⇒ Object
79 80 81 82 83 84 85 |
# File 'lib/megam/core/assembly.rb', line 79 def requirements(arg=[]) if arg != [] @requirements = arg else @requirements end end |
#status(arg = nil) ⇒ Object
119 120 121 122 123 124 125 |
# File 'lib/megam/core/assembly.rb', line 119 def status(arg=nil) if arg != nil @status = arg else @status end end |
#to_hash ⇒ Object
Transform the ruby obj -> to a Hash
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/megam/core/assembly.rb', line 140 def to_hash index_hash = Hash.new index_hash["json_claz"] = self.class.name index_hash["id"] = id index_hash["asms_id"] = asms_id index_hash["name"] = name index_hash["tosca_type"] = tosca_type index_hash["components"] = components index_hash["requirements"] = requirements index_hash["policies"] = policies index_hash["inputs"] = inputs index_hash["operations"] = operations 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.
160 161 162 |
# File 'lib/megam/core/assembly.rb', line 160 def to_json(*a) for_json.to_json(*a) end |
#to_s ⇒ Object
237 238 239 |
# File 'lib/megam/core/assembly.rb', line 237 def to_s Megam::Stuff.styled_hash(to_hash) end |
#tosca_type(arg = nil) ⇒ Object
63 64 65 66 67 68 69 |
# File 'lib/megam/core/assembly.rb', line 63 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
233 234 235 |
# File 'lib/megam/core/assembly.rb', line 233 def update megam_rest.update_assembly(to_hash) end |