Class: Morpheus::TaskSetsInterface

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

Instance Method Summary collapse

Instance Method Details

#create(options) ⇒ Object



25
26
27
28
29
30
# File 'lib/morpheus/api/task_sets_interface.rb', line 25

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

#destroy(id) ⇒ Object



39
40
41
42
43
# File 'lib/morpheus/api/task_sets_interface.rb', line 39

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

#get(options = nil) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/morpheus/api/task_sets_interface.rb', line 12

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

#list(params = {}) ⇒ Object



5
6
7
8
9
10
# File 'lib/morpheus/api/task_sets_interface.rb', line 5

def list(params={})
  url = "#{@base_url}/api/task-sets"
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  opts = {method: :get, url: url, headers: headers}
  execute(opts)
end

#run(id, options) ⇒ Object



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

def run(id, options)
  url = "#{@base_url}/api/task-sets/#{id}/execute"
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  payload = options
  execute(method: :post, url: url, headers: headers, payload: payload.to_json)
end

#update(id, options) ⇒ Object



32
33
34
35
36
37
# File 'lib/morpheus/api/task_sets_interface.rb', line 32

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