Class: Morpheus::JobsInterface

Inherits:
APIClient
  • Object
show all
Defined in:
lib/morpheus/api/jobs_interface.rb

Instance Method Summary collapse

Instance Method Details

#base_pathObject



5
6
7
# File 'lib/morpheus/api/jobs_interface.rb', line 5

def base_path
  "/api/jobs"
end

#create(payload) ⇒ Object



28
29
30
31
32
# File 'lib/morpheus/api/jobs_interface.rb', line 28

def create(payload)
  url = base_path
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  execute(method: :post, url: url, headers: headers, payload: payload.to_json)
end

#destroy(id, params = {}) ⇒ Object



40
41
42
43
44
# File 'lib/morpheus/api/jobs_interface.rb', line 40

def destroy(id, params={})
  url = "#{base_path}/#{id}"
  headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  execute(method: :delete, url: url, headers: headers)
end

#execute_job(id, payload = {}, params = {}) ⇒ Object



46
47
48
49
50
# File 'lib/morpheus/api/jobs_interface.rb', line 46

def execute_job(id, payload={}, params={})
  url = "#{base_path}/#{id}/execute"
  headers = { params: params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  execute(method: :put, url: url, headers: headers, payload: payload.to_json)
end

#get(id, params = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/morpheus/api/jobs_interface.rb', line 15

def get(id, params={})
  url = "#{base_path}/#{id}"
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  if params.is_a?(Hash)
    headers[:params].merge!(params)
  elsif params.is_a?(Numeric)
    url = "#{base_path}/#{params}"
  elsif params.is_a?(String)
    headers[:params]['name'] = params
  end
  execute(method: :get, url: url, headers: headers)
end

#get_execution(id, params = {}) ⇒ Object



66
67
68
69
70
# File 'lib/morpheus/api/jobs_interface.rb', line 66

def get_execution(id, params={})
  url = "#{@base_url}/api/job-executions/#{id}"
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  execute(method: :get, url: url, headers: headers)
end

#get_execution_event(id, event_id, params = {}) ⇒ Object



72
73
74
75
76
# File 'lib/morpheus/api/jobs_interface.rb', line 72

def get_execution_event(id, event_id, params={})
  url = "#{@base_url}/api/job-executions/#{id}/events/#{event_id}"
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  execute(method: :get, url: url, headers: headers)
end

#list(params = {}) ⇒ Object



9
10
11
12
13
# File 'lib/morpheus/api/jobs_interface.rb', line 9

def list(params={})
  url = base_path
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  execute(method: :get, url: url, headers: headers)
end

#list_executions(params = {}) ⇒ Object

def list_job_executions(id, params={}) url = "##base_path/#id/executions" headers = { params: params, authorization: "Bearer #@access_token" } execute(method: :get, url: url, headers: headers) end



60
61
62
63
64
# File 'lib/morpheus/api/jobs_interface.rb', line 60

def list_executions(params={})
  url = "#{@base_url}/api/job-executions"
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  execute(method: :get, url: url, headers: headers)
end

#options(jobTypeId, params = {}) ⇒ Object



78
79
80
81
82
# File 'lib/morpheus/api/jobs_interface.rb', line 78

def options(jobTypeId, params={})
  url = "#{@base_url}/api/job-options/#{jobTypeId}"
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  execute(method: :get, url: url, headers: headers)
end

#update(id, payload, params = {}) ⇒ Object



34
35
36
37
38
# File 'lib/morpheus/api/jobs_interface.rb', line 34

def update(id, payload, params={})
  url = "#{base_path}/#{id}"
  headers = { params: params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  execute(method: :put, url: url, headers: headers, payload: payload.to_json)
end