Class: CloudhouseGuardian::Job

Inherits:
BaseObject show all
Defined in:
lib/cloudhouse_guardian/Job.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) ⇒ Job

Returns a new instance of Job.



9
10
11
12
13
14
15
16
17
# File 'lib/cloudhouse_guardian/Job.rb', line 9

def initialize(appliance_url, appliance_api_key, sec_key, insecure = false)
  super(appliance_url, appliance_api_key, sec_key, insecure)
  self.id = nil
  self.organisation_id = nil
  self.source_id = nil
  self.source_name = nil
  self.source_type = nil
  self.status = nil
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#organisation_idObject

Returns the value of attribute organisation_id.



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

def organisation_id
  @organisation_id
end

#source_idObject

Returns the value of attribute source_id.



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

def source_id
  @source_id
end

#source_nameObject

Returns the value of attribute source_name.



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

def source_name
  @source_name
end

#source_typeObject

Returns the value of attribute source_type.



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

def source_type
  @source_type
end

#statusObject

Returns the value of attribute status.



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

def status
  @status
end

Instance Method Details

#from_hash(h) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/cloudhouse_guardian/Job.rb', line 19

def from_hash(h)
  self.id = h['id'] if h.include?('id')
  self.organisation_id = h['organisation_id'] if h.include?('organisation_id')
  self.source_id = h['source_id'] if h.include?('source_id')
  self.source_name = h['source_name'] if h.include?('source_name')
  self.source_type = h['source_type'] if h.include?('source_type')
  self.status = h['status'] if h.include?('status')
end

#tasksObject



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/cloudhouse_guardian/Job.rb', line 42

def tasks
  obj = http_get("/api/v2/jobs/{job_id}/tasks.json")
  the_list = TaskList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
  obj.each do |x|
    elem = Task.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
    elem.agent_name = x["agent_name"] if x.include?("agent_name")
    elem.connection_manager_id = x["connection_manager_id"] if x.include?("connection_manager_id")
    elem.created_at = x["created_at"] if x.include?("created_at")
    elem.id = x["id"] if x.include?("id")
    elem.job_id = x["job_id"] if x.include?("job_id")
    elem.label = x["label"] if x.include?("label")
    elem.log = x["log"] if x.include?("log")
    elem.node_id = x["node_id"] if x.include?("node_id")
    elem.node_session_id = x["node_session_id"] if x.include?("node_session_id")
    elem.payload = x["payload"] if x.include?("payload")
    elem.report = x["report"] if x.include?("report")
    elem.sequence = x["sequence"] if x.include?("sequence")
    elem.status = x["status"] if x.include?("status")
    elem.step_description = x["step_description"] if x.include?("step_description")
    elem.updated_at = x["updated_at"] if x.include?("updated_at")
    elem.uuid = x["uuid"] if x.include?("uuid")
    the_list << elem
  end
  return the_list
end

#to_hashObject



27
28
29
30
31
32
33
34
35
36
# File 'lib/cloudhouse_guardian/Job.rb', line 27

def to_hash
  h = {}
  h['id'] = self.id
  h['organisation_id'] = self.organisation_id
  h['source_id'] = self.source_id
  h['source_name'] = self.source_name
  h['source_type'] = self.source_type
  h['status'] = self.status
  return h
end

#to_json(options = nil) ⇒ Object



37
38
39
40
# File 'lib/cloudhouse_guardian/Job.rb', line 37

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