Class: Comet::SSHConnection
- Inherits:
-
Object
- Object
- Comet::SSHConnection
- Defined in:
- lib/comet/models/sshconnection.rb
Overview
SSHConnection is a typed class wrapper around the underlying Comet Server API data structure.
Instance Attribute Summary collapse
-
#sshauth_mode ⇒ Object
Returns the value of attribute sshauth_mode.
-
#sshcustom_auth__known_hosts_file ⇒ Object
Returns the value of attribute sshcustom_auth__known_hosts_file.
-
#sshcustom_auth__use_known_hosts_file ⇒ Object
Returns the value of attribute sshcustom_auth__use_known_hosts_file.
-
#sshpassword ⇒ Object
Returns the value of attribute sshpassword.
-
#sshprivate_key ⇒ Object
Returns the value of attribute sshprivate_key.
-
#sshserver ⇒ Object
Returns the value of attribute sshserver.
-
#sshusername ⇒ Object
Returns the value of attribute sshusername.
-
#unknown_json_fields ⇒ Object
Returns the value of attribute unknown_json_fields.
Instance Method Summary collapse
- #clear ⇒ Object
- #from_hash(obj) ⇒ Object
- #from_json(json_string) ⇒ Object
-
#initialize ⇒ SSHConnection
constructor
A new instance of SSHConnection.
-
#to_h ⇒ Hash
The complete object as a Ruby hash.
-
#to_hash ⇒ Hash
The complete object as a Ruby hash.
-
#to_json(options = {}) ⇒ String
The complete object as a JSON string.
Constructor Details
#initialize ⇒ SSHConnection
Returns a new instance of SSHConnection.
41 42 43 |
# File 'lib/comet/models/sshconnection.rb', line 41 def initialize clear end |
Instance Attribute Details
#sshauth_mode ⇒ Object
Returns the value of attribute sshauth_mode.
24 25 26 |
# File 'lib/comet/models/sshconnection.rb', line 24 def sshauth_mode @sshauth_mode end |
#sshcustom_auth__known_hosts_file ⇒ Object
Returns the value of attribute sshcustom_auth__known_hosts_file.
36 37 38 |
# File 'lib/comet/models/sshconnection.rb', line 36 def sshcustom_auth__known_hosts_file @sshcustom_auth__known_hosts_file end |
#sshcustom_auth__use_known_hosts_file ⇒ Object
Returns the value of attribute sshcustom_auth__use_known_hosts_file.
33 34 35 |
# File 'lib/comet/models/sshconnection.rb', line 33 def sshcustom_auth__use_known_hosts_file @sshcustom_auth__use_known_hosts_file end |
#sshpassword ⇒ Object
Returns the value of attribute sshpassword.
27 28 29 |
# File 'lib/comet/models/sshconnection.rb', line 27 def sshpassword @sshpassword end |
#sshprivate_key ⇒ Object
Returns the value of attribute sshprivate_key.
30 31 32 |
# File 'lib/comet/models/sshconnection.rb', line 30 def sshprivate_key @sshprivate_key end |
#sshserver ⇒ Object
Returns the value of attribute sshserver.
18 19 20 |
# File 'lib/comet/models/sshconnection.rb', line 18 def sshserver @sshserver end |
#sshusername ⇒ Object
Returns the value of attribute sshusername.
21 22 23 |
# File 'lib/comet/models/sshconnection.rb', line 21 def sshusername @sshusername end |
#unknown_json_fields ⇒ Object
Returns the value of attribute unknown_json_fields.
39 40 41 |
# File 'lib/comet/models/sshconnection.rb', line 39 def unknown_json_fields @unknown_json_fields end |
Instance Method Details
#clear ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/comet/models/sshconnection.rb', line 45 def clear @sshserver = '' @sshusername = '' @sshauth_mode = 0 @sshpassword = '' @sshprivate_key = '' @sshcustom_auth__known_hosts_file = '' @unknown_json_fields = {} end |
#from_hash(obj) ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/comet/models/sshconnection.rb', line 63 def from_hash(obj) raise TypeError, "'obj' expected Hash, got #{obj.class}" unless obj.is_a? Hash obj.each do |k, v| case k when 'SSHServer' raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String @sshserver = v when 'SSHUsername' raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String @sshusername = v when 'SSHAuthMode' raise TypeError, "'v' expected Numeric, got #{v.class}" unless v.is_a? Numeric @sshauth_mode = v when 'SSHPassword' raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String @sshpassword = v when 'SSHPrivateKey' raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String @sshprivate_key = v when 'SSHCustomAuth_UseKnownHostsFile' @sshcustom_auth__use_known_hosts_file = v when 'SSHCustomAuth_KnownHostsFile' raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String @sshcustom_auth__known_hosts_file = v else @unknown_json_fields[k] = v end end end |
#from_json(json_string) ⇒ Object
56 57 58 59 60 |
# File 'lib/comet/models/sshconnection.rb', line 56 def from_json(json_string) raise TypeError, "'json_string' expected String, got #{json_string.class}" unless json_string.is_a? String from_hash(JSON.parse(json_string)) end |
#to_h ⇒ Hash
Returns The complete object as a Ruby hash.
117 118 119 |
# File 'lib/comet/models/sshconnection.rb', line 117 def to_h to_hash end |
#to_hash ⇒ Hash
Returns The complete object as a Ruby hash.
101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/comet/models/sshconnection.rb', line 101 def to_hash ret = {} ret['SSHServer'] = @sshserver ret['SSHUsername'] = @sshusername ret['SSHAuthMode'] = @sshauth_mode ret['SSHPassword'] = @sshpassword ret['SSHPrivateKey'] = @sshprivate_key ret['SSHCustomAuth_UseKnownHostsFile'] = @sshcustom_auth__use_known_hosts_file ret['SSHCustomAuth_KnownHostsFile'] = @sshcustom_auth__known_hosts_file @unknown_json_fields.each do |k, v| ret[k] = v end ret end |
#to_json(options = {}) ⇒ String
Returns The complete object as a JSON string.
122 123 124 |
# File 'lib/comet/models/sshconnection.rb', line 122 def to_json( = {}) to_hash.to_json() end |