class Megam::Components

Public Class Methods

create(params) click to toggle source
# File lib/megam/core/components.rb, line 301
def self.create(params)
    asm = from_hash(params)
    asm.create
end
from_hash(o) click to toggle source
# File lib/megam/core/components.rb, line 278
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/components.rb, line 250
def self.json_create(o)
    asm = new({})
    asm.id(o['id']) if o.key?('id')
    asm.name(o['name']) if o.key?('name')
    asm.tosca_type(o['tosca_type']) if o.key?('tosca_type')
    asm.inputs(o['inputs']) if o.key?('inputs')
    asm.outputs(o['outputs']) if o.key?('outputs')
    asm.envs(o['envs']) if o.key?('envs')
    ar = o['artifacts']
    asm.artifacts[:artifact_type] = ar['artifact_type'] if ar && ar.key?('artifact_type')
    asm.artifacts[:content] = ar['content'] if ar && ar.key?('content')
    asm.artifacts[:artifact_requirements] = ar['artifact_requirements'] if ar && ar.key?('artifact_requirements')

    asm.related_components(o['related_components']) if o.key?('related_components')
    asm.operations(o['operations']) if o.key?('operations')
    asm.status(o['status']) if o.key?('status')
    asm.state(o['state']) if o.key?('state')

    ro = o['repo']
    asm.repo[:rtype] = ro['rtype'] if ro && ro.key?('rtype')
    asm.repo[:source] = ro['source'] if ro && ro.key?('source')
    asm.repo[:oneclick] = ro['oneclick'] if ro && ro.key?('oneclick')
    asm.repo[:branch] = ro['branch'] if ro && ro.key?('branch')
    asm.repo[:url] = ro['url'] if ro && ro.key?('url')
    asm.created_at(o['created_at']) if o.key?('created_at')
    asm
end
new(o) click to toggle source
Calls superclass method Megam::RestAdapter::new
# File lib/megam/core/components.rb, line 3
def initialize(o)
    @id = nil
    @name = nil
    @tosca_type = nil
    @inputs = []
    @outputs = []
    @envs = []
    @artifacts = {}
    @artifact_type = nil
    @content = nil
    @artifact_requirements = []
    @related_components = []
    @operations = []
    @status = nil
    @state = nil
    @repo = {}
    @rtype = nil
    @source = nil
    @oneclick = nil
    @branch = nil
    @url = nil
    @created_at = nil

    super(o)
end
show(params) click to toggle source

Load a account by email_p

# File lib/megam/core/components.rb, line 307
def self.show(params)
    asm = new(params)
    asm.megam_rest.get_components(params['id'])
end
update(params) click to toggle source
# File lib/megam/core/components.rb, line 312
def self.update(params)
    asm = from_hash(params)
    asm.update
end

Public Instance Methods

artifact_requirements(arg = []) click to toggle source
# File lib/megam/core/components.rb, line 105
def artifact_requirements(arg = [])
    if arg != []
        @artifact_requirements = arg
    else
        @artifact_requirements
    end
end
artifact_type(arg = nil) click to toggle source
# File lib/megam/core/components.rb, line 89
def artifact_type(arg = nil)
    if !arg.nil?
        @artifact_type = arg
    else
        @artifact_type
    end
end
artifacts(arg = nil) click to toggle source
# File lib/megam/core/components.rb, line 81
def artifacts(arg = nil)
    if !arg.nil?
        @artifacts = arg
    else
        @artifacts
    end
end
branch(arg = nil) click to toggle source
# File lib/megam/core/components.rb, line 177
def branch(arg = nil)
    if !arg.nil?
        @branch = arg
    else
        @branch
    end
end
components() click to toggle source
# File lib/megam/core/components.rb, line 29
def components
    self
end
content(arg = nil) click to toggle source
# File lib/megam/core/components.rb, line 97
def content(arg = nil)
    if !arg.nil?
        @content = arg
    else
        @content
    end
end
created_at(arg = nil) click to toggle source
# File lib/megam/core/components.rb, line 193
def created_at(arg = nil)
    if !arg.nil?
        @created_at = arg
    else
        @created_at
    end
end
envs(arg = []) click to toggle source
# File lib/megam/core/components.rb, line 73
def envs(arg = [])
    if arg != []
        @envs = arg
    else
        @envs
    end
