class Megam::Backups

Public Class Methods

create(params) click to toggle source
# File lib/megam/core/backups.rb, line 219
def self.create(params)
    sps = from_hash(params)
    sps.create
end
from_hash(o) click to toggle source
# File lib/megam/core/backups.rb, line 197
def self.from_hash(o)
    sps = self.new(o)
    sps.from_hash(o)
    sps
end
json_create(o) click to toggle source
# File lib/megam/core/backups.rb, line 176
def self.json_create(o)
    sps = new({})
    sps.id(o["id"]) if o.has_key?("id")
    sps.account_id(o["account_id"]) if o.has_key?("account_id")
    sps.asm_id(o["asm_id"]) if o.has_key?("asm_id")
    sps.org_id(o["org_id"]) if o.has_key?("org_id") #this will be an array? can hash store array?
    sps.tosca_type(o['tosca_type']) if o.key?('tosca_type')
    sps.inputs(o['inputs']) if o.key?('inputs')
    sps.outputs(o['outputs']) if o.key?('outputs')
    sps.name(o["name"]) if o.has_key?("name")
    sps.status(o["status"]) if o.has_key?("status")
    sps.image_id(o["image_id"]) if o.has_key?("image_id")
    sps.created_at(o["created_at"]) if o.has_key?("created_at")
    sps.labels(o["labels"]) if o.key?("labels")
    sps.some_msg[:code] = o["code"] if o.has_key?("code")
    sps.some_msg[:msg_type] = o["msg_type"] if o.has_key?("msg_type")
    sps.some_msg[:msg]= o["msg"] if o.has_key?("msg")
    sps.some_msg[:links] = o["links"] if o.has_key?("links")
    sps
end
list(o) click to toggle source

Load a account by email_p

# File lib/megam/core/backups.rb, line 240
def self.list(o)
    sps = self.new(o)
    sps.megam_rest.get_backups(o[:id])
end
listall(params) click to toggle source
# File lib/megam/core/backups.rb, line 234
def self.listall(params)
    sps = self.new(params)
    sps.megam_rest.list_backups
end
new(o) click to toggle source
Calls superclass method Megam::RestAdapter::new
# File lib/megam/core/backups.rb, line 3
def initialize(o)
    @id = nil
    @account_id = nil
    @asm_id = nil
    @org_id = nil
    @tosca_type = nil
    @inputs = []
    @outputs = []
    @labels = []
    @name= nil
    @status=nil
    @image_id=nil
    @created_at = nil
    @some_msg = {}
    super(o)
end
show(o) click to toggle source
# File lib/megam/core/backups.rb, line 245
def self.show(o)
    sps = self.new(o)
    sps.megam_rest.get_one_backup(o[:id])
end
update(params) click to toggle source
# File lib/megam/core/backups.rb, line 224
def self.update(params)
    sps = from_hash(params)
    sps.update
end

Public Instance Methods

account_id(arg=nil) click to toggle source
# File lib/megam/core/backups.rb, line 31
def account_id(arg=nil)
    if arg != nil
        @account_id = arg
    else
        @account_id
    end
end
asm_id(arg=nil) click to toggle source
# File lib/megam/core/backups.rb, line 39
def asm_id(arg=nil)
    if arg != nil
        @asm_id = arg
    else
        @asm_id
    end
end
backups() click to toggle source
# File lib/megam/core/backups.rb, line 20
def backups
    self
end
create() click to toggle source

Create the node via the REST API

# File lib/megam/core/backups.rb, line 230
def create
    megam_rest.post_backups(to_hash)
end
created_at(arg=nil) click to toggle source
# File lib/megam/core/backups.rb, line 110
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/backups.rb, line 118
def error?
    crocked  = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error")
end
for_json() click to toggle source
# File lib/megam/core/backups.rb, line 158
def for_json
    result = {
        "id" => id,
        "account_id" => account_id,
        "asm_id" => asm_id,
        "org_id" => org_id,
        "tosca_type" => tosca_type,
        "inputs" => inputs,
        "outputs" => outputs,
        "name" => name,
        "status" => status,
        "image_id" => image_id,
        "created_at" => created_at,
        "labels" =>labels,
    }
    result
