Class: Megam::SshKey
Instance Attribute Summary
Attributes inherited from ServerAPI
#api_key, #email, #host, #password
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from ServerAPI
#megam_rest
Constructor Details
#initialize(o) ⇒ SshKey
Returns a new instance of SshKey.
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/megam/core/sshkey.rb', line 18
def initialize(o)
@id = nil
@name = nil
@org_id = nil
@privatekey=nil
@publickey=nil
@created_at = nil
@some_msg = {}
super(o)
end
|
Class Method Details
.create(params) ⇒ Object
157
158
159
160
|
# File 'lib/megam/core/sshkey.rb', line 157
def self.create(params)
acct = from_hash(params)
acct.create
end
|
.from_hash(o) ⇒ Object
141
142
143
144
145
|
# File 'lib/megam/core/sshkey.rb', line 141
def self.from_hash(o)
sshKey = self.new(o)
sshKey.from_hash(o)
sshKey
end
|
.json_create(o) ⇒ Object
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
# File 'lib/megam/core/sshkey.rb', line 126
def self.json_create(o)
sshKey = new({})
sshKey.id(o["id"]) if o.has_key?("id")
sshKey.name(o["name"]) if o.has_key?("name")
sshKey.privatekey(o["privatekey"]) if o.has_key?("privatekey")
sshKey.publickey(o["publickey"]) if o.has_key?("publickey")
sshKey.created_at(o["created_at"]) if o.has_key?("created_at")
sshKey.some_msg[:code] = o["code"] if o.has_key?("code")
sshKey.some_msg[:msg_type] = o["msg_type"] if o.has_key?("msg_type")
sshKey.some_msg[:msg]= o["msg"] if o.has_key?("msg")
sshKey.some_msg[:links] = o["links"] if o.has_key?("links")
sshKey
end
|
.list(params) ⇒ Object
Load all sshkeys - returns a sshkeysCollection don’t return self. check if the Megam::SshKeyCollection is returned.
170
171
172
173
|
# File 'lib/megam/core/sshkey.rb', line 170
def self.list(params)
sshKey = self.new(params)
sshKey.megam_rest.get_sshkeys
end
|
.show(params) ⇒ Object
Show a particular sshKey by name, Megam::SshKey
177
178
179
180
|
# File 'lib/megam/core/sshkey.rb', line 177
def self.show(params)
pre = self.new(params)
pre.megam_rest.get_sshkey(params["name"])
end
|
Instance Method Details
#create ⇒ Object
Create the predef via the REST API
163
164
165
|
# File 'lib/megam/core/sshkey.rb', line 163
def create
megam_rest.post_sshkey(to_hash)
end
|
#created_at(arg = nil) ⇒ Object
74
75
76
77
78
79
80
|
# File 'lib/megam/core/sshkey.rb', line 74
def created_at(arg=nil)
if arg != nil
@created_at = arg
else
@created_at
end
end
|
#error? ⇒ Boolean
90
91
92
|
# File 'lib/megam/core/sshkey.rb', line 90
def error?
crocked = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error")
end
|
#for_json ⇒ Object
113
114
115
116
117
118
119
120
121
122
123
|
# File 'lib/megam/core/sshkey.rb', line 113
def for_json
result = {
"id" => id,
"name" => name,
"org_id" => org_id,
"privatekey" => privatekey,
"publickey" => publickey,
"created_at" => created_at
}
result
end
|
#from_hash(o) ⇒ Object
147
148
149
150
151
152
153
154
155
|
# File 'lib/megam/core/sshkey.rb', line 147
def from_hash(o)
@id = o[:id] if o.has_key?(:id)
@name = o[:name] if o.has_key?(:name)
@org_id = o[:org_id] if o.has_key?(:org_id)
@privatekey = o[:privatekey] if o.has_key?(:privatekey)
@publickey = o[:publickey] if o.has_key?(:publickey)
@created_at = o[:created_at] if o.has_key?(:created_at)
self
end
|
#id(arg = nil) ⇒ Object
33
34
35
36
37
38
39
|
# File 'lib/megam/core/sshkey.rb', line 33
def id(arg=nil)
if arg != nil
@id = arg
else
@id
end
end
|
#name(arg = nil) ⇒ Object
41
42
43
44
45
46
47
|
# File 'lib/megam/core/sshkey.rb', line 41
def name(arg=nil)
if arg != nil
@name = arg
else
@name
end
end
|
#org_id(arg = nil) ⇒ Object
49
50
51
52
53
54
55
|
# File 'lib/megam/core/sshkey.rb', line 49
def org_id(arg=nil)
if arg != nil
@org_id= arg
else
@org_id
end
end
|
#privatekey(arg = nil) ⇒ Object
57
58
59
60
61
62
63
|
# File 'lib/megam/core/sshkey.rb', line 57
def privatekey(arg=nil)
if arg != nil
@privatekey = arg
else
@privatekey
end
end
|
#publickey(arg = nil) ⇒ Object
65
66
67
68
69
70
71
|
# File 'lib/megam/core/sshkey.rb', line 65
def publickey(arg=nil)
if arg != nil
@publickey = arg
else
@publickey
end
end
|
#some_msg(arg = nil) ⇒ Object
82
83
84
85
86
87
88
|
# File 'lib/megam/core/sshkey.rb', line 82
def some_msg(arg=nil)
if arg != nil
@some_msg = arg
else
@some_msg
end
end
|
#sshkey ⇒ Object
29
30
31
|
# File 'lib/megam/core/sshkey.rb', line 29
def sshkey
self
end
|
#to_hash ⇒ Object
Transform the ruby obj -> to a Hash
95
96
97
98
99
100
101
102
103
104
105
|
# File 'lib/megam/core/sshkey.rb', line 95
def to_hash
index_hash = Hash.new
index_hash["json_claz"] = self.class.name
index_hash["id"] = id
index_hash["name"] = name
index_hash["org_id"] = org_id
index_hash["privatekey"] = privatekey
index_hash["publickey"] = publickey
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.
109
110
111
|
# File 'lib/megam/core/sshkey.rb', line 109
def to_json(*a)
for_json.to_json(*a)
end
|
#to_s ⇒ Object
182
183
184
185
|
# File 'lib/megam/core/sshkey.rb', line 182
def to_s
Megam::Stuff.styled_hash(to_hash)
end
|