class Megam::Assembly

Public Class Methods

from_hash(o) click to toggle source
# File lib/megam/core/assembly.rb, line 171
def self.from_hash(o)
    asm = new(o)
    asm.from_hash(o)
    asm
end
json_create(o) click to toggle source
# File lib/megam/core/assembly.rb, line 155
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') # this will be an array? can hash store array?
    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.state(o['state']) if o.key?('state')
    asm.created_at(o['created_at']) if o.key?('created_at')
    asm
end
list(params) click to toggle source
# File lib/megam/core/assembly.rb, line 207
def self.list(params)
    asm = self.new(params)
    asm.megam_rest.list_assembly
end
new(o) click to toggle source
Calls superclass method Megam::RestAdapter::new
# File lib/megam/core/assembly.rb, line 3
def initialize(o)
    @id = nil
    @asms_id = nil
    @name = nil
    @components = []
    @tosca_type = nil
    @policies = []
    @inputs = []
    @outputs = []
    @status = nil
    @state = nil
    @created_at = nil
    super(o)
end
remove(params) click to toggle source
# File lib/megam/core/assembly.rb, line 212
def self.remove(params)
    asm = self.new(params)
    asm.megam_rest.delete_assembly(params['id'], params['asms_id'])
end
show(params) click to toggle source
# File lib/megam/core/assembly.rb, line 192
def self.show(params)
    asm = new(params)
    asm.megam_rest.get_one_assembly(params['id'])
end
update(params) click to toggle source
# File lib/megam/core/assembly.rb, line 197
def self.update(params)
    asm = from_hash(params)
    asm.update
end
upgrade(params) click to toggle source
# File lib/megam/core/assembly.rb, line 202
def self.upgrade(params)
    asm = from_hash(params)
    asm.megam_rest.upgrade_assembly(params['id'])
end

Public Instance Methods

asms_id(arg=nil) click to toggle source
# File lib/megam/core/assembly.rb, line 30
def asms_id(arg=nil)
    if arg != nil
        @asms_id = arg
    else
        @asms_id
    end
end
assembly() click to toggle source
# File lib/megam/core/assembly.rb, line 18
def assembly
    self
end
components(arg = []) click to toggle source
# File lib/megam/core/assembly.rb, line 54
def components(arg = [])
    if arg != []
        @components = arg
    else
        @components
    end
end
created_at(arg = nil) click to toggle source
# File lib/megam/core/assembly.rb, line 102
def created_at(arg = nil)
    if !arg.nil?
        @created_at = arg
    else
        @created_at
    end
end
error?() click to toggle source
# File lib/megam/core/assembly.rb, line 110
def error?
    crocked = true if some_msg.key?(:msg_type) && some_msg[:msg_type] == 'error'
end
for_json() click to toggle source
# File lib/megam/core/assembly.rb, line 138
def for_json
    result = {
        'id' => id,
        'name' => name,
        'components' => components,
        'tosca_type' => tosca_type,
        'policies' => policies,
        'inputs' => inputs,
        'outputs' => outputs,
        'status' => status,
        'state' => state,
        'created_at' => created_at
    }

    result
end
from_hash(o) click to toggle source
# File lib/megam/core/assembly.rb, line 177
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')
    @state            = o['state'] if o.key?('state')
    @created_at        = o['created_at'] if o.key?('created_at')
    self
end
id(arg = nil) click to toggle source
# File lib/megam/core/assembly.rb, line 22
def id(arg = nil)
    if !arg.nil?
        @id = arg
    else
        @id
    end
end
inputs(arg = []) click to toggle source
# File lib/megam/core/assembly.rb, line 70
def inputs(arg = [])
    if arg != []
        @inputs = arg
    else
        @inputs
    end
end
name(arg = nil) click to toggle source
# File lib/megam/core/assembly.rb, line 38
def name(arg = nil)
    if !arg.nil?
        @name = arg
    else
        @name
    end
end
outputs(arg = []) click to toggle source
# File lib/megam/core/assembly.rb, line 78
def outputs(arg = [])
    if arg != []
        @outputs = arg
    else
        @outputs
    end
end
policies(arg = []) click to toggle source
# File lib/megam/core/assembly.rb, line 62
def policies(arg = [])
    if arg != []
        @policies = arg
    else
        @policies
    end
end
state(arg = nil) click to toggle source
# File lib/megam/core/assembly.rb, line 94
def state(arg = nil)
    if !arg.nil?
        @state = arg
    else
        @state
    end
end
status(arg = nil) click to toggle source
# File lib/megam/core/assembly.rb, line 86
def status(arg = nil)
    if !arg.nil?
        @status = arg
    else
        @status
    end
end
to_hash() click to toggle source

Transform the ruby obj -> to a Hash

# File lib/megam/core/assembly.rb, line 115
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['state'] = state
    index_hash['created_at'] = created_at
    index_hash
end
to_json(*a) click to toggle source

Serialize this object as a hash: called from JsonCompat. Verify if this called from JsonCompat during testing.

# File lib/megam/core/assembly.rb, line 134
def to_json(*a)
    for_json.to_json(*a)
end
to_s() click to toggle source
# File lib/megam/core/assembly.rb, line 222
def to_s
    Megam::Stuff.styled_hash(to_hash)
end
tosca_type(arg = nil) click to toggle source
# File lib/megam/core/assembly.rb, line 46
def tosca_type(arg = nil)
    if !arg.nil?
        @tosca_type = arg
    else
        @tosca_type
    end
end
update() click to toggle source

Create the node via the REST API

# File lib/megam/core/assembly.rb, line 218
def update
    megam_rest.update_assembly(to_hash)
end