end
error?() click to toggle source
# File lib/megam/core/components.rb, line 201
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/components.rb, line 231
def for_json
    result = {
        'id' => id,
        'name' => name,
        'tosca_type' => tosca_type,
        'inputs' => inputs,
        'outputs' => outputs,
        'envs' => envs,
        'artifacts' => artifacts,
        'related_components' => related_components,
        'operations' => operations,
        'status' => status,
        'state' => state,
        'repo' => repo,
        'created_at' => created_at
    }
    result
end
from_hash(o) click to toggle source
# File lib/megam/core/components.rb, line 284
def from_hash(o)
    @id                              = o['id'] if o.key?('id')
    @name                            = o['name'] if o.key?('name')
    @tosca_type                      = o['tosca_type'] if o.key?('tosca_type')
    @inputs                          = o['inputs'] if o.key?('inputs')
    @outputs                         = o['outputs'] if o.key?('outputs')
    @envs                            = o['envs'] if o.key?('envs')
    @artifacts                       = o['artifacts'] if o.key?('artifacts')
    @related_components              = o['related_components'] if o.key?('related_components')
    @operations                      = o['operations'] if o.key?('operations')
    @status                          = o['status'] if o.key?('status')
    @state                          = o['state'] if o.key?('state')
    @repo                            = o['repo'] if o.key?('repo')
    @created_at                      = o['created_at'] if o.key?('created_at')
    self
end
id(arg = nil) click to toggle source
# File lib/megam/core/components.rb, line 33
def id(arg = nil)
    if !arg.nil?
        @id = arg
    else
        @id
    end
end
inputs(arg = []) click to toggle source
# File lib/megam/core/components.rb, line 57
def inputs(arg = [])
    if arg != []
        @inputs = arg
    else
        @inputs
    end
end
name(arg = nil) click to toggle source
# File lib/megam/core/components.rb, line 41
def name(arg = nil)
    if !arg.nil?
        @name = arg
    else
        @name
    end
end
oneclick(arg = nil) click to toggle source
# File lib/megam/core/components.rb, line 169
def oneclick(arg = nil)
    if !arg.nil?
        @oneclick = arg
    else
        @oneclick
    end
end
operations(arg = []) click to toggle source
# File lib/megam/core/components.rb, line 121
def operations(arg = [])
    if arg != []
        @operations = arg
    else
        @operations
    end
end
outputs(arg = []) click to toggle source
# File lib/megam/core/components.rb, line 65
def outputs(arg = [])
    if arg != []
        @outputs = arg
    else
        @outputs
    end
end
repo(arg = nil) click to toggle source
# File lib/megam/core/components.rb, line 145
def repo(arg = nil)
    if !arg.nil?
        @repo = arg
    else
        @repo
    end
end
rtype(arg = nil) click to toggle source
# File lib/megam/core/components.rb, line 153
def rtype(arg = nil)
    if !arg.nil?
        @rtype = arg
    else
        @rtype
    end
end
source(arg = nil) click to toggle source
# File lib/megam/core/components.rb, line 161
def source(arg = nil)
    if !arg.nil?
        @source = arg
    else
        @source
    end
end
state(arg = nil) click to toggle source
# File lib/megam/core/components.rb, line 137
def state(arg = nil)
    if !arg.nil?
        @state = arg
    else
        @state
    end
end
status(arg = nil) click to toggle source
# File lib/megam/core/components.rb, line 129
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/components.rb, line 206
def to_hash
    index_hash = {}
    index_hash['json_claz'] = self.class.name
    index_hash['id'] = id
    index_hash['name'] = name
    index_hash['tosca_type'] = tosca_type
    index_hash['inputs'] = inputs
    index_hash['outputs'] = outputs
    index_hash['envs'] = envs
    index_hash['artifacts'] = artifacts
    index_hash['related_components'] = related_components
    index_hash['operations'] = operations
    index_hash['status'] = status
    index_hash['state'] = state
    index_hash['repo'] = repo
    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/components.rb, line 227
def to_json(*a)
    for_json.to_json(*a)
end
to_s() click to toggle source
# File lib/megam/core/components.rb, line 322
def to_s
    Megam::Stuff.styled_hash(to_hash)
end
tosca_type(arg = nil) click to toggle source
# File lib/megam/core/components.rb, line 49
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/components.rb, line 318
def update
    megam_rest.update_component(to_hash)
end
url(arg = nil) click to toggle source
# File lib/megam/core/components.rb, line 185
def url(arg = nil)
    if !arg.nil?
        @url = arg
    else
        @url
    end
end