Class: Megam::Snapshots
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
Returns a new instance of Snapshots.
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/megam/core/snapshots.rb', line 3
def initialize(o)
@id = nil
@account_id = nil
@asm_id = nil
@org_id = nil
@tosca_type = nil
@inputs = []
@outputs = []
@name= nil
@status=nil
@disk_id=nil
@snap_id=nil
@created_at = nil
@updated_at = nil
@some_msg = {}
super(o)
end
|
Class Method Details
.create(params) ⇒ Object
233
234
235
236
|
# File 'lib/megam/core/snapshots.rb', line 233
def self.create(params)
sps = from_hash(params)
sps.create
end
|
.from_hash(o) ⇒ Object
210
211
212
213
214
|
# File 'lib/megam/core/snapshots.rb', line 210
def self.from_hash(o)
sps = self.new(o)
sps.from_hash(o)
sps
end
|
.json_create(o) ⇒ Object
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
|
# File 'lib/megam/core/snapshots.rb', line 188
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.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.disk_id(o["disk_id"]) if o.has_key?("disk_id")
sps.snap_id(o["snap_id"]) if o.has_key?("snap_id")
sps.created_at(o["created_at"]) if o.has_key?("created_at")
sps.created_at(o["updated_at"]) if o.has_key?("updated_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
254
255
256
257
|
# File 'lib/megam/core/snapshots.rb', line 254
def self.list(params)
sps = self.new(params)
sps.megam_rest.list_snapshots
end
|
.show(o) ⇒ Object
Load a account by email_p
249
250
251
252
|
# File 'lib/megam/core/snapshots.rb', line 249
def self.show(o)
sps = self.new(o)
sps.megam_rest.get_snapshots(o[:id])
end
|
.update(params) ⇒ Object
238
239
240
241
|
# File 'lib/megam/core/snapshots.rb', line 238
def self.update(params)
sps = from_hash(params)
sps.update
end
|
Instance Method Details
#account_id(arg = nil) ⇒ Object
32
33
34
35
36
37
38
|
# File 'lib/megam/core/snapshots.rb', line 32
def account_id(arg=nil)
if arg != nil
@account_id = arg
else
@account_id
end
end
|
#asm_id(arg = nil) ⇒ Object
40
41
42
43
44
45
46
|
# File 'lib/megam/core/snapshots.rb', line 40
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
244
245
246
|
# File 'lib/megam/core/snapshots.rb', line 244
def create
megam_rest.post_snapshots(to_hash)
end
|
#created_at(arg = nil) ⇒ Object
112
113
114
115
116
117
118
|
# File 'lib/megam/core/snapshots.rb', line 112
def created_at(arg=nil)
if arg != nil
@created_at = arg
else
@created_at
end
end
|
#disk_id(arg = nil) ⇒ Object
96
97
98
99
100
101
102
|
# File 'lib/megam/core/snapshots.rb', line 96
def disk_id(arg=nil)
if arg != nil
@disk_id = arg
else
@disk_id
end
end
|
#error? ⇒ Boolean
128
129
130
|
# File 'lib/megam/core/snapshots.rb', line 128
def error?
crocked = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error")
end
|
#for_json ⇒ Object
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
|
# File 'lib/megam/core/snapshots.rb', line 169
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,
"disk_id" => disk_id,
"snap_id" => snap_id,
"created_at" => created_at,
"updated_at" => updated_at
}
result
end
|
#from_hash(o) ⇒ Object
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
|
# File 'lib/megam/core/snapshots.rb', line 216
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)
@disk_id = o[:disk_id] if o.has_key?(:disk_id)
@snap_id = o[:snap_id] if o.has_key?(:snap_id)
@created_at = o[:created_at] if o.has_key?(:created_at)
@updated_at = o[:updated_at] if o.has_key?(:updated_at)
self
end
|
#id(arg = nil) ⇒ Object
24
25
26
27
28
29
30
|
# File 'lib/megam/core/snapshots.rb', line 24
def id(arg=nil)
if arg != nil
@id = arg
else
@id
end
end
|
64
65
66
67
68
69
70
|
# File 'lib/megam/core/snapshots.rb', line 64
def inputs(arg = [])
if arg != []
@inputs = arg
else
@inputs
end
end
|
#name(arg = nil) ⇒ Object
80
81
82
83
84
85
86
|
# File 'lib/megam/core/snapshots.rb', line 80
def name(arg=nil)
if arg != nil
@name = arg
else
@name
end
end
|
#org_id(arg = nil) ⇒ Object
48
49
50
51
52
53
54
|
# File 'lib/megam/core/snapshots.rb', line 48
def org_id(arg=nil)
if arg != nil
@org_id = arg
else
@org_id
end
end
|
#outputs(arg = []) ⇒ Object
72
73
74
75
76
77
78
|
# File 'lib/megam/core/snapshots.rb', line 72
def outputs(arg = [])
if arg != []
@outputs = arg
else
@outputs
end
end
|
#snap_id(arg = nil) ⇒ Object
104
105
106
107
108
109
110
|
# File 'lib/megam/core/snapshots.rb', line 104
def snap_id(arg=nil)
if arg != nil
@snap_id = arg
else
@snap_id
end
end
|
#snapshots ⇒ Object
21
22
23
|
# File 'lib/megam/core/snapshots.rb', line 21
def snapshots
self
end
|
#some_msg(arg = nil) ⇒ Object
133
134
135
136
137
138
139
|
# File 'lib/megam/core/snapshots.rb', line 133
def some_msg(arg=nil)
if arg != nil
@some_msg = arg
else
@some_msg
end
end
|
#status(arg = nil) ⇒ Object
88
89
90
91
92
93
94
|
# File 'lib/megam/core/snapshots.rb', line 88
def status(arg=nil)
if arg != nil
@status = arg
else
@status
end
end
|
#to_hash ⇒ Object
Transform the ruby obj -> to a Hash
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
# File 'lib/megam/core/snapshots.rb', line 143
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["tosca_type"] = tosca_type
index_hash["inputs"] = inputs
index_hash["outputs"] = outputs
index_hash["name"] = name
index_hash["status"] = status
index_hash["disk_id"] = disk_id
index_hash["snap_id"] = snap_id
index_hash["created_at"] = created_at
index_hash["updated_at"] = updated_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.
165
166
167
|
# File 'lib/megam/core/snapshots.rb', line 165
def to_json(*a)
for_json.to_json(*a)
end
|
#to_s ⇒ Object
263
264
265
|
# File 'lib/megam/core/snapshots.rb', line 263
def to_s
Megam::Stuff.styled_hash(to_hash)
end
|
#tosca_type(arg = nil) ⇒ Object
56
57
58
59
60
61
62
|
# File 'lib/megam/core/snapshots.rb', line 56
def tosca_type(arg = nil)
if !arg.nil?
@tosca_type = arg
else
@tosca_type
end
end
|
#update ⇒ Object
259
260
261
|
# File 'lib/megam/core/snapshots.rb', line 259
def update
megam_rest.update_snapshots(to_hash)
end
|
#updated_at(arg = nil) ⇒ Object
120
121
122
123
124
125
126
|
# File 'lib/megam/core/snapshots.rb', line 120
def updated_at(arg=nil)
if arg != nil
@updated_at = arg
else
@updated_at
end
end
|