Class: Megam::Disks
Instance Attribute Summary
Attributes inherited from RestAdapter
#api_key, #email, #headers, #host, #master_key, #password_hash
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from RestAdapter
#megam_rest
Constructor Details
#initialize(o) ⇒ Disks
Returns a new instance of Disks.
3
4
5
6
7
8
9
10
11
12
13
14
|
# 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
|
Class Method Details
.create(params) ⇒ Object
168
169
170
171
|
# File 'lib/megam/core/disks.rb', line 168
def self.create(params)
dks = from_hash(params)
dks.create
end
|
.from_hash(o) ⇒ Object
150
151
152
153
154
|
# 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) ⇒ Object
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
# 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")
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) ⇒ Object
184
185
186
187
|
# File 'lib/megam/core/disks.rb', line 184
def self.list(params)
dks = self.new(params)
dks.megam_rest.list_disks
end
|
.show(o) ⇒ Object
Load a account by email_p
179
180
181
182
|
# File 'lib/megam/core/disks.rb', line 179
def self.show(o)
dks = self.new(o)
dks.megam_rest.get_disks(o[:id])
end
|
Instance Method Details
#account_id(arg = nil) ⇒ Object
27
28
29
30
31
32
33
|
# 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) ⇒ Object
35
36
37
38
39
40
41
|
# 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 ⇒ Object
Create the node via the REST API
174
175
176
|
# File 'lib/megam/core/disks.rb', line 174
def create
megam_rest.post_disks(to_hash)
end
|
#created_at(arg = nil) ⇒ Object
75
76
77
78
79
80
81
|
# 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) ⇒ Object
51
52
53
54
55
56
57
|
# 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 ⇒ Object
16
17
18
|
# File 'lib/megam/core/disks.rb', line 16
def disks
self
end
|
#error? ⇒ Boolean
83
84
85
|
# 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 ⇒ Object
119
120
121
122
123
124
125
126
127
128
129
130
131
|
# 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) ⇒ Object
156
157
158
159
160
161
162
163
164
165
166
|
# 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) ⇒ Object
19
20
21
22
23
24
25
|
# 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) ⇒ Object
43
44
45
46
47
48
49
|
# 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) ⇒ Object
67
68
69
70
71
72
73
|
# 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) ⇒ Object
88
89
90
91
92
93
94
|
# 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) ⇒ Object
59
60
61
62
63
64
65
|
# File 'lib/megam/core/disks.rb', line 59
def status(arg=nil)
if arg != nil
@status = arg
else
@status
end
end
|
#to_hash ⇒ Object
Transform the ruby obj -> to a Hash
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
# 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) ⇒ Object
Serialize this object as a hash: called from JsonCompat. Verify if this called from JsonCompat during testing.
115
116
117
|
# File 'lib/megam/core/disks.rb', line 115
def to_json(*a)
for_json.to_json(*a)
end
|
#to_s ⇒ Object
189
190
191
|
# File 'lib/megam/core/disks.rb', line 189
def to_s
Megam::Stuff.styled_hash(to_hash)
end
|