Class: Delphix::Job

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/delphix/job.rb

Instance Attribute Summary

Attributes included from Base

#details

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Base

#name, #reference, #refresh_details, #type

Constructor Details

#initialize(reference, details = nil) ⇒ Job

Returns a new instance of Job.



5
6
7
# File 'lib/delphix/job.rb', line 5

def initialize(reference, details=nil)
  super(reference, details)
end

Class Method Details

.listObject

class methods



52
53
54
55
56
57
58
59
# File 'lib/delphix/job.rb', line 52

def self.list
  jobs = Delphix::BaseArray.new
  result = Delphix.get('/resources/json/delphix/job')['result']
  result.each do |job|
    jobs << Delphix::Job.new(job['reference'],job)
  end
  jobs
end

Instance Method Details

#base_endpointObject



46
47
48
# File 'lib/delphix/job.rb', line 46

def base_endpoint
  '/resources/json/delphix/job'
end

#cancel!Object



22
23
24
# File 'lib/delphix/job.rb', line 22

def cancel!
  Delphix.post("#{base_endpoint}/#{reference}/cancel")['result']
end

#resume!Object



30
31
32
# File 'lib/delphix/job.rb', line 30

def resume!
  Delphix.post("#{base_endpoint}/#{reference}/resume")['result']
end

#stateObject

specific operations



13
14
15
# File 'lib/delphix/job.rb', line 13

def state
  @details['jobState'] # RUNNING, SUSPENDED, CANCELED, COMPLETED, FAILED
end

#state?Boolean

Returns:

  • (Boolean)


17
18
19
20
# File 'lib/delphix/job.rb', line 17

def state?
  refresh_details
  state
end

#suspend!Object



26
27
28
# File 'lib/delphix/job.rb', line 26

def suspend!
  Delphix.post("#{base_endpoint}/#{reference}/suspend")['result']
end

#to_sObject

inherited operations



42
43
44
# File 'lib/delphix/job.rb', line 42

def to_s
  "#{self.class.name}[#{@details['actionType']}, #{reference}, #{@details['jobState']}]"
end

#wait_for_completionObject



34
35
36
37
38
# File 'lib/delphix/job.rb', line 34

def wait_for_completion
  begin
    sleep 1
  end while state? == 'RUNNING'
end