Class: Podnix::AppRequest
- Inherits:
-
Object
- Object
- Podnix::AppRequest
- Defined in:
- lib/podnix/core/images.rb
Class Method Summary collapse
- .create(o) ⇒ Object
- .from_hash(o) ⇒ Object
-
.json_create(o) ⇒ Object
Create a Megam::Node from NodeResult-JSON.
-
.list(node_name) ⇒ Object
Load a account by email_p.
Instance Method Summary collapse
- #appdefns_id(arg = nil) ⇒ Object
- #appreq ⇒ Object
-
#create ⇒ Object
Create the node via the REST API.
- #created_at(arg = nil) ⇒ Object
- #error? ⇒ Boolean
- #for_json ⇒ Object
- #from_hash(o) ⇒ Object
- #id(arg = nil) ⇒ Object
-
#initialize ⇒ AppRequest
constructor
def self.hash_tree Hash.new do |hash, key| hash = hash_tree end end.
- #lc_additional(arg = nil) ⇒ Object
- #lc_apply(arg = nil) ⇒ Object
- #lc_when(arg = nil) ⇒ Object
- #node_name(arg = nil) ⇒ Object
- #podnix_rest ⇒ Object
- #req_type(arg = nil) ⇒ Object
- #some_msg(arg = nil) ⇒ Object
-
#to_hash ⇒ Object
Transform the ruby obj -> to a Hash.
-
#to_json(*a) ⇒ Object
Serialize this object as a hash: called from JsonCompat.
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ AppRequest
def self.hash_tree
Hash.new do |hash, key|
hash[key] = hash_tree
end
end
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/podnix/core/images.rb', line 28 def initialize @id = nil @req_type = nil @appdefns_id = nil @node_name = nil @lc_apply = nil @lc_additional = nil @lc_when = nil @created_at = nil @some_msg = {} end |
Class Method Details
.create(o) ⇒ Object
216 217 218 219 |
# File 'lib/podnix/core/images.rb', line 216 def self.create(o) acct = from_hash(o) acct.create end |
.from_hash(o) ⇒ Object
198 199 200 201 202 |
# File 'lib/podnix/core/images.rb', line 198 def self.from_hash(o) appreq = self.new() appreq.from_hash(o) appreq end |
.json_create(o) ⇒ Object
Create a Megam::Node from NodeResult-JSON
[{ “id”:“NOD362212018897289216”, “accounts_id”:“ACT362211962353876992”, “json_claz”:“Megam::Node”, “request”:{ “req_id”:“NOD362212018897289216”, “command”:“commands” }, “predefs”:{ “name”:“”, “scm”:“”, “war”:“”, “db”:“”, “queue”:“” } }]
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
# File 'lib/podnix/core/images.rb', line 179 def self.json_create(o) appreq = new appreq.id(o["id"]) if o.has_key?("id") appreq.req_type(o["req_type"]) if o.has_key?("req_type") appreq.appdefns_id(o["appdefns_id"]) if o.has_key?("appdefns_id") appreq.node_name(o["node_name"]) if o.has_key?("node_name") appreq.lc_apply(o["lc_apply"]) if o.has_key?("lc_apply") appreq.lc_additional(o["lc_additional"]) if o.has_key?("lc_additional") appreq.lc_when(o["lc_when"]) if o.has_key?("lc_when") appreq.created_at(o["created_at"]) if o.has_key?("created_at") appreq.some_msg[:code] = o["code"] if o.has_key?("code") appreq.some_msg[:msg_type] = o["msg_type"] if o.has_key?("msg_type") appreq.some_msg[:msg]= o["msg"] if o.has_key?("msg") appreq.some_msg[:links] = o["links"] if o.has_key?("links") appreq end |
.list(node_name) ⇒ Object
Load a account by email_p
227 228 229 230 231 |
# File 'lib/podnix/core/images.rb', line 227 def self.list(node_name) appreq = self.new() appreq.podnix_rest.get_appreq(node_name) #self end |
Instance Method Details
#appdefns_id(arg = nil) ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/podnix/core/images.rb', line 64 def appdefns_id(arg=nil) if arg != nil @appdefns_id = arg else @appdefns_id end end |
#appreq ⇒ Object
39 40 41 |
# File 'lib/podnix/core/images.rb', line 39 def appreq self end |
#create ⇒ Object
Create the node via the REST API
222 223 224 |
# File 'lib/podnix/core/images.rb', line 222 def create podnix_rest.post_appreq(to_hash) end |
#created_at(arg = nil) ⇒ Object
104 105 106 107 108 109 110 |
# File 'lib/podnix/core/images.rb', line 104 def created_at(arg=nil) if arg != nil @created_at = arg else @created_at end end |
#error? ⇒ Boolean
119 120 121 |
# File 'lib/podnix/core/images.rb', line 119 def error? crocked = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error") end |
#for_json ⇒ Object
145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/podnix/core/images.rb', line 145 def for_json result = { "id" => id, "req_type" => req_type, "appdefns_id" => appdefns_id, "node_name" => node_name, "lc_apply" => lc_apply, "lc_additional" => lc_additional, "lc_when" => lc_when, "created_at" => created_at } result end |
#from_hash(o) ⇒ Object
204 205 206 207 208 209 210 211 212 213 214 |
# File 'lib/podnix/core/images.rb', line 204 def from_hash(o) @id = o["id"] if o.has_key?("id") @req_type = o["req_type"] if o.has_key?("req_type") @appdefns_id = o["appdefns_id"] if o.has_key?("appdefns_id") @node_name = o["node_name"] if o.has_key?("node_name") @lc_apply = o["lc_apply"] if o.has_key?("lc_apply") @lc_additional = o["lc_additional"] if o.has_key?("lc_additional") @lc_when = o["lc_when"] if o.has_key?("lc_when") @created_at = o["created_at"] if o.has_key?("created_at") self end |
#id(arg = nil) ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/podnix/core/images.rb', line 48 def id(arg=nil) if arg != nil @id = arg else @id end end |
#lc_additional(arg = nil) ⇒ Object
88 89 90 91 92 93 94 |
# File 'lib/podnix/core/images.rb', line 88 def lc_additional(arg=nil) if arg != nil @lc_additional = arg else @lc_additional end end |
#lc_apply(arg = nil) ⇒ Object
80 81 82 83 84 85 86 |
# File 'lib/podnix/core/images.rb', line 80 def lc_apply(arg=nil) if arg != nil @lc_apply = arg else @lc_apply end end |
#lc_when(arg = nil) ⇒ Object
96 97 98 99 100 101 102 |
# File 'lib/podnix/core/images.rb', line 96 def lc_when(arg=nil) if arg != nil @lc_when = arg else @lc_when end end |
#node_name(arg = nil) ⇒ Object
72 73 74 75 76 77 78 |
# File 'lib/podnix/core/images.rb', line 72 def node_name(arg=nil) if arg != nil @node_name = arg else @node_name end end |
#podnix_rest ⇒ Object
43 44 45 46 |
# File 'lib/podnix/core/images.rb', line 43 def podnix_rest = { :email => Megam::Config[:email], :api_key => Megam::Config[:api_key]} Podnix::API.new() end |
#req_type(arg = nil) ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/podnix/core/images.rb', line 56 def req_type(arg=nil) if arg != nil @req_type = arg else @req_type end end |
#some_msg(arg = nil) ⇒ Object
111 112 113 114 115 116 117 |
# File 'lib/podnix/core/images.rb', line 111 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
124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/podnix/core/images.rb', line 124 def to_hash index_hash = Hash.new index_hash["json_claz"] = self.class.name index_hash["id"] = id index_hash["req_type"] = req_type index_hash["appdefns_id"] = appdefns_id index_hash["node_name"] = node_name index_hash["lc_apply"] = lc_apply index_hash["lc_additional"] = lc_additional index_hash["lc_when"] = lc_when 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.
141 142 143 |
# File 'lib/podnix/core/images.rb', line 141 def to_json(*a) for_json.to_json(*a) end |
#to_s ⇒ Object
233 234 235 236 |
# File 'lib/podnix/core/images.rb', line 233 def to_s Podnix::Stuff.styled_hash(to_hash) #"---> Megam::Account:[error=#{error?}]\n"+ end |