class Megam::Disks

Public Class Methods

create(params) click to toggle source
# File lib/megam/core/disks.rb, line 168
def self.create(params)
    dks = from_hash(params)
    dks.create
end
from_hash(o) click to toggle source
# File lib/megam/core/disks.rb, line 150
def self.from_hash(o)
    dks = self.new(o)
    dks.from_hash(o)
    dks
end
json_create(o) click to toggle source
# File lib/megam/core/disks.rb, line 133
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.disk_id(o["disk_id"]) if o.has_key?("disk_id")
    sps.size(o["size"]) if o.has_key?("size")
    sps.status(o["status"]) if o.has_key?("status")
    sps.created_at(o["created_at"]) if o.has_key?("created_at")
    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(params) click to toggle source
# File lib/megam/core/disks.rb, line 184
def self.list(params)
    dks = self.new(params)
    dks.megam_rest.list_disks
end
new(o) click to toggle source
Calls superclass method Megam::RestAdapter::new
# File lib/megam/core/disks.rb, line 3
def initialize(o)
    @id = nil
    @account_id = nil
    @asm_id = nil
    @org_id = nil
    @disk_id= nil
    @size= nil
    @status= nil
    @created_at = nil
    @some_msg = {}
    super(o)
end
remove(o) click to toggle source
# File lib/megam/core/disks.rb, line 189
def self.remove(o)
    dks = self.new(o)
    dks.megam_rest.remove_disks(o[:id], o[:disk_id])
end
show(o) click to toggle source

Load a account by email_p

# File lib/megam/core/disks.rb, line 179
def self.show(o)
    dks = self.new(o)
    dks.megam_rest.get_disks(o[:id])
end

Public Instance Methods

account_id(arg=nil) click to toggle source
# File lib/megam/core/disks.rb, line 27
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/disks.rb, line 35
def asm_id(arg=nil)
    if arg != nil
        @asm_id = arg
    else
        @asm_id
    end
end
create() click to toggle source

Create the node via the REST API

# File lib/megam/core/disks.rb, line 174
def create
    megam_rest.post_disks(to_hash)
end
created_at(arg=nil) click to toggle source
# File lib/megam/core/disks.rb, line 75
def created_at(arg=nil)
    if arg != nil
        @created_at = arg
    else
        @created_at
    end
end
disk_id(arg=nil) click to toggle source
# File lib/megam/core/disks.rb, line 51
def disk_id(arg=nil)
    if arg != nil
        @disk_id = arg
    else
        @disk_id
    end
end
disks() click to toggle source
# File lib/megam/core/disks.rb, line 16
def disks
    self
end
error?() click to toggle source
# File lib/megam/core/disks.rb, line 83
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/disks.rb, line 119
def for_json
    result = {
      "id" => id,
        "account_id" => account_id,
        "asm_id" => asm_id,
        "org_id" => org_id,
        "disk_id" => disk_id,
        "size" => size,
        "status" => status,
        "created_at" => created_at
    }
    result
end
from_hash(o) click to toggle source
# File lib/megam/core/disks.rb, line 156
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)
    @disk_id       = o[:disk_id] if o.has_key?(:disk_id)
    @size            = o[:size] if o.has_key?(:size)
    @status          = o[:status] if o.has_key?(:status)
    @created_at      = o[:created_at] if o.has_key?(:created_at)
    self
end
id(arg=nil) click to toggle source
# File lib/megam/core/disks.rb, line 19
def id(arg=nil)
    if arg != nil
        @id = arg
    else
        @id
    end
end
org_id(arg=nil) click to toggle source
# File lib/megam/core/disks.rb, line 43
def org_id(arg=nil)
    if arg != nil
        @org_id = arg
    else
        @org_id
    end
end
size(arg=nil) click to toggle source
# File lib/megam/core/disks.rb, line 67
def size(arg=nil)
    if arg != nil
        @size = arg
    else
        @size
    end
end
some_msg(arg=nil) click to toggle source
# File lib/megam/core/disks.rb, line 88
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/disks.rb, line 59
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/disks.rb, line 98
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["disk_id"] = disk_id
    index_hash["size"] = size
    index_hash["status"] = status
    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/disks.rb, line 115
def to_json(*a)
    for_json.to_json(*a)
end
to_s() click to toggle source
# File lib/megam/core/disks.rb, line 194
def to_s
    Megam::Stuff.styled_hash(to_hash)
end