end
from_hash(o) click to toggle source
# File lib/megam/core/backups.rb, line 203
def from_hash(o)
    @id       = o[:id] if o.has_key?(:id)
    @account_id       = o[:account_id] if o.has_key?(:account_id)
    @asm_id        = o[:asm_id] if o.has_key?(:asm_id)
    @org_id        = o[:org_id] if o.has_key?(:org_id)
    @tosca_type        = o[:tosca_type] if o.key?(:tosca_type)
    @inputs            = o[:inputs] if o.key?(:inputs)
    @outputs           = o[:outputs] if o.key?(:outputs)
    @name            = o[:name] if o.has_key?(:name)
    @status            = o[:status] if o.has_key?(:status)
    @image_id          = o[:image_id] if o.has_key?(:image_id)
    @created_at        = o[:created_at] if o.has_key?(:created_at)
    @labels            = o[:labels] if o.key?(:labels)
    self
end
id(arg=nil) click to toggle source
# File lib/megam/core/backups.rb, line 23
def id(arg=nil)
    if arg != nil
        @id = arg
    else
        @id
    end
end
image_id(arg=nil) click to toggle source
# File lib/megam/core/backups.rb, line 102
def image_id(arg=nil)
    if arg != nil
        @image_id = arg
    else
        @image_id
    end
end
inputs(arg = []) click to toggle source
# File lib/megam/core/backups.rb, line 63
def inputs(arg = [])
    if arg != []
        @inputs = arg
    else
        @inputs
    end
end
labels(arg=[]) click to toggle source
# File lib/megam/core/backups.rb, line 70
 def labels(arg=[])
   if arg != []
      @labels=arg
   else
      @labels
    end
end
name(arg=nil) click to toggle source
# File lib/megam/core/backups.rb, line 86
def name(arg=nil)
    if arg != nil
        @name = arg
    else
        @name
    end
end
org_id(arg=nil) click to toggle source
# File lib/megam/core/backups.rb, line 47
def org_id(arg=nil)
    if arg != nil
        @org_id = arg
    else
        @org_id
    end
end
outputs(arg = []) click to toggle source
# File lib/megam/core/backups.rb, line 78
def outputs(arg = [])
    if arg != []
        @outputs = arg
    else
        @outputs
    end
end
some_msg(arg=nil) click to toggle source
# File lib/megam/core/backups.rb, line 123
def some_msg(arg=nil)
    if arg != nil
        @some_msg = arg
    else
        @some_msg
    end
end
status(arg=nil) click to toggle source
# File lib/megam/core/backups.rb, line 94
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/backups.rb, line 133
def to_hash
    index_hash = Hash.new
    index_hash["json_claz"] = self.class.name
    index_hash["id"] = id
    index_hash["account_id"] = account_id
    index_hash["asm_id"] = asm_id
    index_hash["org_id"] = org_id
    index_hash["labels"] = labels
    index_hash["tosca_type"] = tosca_type
    index_hash["inputs"] = inputs
    index_hash["outputs"] = outputs
    index_hash["name"] = name
    index_hash["status"] = status
    index_hash["image_id"] = image_id
    index_hash["created_at"] = created_at
    index_hash["some_msg"] = some_msg
    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/backups.rb, line 154
def to_json(*a)
    for_json.to_json(*a)
end
to_s() click to toggle source
# File lib/megam/core/backups.rb, line 254
def to_s
    Megam::Stuff.styled_hash(to_hash)
end
tosca_type(arg = nil) click to toggle source
# File lib/megam/core/backups.rb, line 55
def tosca_type(arg = nil)
    if !arg.nil?
        @tosca_type = arg
    else
        @tosca_type
    end
end
update() click to toggle source
# File lib/megam/core/backups.rb, line 250
def update
    megam_rest.update_backups(to_hash)
end