Class: Comet::SSHConnection

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initializeSSHConnection

Returns a new instance of SSHConnection.



39
40
41
# File 'lib/comet/models/sshconnection.rb', line 39

def initialize
  clear
end

Instance Attribute Details

#sshauth_modeObject

Returns the value of attribute sshauth_mode.



22
23
24
# File 'lib/comet/models/sshconnection.rb', line 22

def sshauth_mode
  @sshauth_mode
end

#sshcustom_auth__known_hosts_fileObject

Returns the value of attribute sshcustom_auth__known_hosts_file.



34
35
36
# File 'lib/comet/models/sshconnection.rb', line 34

def sshcustom_auth__known_hosts_file
  @sshcustom_auth__known_hosts_file
end

#sshcustom_auth__use_known_hosts_fileObject

Returns the value of attribute sshcustom_auth__use_known_hosts_file.



31
32
33
# File 'lib/comet/models/sshconnection.rb', line 31

def sshcustom_auth__use_known_hosts_file
  @sshcustom_auth__use_known_hosts_file
end

#sshpasswordObject

Returns the value of attribute sshpassword.



25
26
27
# File 'lib/comet/models/sshconnection.rb', line 25

def sshpassword
  @sshpassword
end

#sshprivate_keyObject

Returns the value of attribute sshprivate_key.



28
29
30
# File 'lib/comet/models/sshconnection.rb', line 28

def sshprivate_key
  @sshprivate_key
end

#sshserverObject

Returns the value of attribute sshserver.



16
17
18
# File 'lib/comet/models/sshconnection.rb', line 16

def sshserver
  @sshserver
end

#sshusernameObject

Returns the value of attribute sshusername.



19
20
21
# File 'lib/comet/models/sshconnection.rb', line 19

def sshusername
  @sshusername
end

#unknown_json_fieldsObject

Returns the value of attribute unknown_json_fields.



37
38
39
# File 'lib/comet/models/sshconnection.rb', line 37

def unknown_json_fields
  @unknown_json_fields
end

Instance Method Details

#clearObject



43
44
45
46
47
48
49
50
51
# File 'lib/comet/models/sshconnection.rb', line 43

def clear
  @sshserver = ''
  @sshusername = ''
  @sshauth_mode = 0
  @sshpassword = ''
  @sshprivate_key = ''
  @sshcustom_auth__known_hosts_file = ''
  @unknown_json_fields = {}
end

#from_hash(obj) ⇒ Object

Parameters:

  • obj (Hash)

    The complete object as a Ruby hash

Raises:

  • (TypeError)


61
62
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
# File 'lib/comet/models/sshconnection.rb', line 61

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

Parameters:

  • json_string (String)

    The complete object in JSON format

Raises:

  • (TypeError)


54
55
56
57
58
# File 'lib/comet/models/sshconnection.rb', line 54

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_hHash

Returns The complete object as a Ruby hash.

Returns:

  • (Hash)

    The complete object as a Ruby hash



115
116
117
# File 'lib/comet/models/sshconnection.rb', line 115

def to_h
  to_hash
end

#to_hashHash

Returns The complete object as a Ruby hash.

Returns:

  • (Hash)

    The complete object as a Ruby hash



99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/comet/models/sshconnection.rb', line 99

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.

Returns:

  • (String)

    The complete object as a JSON string



120
121
122
# File 'lib/comet/models/sshconnection.rb', line 120

def to_json(options = {})
  to_hash.to_json(options)
end