Class: CloudhouseGuardian::NodeScan

Inherits:
BaseObject show all
Defined in:
lib/cloudhouse_guardian/NodeScan.rb

Instance Attribute Summary collapse

Attributes inherited from BaseObject

#appliance_api_key, #appliance_url, #insecure, #sec_key

Instance Method Summary collapse

Methods inherited from BaseObject

#http_delete, #http_get, #http_post, #http_put, #make_headers

Constructor Details

#initialize(appliance_url, appliance_api_key, sec_key, insecure = false) ⇒ NodeScan

Returns a new instance of NodeScan.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/cloudhouse_guardian/NodeScan.rb', line 14

def initialize(appliance_url, appliance_api_key, sec_key, insecure = false)
  super(appliance_url, appliance_api_key, sec_key, insecure)
  self.associated_id = nil
  self.category = nil
  self.created_at = nil
  self.data = nil
  self.id = nil
  self.label = nil
  self.node_id = nil
  self.scan_options = nil
  self.task_id = nil
  self.tsv = nil
  self.updated_at = nil
end

Instance Attribute Details

#associated_idObject

Returns the value of attribute associated_id.



3
4
5
# File 'lib/cloudhouse_guardian/NodeScan.rb', line 3

def associated_id
  @associated_id
end

#categoryObject

Returns the value of attribute category.



4
5
6
# File 'lib/cloudhouse_guardian/NodeScan.rb', line 4

def category
  @category
end

#created_atObject

Returns the value of attribute created_at.



5
6
7
# File 'lib/cloudhouse_guardian/NodeScan.rb', line 5

def created_at
  @created_at
end

#dataObject

Returns the value of attribute data.



6
7
8
# File 'lib/cloudhouse_guardian/NodeScan.rb', line 6

def data
  @data
end

#idObject

Returns the value of attribute id.



7
8
9
# File 'lib/cloudhouse_guardian/NodeScan.rb', line 7

def id
  @id
end

#labelObject

Returns the value of attribute label.



8
9
10
# File 'lib/cloudhouse_guardian/NodeScan.rb', line 8

def label
  @label
end

#node_idObject

Returns the value of attribute node_id.



9
10
11
# File 'lib/cloudhouse_guardian/NodeScan.rb', line 9

def node_id
  @node_id
end

#scan_optionsObject

Returns the value of attribute scan_options.



10
11
12
# File 'lib/cloudhouse_guardian/NodeScan.rb', line 10

def scan_options
  @scan_options
end

#task_idObject

Returns the value of attribute task_id.



11
12
13
# File 'lib/cloudhouse_guardian/NodeScan.rb', line 11

def task_id
  @task_id
end

#tsvObject

Returns the value of attribute tsv.



12
13
14
# File 'lib/cloudhouse_guardian/NodeScan.rb', line 12

def tsv
  @tsv
end

#updated_atObject

Returns the value of attribute updated_at.



13
14
15
# File 'lib/cloudhouse_guardian/NodeScan.rb', line 13

def updated_at
  @updated_at
end

Instance Method Details

#from_hash(h) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/cloudhouse_guardian/NodeScan.rb', line 29

def from_hash(h)
  self.associated_id = h['associated_id'] if h.include?('associated_id')
  self.category = h['category'] if h.include?('category')
  self.created_at = h['created_at'] if h.include?('created_at')
  self.data = h['data'] if h.include?('data')
  self.id = h['id'] if h.include?('id')
  self.label = h['label'] if h.include?('label')
  self.node_id = h['node_id'] if h.include?('node_id')
  self.scan_options = h['scan_options'] if h.include?('scan_options')
  self.task_id = h['task_id'] if h.include?('task_id')
  self.tsv = h['tsv'] if h.include?('tsv')
  self.updated_at = h['updated_at'] if h.include?('updated_at')
end

#loadObject



62
63
64
65
# File 'lib/cloudhouse_guardian/NodeScan.rb', line 62

def load
  obj = http_get("/api/v2/node_scans/#{self.id}.json")
  from_hash(obj)
end

#nodeObject



68
69
70
71
72
73
74
# File 'lib/cloudhouse_guardian/NodeScan.rb', line 68

def node
  obj = http_get("/api/v2/nodes/{node_id}.json")
  elem = Node.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
    elem.id = obj["id"]
    elem.name = obj["name"]
  return elem
end

#to_hashObject



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/cloudhouse_guardian/NodeScan.rb', line 42

def to_hash
  h = {}
  h['associated_id'] = self.associated_id
  h['category'] = self.category
  h['created_at'] = self.created_at
  h['data'] = self.data
  h['id'] = self.id
  h['label'] = self.label
  h['node_id'] = self.node_id
  h['scan_options'] = self.scan_options
  h['task_id'] = self.task_id
  h['tsv'] = self.tsv
  h['updated_at'] = self.updated_at
  return h
end

#to_json(options = nil) ⇒ Object



57
58
59
60
# File 'lib/cloudhouse_guardian/NodeScan.rb', line 57

def to_json(options = nil)
  h = to_hash
  return h.to_json(options)
end