Class: Megam::CSAR
Instance Attribute Summary
Attributes inherited from ServerAPI
#api_key, #email, #host, #org_id, #password
Class Method Summary
collapse
-
.create(o, tmp_email = nil, tmp_api_key = nil, tmp_host = nil) ⇒ Object
This won’t work, as the body just needs the yaml string.
-
.from_hash(o, tmp_email = nil, tmp_api_key = nil, tmp_host = nil) ⇒ Object
-
.json_create(o) ⇒ Object
-
.list(tmp_email = nil, tmp_api_key = nil, tmp_host = nil) ⇒ Object
-
.push(tmp_email = nil, tmp_api_key = nil, tmp_host = nil, csar_id) ⇒ Object
-
.show(tmp_email = nil, tmp_api_key = nil, tmp_host = nil, csarlink_name) ⇒ Object
Load the yaml back from the link.
Instance Method Summary
collapse
Methods inherited from ServerAPI
#megam_rest
Constructor Details
#initialize(email = nil, api_key = nil, host = nil) ⇒ CSAR
Returns a new instance of CSAR.
19
20
21
22
23
24
25
26
|
# File 'lib/megam/core/csar.rb', line 19
def initialize(email=nil, api_key=nil, host=nil)
@id = nil
@desc = nil
@link = {}
@some_msg = {}
@created_at = nil
super(email, api_key, host)
end
|
Class Method Details
.create(o, tmp_email = nil, tmp_api_key = nil, tmp_host = nil) ⇒ Object
This won’t work, as the body just needs the yaml string.
145
146
147
148
|
# File 'lib/megam/core/csar.rb', line 145
def self.create(o,tmp_email=nil, tmp_api_key=nil, tmp_host=nil)
csarslf = from_hash(o, tmp_email, tmp_api_key, tmp_host)
csarslf.create
end
|
.from_hash(o, tmp_email = nil, tmp_api_key = nil, tmp_host = nil) ⇒ Object
129
130
131
132
133
|
# File 'lib/megam/core/csar.rb', line 129
def self.from_hash(o,tmp_email=nil, tmp_api_key=nil, tmp_host=nil)
csarhslf = self.new(tmp_email, tmp_api_key, tmp_host)
csarhslf.from_hash(o)
csarhslf
end
|
.json_create(o) ⇒ Object
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
# File 'lib/megam/core/csar.rb', line 113
def self.json_create(o)
csarjslf = new
csarjslf.id(o["id"]) if o.has_key?("id")
csarjslf.desc(o["desc"]) if o.has_key?("desc")
csarjslf.link(o["link"]) if o.has_key?("link")
csarjslf.created_at(o["created_at"]) if o.has_key?("created_at")
csarjslf.some_msg[:code] = o["code"] if o.has_key?("code")
csarjslf.some_msg[:msg_type] = o["msg_type"] if o.has_key?("msg_type")
csarjslf.some_msg[:msg]= o["msg"] if o.has_key?("msg")
csarjslf.some_msg[:links] = o["links"] if o.has_key?("links")
csarjslf
end
|
.list(tmp_email = nil, tmp_api_key = nil, tmp_host = nil) ⇒ Object
163
164
165
166
|
# File 'lib/megam/core/csar.rb', line 163
def self.list(tmp_email=nil, tmp_api_key=nil, tmp_host=nil)
csarslf = self.new(tmp_email, tmp_api_key, tmp_host)
csarslf.megam_rest.get_csars
end
|
.push(tmp_email = nil, tmp_api_key = nil, tmp_host = nil, csar_id) ⇒ Object
169
170
171
172
|
# File 'lib/megam/core/csar.rb', line 169
def self.push(tmp_email=nil, tmp_api_key=nil, tmp_host=nil, csar_id)
csarslf = self.new(tmp_email, tmp_api_key, tmp_host)
csarslf.megam_rest.push_csar(csar_id)
end
|
.show(tmp_email = nil, tmp_api_key = nil, tmp_host = nil, csarlink_name) ⇒ Object
Load the yaml back from the link
157
158
159
160
|
# File 'lib/megam/core/csar.rb', line 157
def self.show(tmp_email=nil, tmp_api_key=nil, tmp_host=nil, csarlink_name)
csarslf = self.new(tmp_email, tmp_api_key, tmp_host)
csarslf.megam_rest.get_csar(csarlink_name)
end
|
Instance Method Details
#create ⇒ Object
Create the csar yaml This won’t work, as the body just needs the yaml string.
152
153
154
|
# File 'lib/megam/core/csar.rb', line 152
def create
megam_rest.post_csar(@yamldata)
end
|
#created_at(arg = nil) ⇒ Object
65
66
67
68
69
70
71
|
# File 'lib/megam/core/csar.rb', line 65
def created_at(arg=nil)
if arg != nil
@created_at = arg
else
@created_at
end
end
|
#csar ⇒ Object
28
29
30
|
# File 'lib/megam/core/csar.rb', line 28
def csar
self
end
|
#desc(arg = nil) ⇒ Object
40
41
42
43
44
45
46
|
# File 'lib/megam/core/csar.rb', line 40
def desc(arg=nil)
if arg != nil
@desc = arg
else
@desc
end
end
|
#error? ⇒ Boolean
81
82
83
|
# File 'lib/megam/core/csar.rb', line 81
def error?
crocked = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error")
end
|
#for_json ⇒ Object
103
104
105
106
107
108
109
110
111
|
# File 'lib/megam/core/csar.rb', line 103
def for_json
result = {
"id" => id,
"desc" => desc,
"link" => link,
"created_at" => created_at
}
result
end
|
#from_hash(o) ⇒ Object
135
136
137
138
139
140
141
142
|
# File 'lib/megam/core/csar.rb', line 135
def from_hash(o)
@id = o["id"] if o.has_key?("id")
@desc = o["desc"] if o.has_key?("desc")
@link = o["link"] if o.has_key?("link")
@yamldata = o["yamldata"] if o.has_key?("yamldata")
@created_at = o["created_at"] if o.has_key?("created_at")
self
end
|
#id(arg = nil) ⇒ Object
32
33
34
35
36
37
38
|
# File 'lib/megam/core/csar.rb', line 32
def id(arg=nil)
if arg != nil
@id = arg
else
@id
end
end
|
#link(arg = nil) ⇒ Object
56
57
58
59
60
61
62
|
# File 'lib/megam/core/csar.rb', line 56
def link(arg=nil)
if arg != nil
@link = arg
else
@link
end
end
|
#some_msg(arg = nil) ⇒ Object
73
74
75
76
77
78
79
|
# File 'lib/megam/core/csar.rb', line 73
def some_msg(arg=nil)
if arg != nil
@some_msg = arg
else
@some_msg
end
end
|
#to_hash ⇒ Object
Transform the ruby obj -> to a Hash
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/megam/core/csar.rb', line 86
def to_hash
index_hash = Hash.new
index_hash["json_claz"] = self.class.name
index_hash["id"] = id
index_hash["desc"] = desc
index_hash["link"] = link
index_hash["some_msg"] = some_msg
index_hash["created_at"] = created_at
index_hash
end
|
#to_json(*a) ⇒ Object
Serialize this object as a hash: called from JsonCompat. Verify if this called from JsonCompat during testing.
99
100
101
|
# File 'lib/megam/core/csar.rb', line 99
def to_json(*a)
for_json.to_json(*a)
end
|
#yamldata(arg = nil) ⇒ Object
48
49
50
51
52
53
54
|
# File 'lib/megam/core/csar.rb', line 48
def yamldata(arg=nil)
if arg != nil
@yamldata = arg
else
@yamldata
end
end
|