Class: Morpheus::TasksInterface
- Inherits:
-
APIClient
- Object
- APIClient
- Morpheus::TasksInterface
- Defined in:
- lib/morpheus/api/tasks_interface.rb
Instance Method Summary collapse
- #create(options) ⇒ Object
- #destroy(id, params = {}) ⇒ Object
- #get(options = nil) ⇒ Object
- #get_type(id, params = {}) ⇒ Object
- #list(params = {}) ⇒ Object
- #list_types(params = {}) ⇒ Object
- #run(id, options) ⇒ Object
- #update(id, options) ⇒ Object
Instance Method Details
#create(options) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/morpheus/api/tasks_interface.rb', line 34 def create() url = "#{@base_url}/api/tasks" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } payload = execute(method: :post, url: url, headers: headers, payload: payload.to_json) end |
#destroy(id, params = {}) ⇒ Object
41 42 43 44 45 |
# File 'lib/morpheus/api/tasks_interface.rb', line 41 def destroy(id, params={}) url = "#{@base_url}/api/tasks/#{id}" headers = { :params => params, :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 24 |
# File 'lib/morpheus/api/tasks_interface.rb', line 12 def get(=nil) url = "#{@base_url}/api/tasks" headers = { params: {}, authorization: "Bearer #{@access_token}" } if .is_a?(Hash) headers[:params].merge!() elsif .is_a?(Numeric) url = "#{@base_url}/api/tasks/#{}" elsif .is_a?(String) headers[:params]['name'] = end execute(method: :get, url: url, headers: headers) end |
#get_type(id, params = {}) ⇒ Object
60 61 62 63 64 |
# File 'lib/morpheus/api/tasks_interface.rb', line 60 def get_type(id, params={}) url = "#{@base_url}/api/task-types/#{id}" headers = { params: params, authorization: "Bearer #{@access_token}" } execute(method: :get, url: url, headers: headers) end |
#list(params = {}) ⇒ Object
5 6 7 8 9 10 |
# File 'lib/morpheus/api/tasks_interface.rb', line 5 def list(params={}) url = "#{@base_url}/api/tasks" headers = { params: params, authorization: "Bearer #{@access_token}" } opts = {method: :get, url: url, headers: headers} execute(opts) end |
#list_types(params = {}) ⇒ Object
54 55 56 57 58 |
# File 'lib/morpheus/api/tasks_interface.rb', line 54 def list_types(params={}) url = "#{@base_url}/api/task-types" headers = { params: params, authorization: "Bearer #{@access_token}" } execute(method: :get, url: url, headers: headers) end |
#run(id, options) ⇒ Object
47 48 49 50 51 52 |
# File 'lib/morpheus/api/tasks_interface.rb', line 47 def run(id, ) url = "#{@base_url}/api/tasks/#{id}/execute" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } payload = execute(method: :post, url: url, headers: headers, payload: payload.to_json) end |
#update(id, options) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/morpheus/api/tasks_interface.rb', line 26 def update(id, ) url = "#{@base_url}/api/tasks/#{id}" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } payload = execute(method: :put, url: url, headers: headers, payload: payload.to_json) end |