Class: Nexpose::SharedSecret

Inherits:
APIObject show all
Defined in:
lib/nexpose/shared_secret.rb

Overview

SharedSecret class for pairing engines

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from APIObject

#object_from_hash

Constructor Details

#initialize(console, time_to_live) ⇒ SharedSecret

Returns a new instance of SharedSecret.



7
8
9
10
11
# File 'lib/nexpose/shared_secret.rb', line 7

def initialize(console, time_to_live)
  uri = "/data/admin/global/shared-secret?time-to-live=#{time_to_live}"
  json = JSON.parse(AJAX.put(console, uri))
  self.from_json(json)
end

Instance Attribute Details

#key_stringObject (readonly)

Returns the value of attribute key_string.



4
5
6
# File 'lib/nexpose/shared_secret.rb', line 4

def key_string
  @key_string
end

#ttlObject (readonly)

Returns the value of attribute ttl.



5
6
7
# File 'lib/nexpose/shared_secret.rb', line 5

def ttl
  @ttl
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



23
24
25
26
27
28
# File 'lib/nexpose/shared_secret.rb', line 23

def ==(other)
  return false unless self.class == other.class
  return false unless key_string.upcase == other.key_string.upcase

  true
end

#delete(console) ⇒ Object



18
19
20
21
# File 'lib/nexpose/shared_secret.rb', line 18

def delete(console)
  uri = "/data/admin/global/remove-shared-secret?key-string=#{key_string}"
  AJAX.delete(console, uri)
end

#from_json(json) ⇒ Object



13
14
15
16
# File 'lib/nexpose/shared_secret.rb', line 13

def from_json(json)
  @key_string = json['keyString']
  @ttl = json['timeToLiveInSeconds']
end