Class: Morpheus::TaskSetsInterface
- Inherits:
-
APIClient
- Object
- APIClient
- Morpheus::TaskSetsInterface
- Defined in:
- lib/morpheus/api/task_sets_interface.rb
Instance Method Summary collapse
- #create(options) ⇒ Object
- #destroy(id) ⇒ Object
- #get(options = nil) ⇒ Object
-
#initialize(access_token, refresh_token, expires_at = nil, base_url = nil) ⇒ TaskSetsInterface
constructor
A new instance of TaskSetsInterface.
Constructor Details
#initialize(access_token, refresh_token, expires_at = nil, base_url = nil) ⇒ TaskSetsInterface
Returns a new instance of TaskSetsInterface.
5 6 7 8 9 10 |
# File 'lib/morpheus/api/task_sets_interface.rb', line 5 def initialize(access_token, refresh_token,expires_at = nil, base_url=nil) @access_token = access_token @refresh_token = refresh_token @base_url = base_url @expires_at = expires_at end |
Instance Method Details
#create(options) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/morpheus/api/task_sets_interface.rb', line 29 def create() url = "#{@base_url}/api/task-sets" headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' } payload = response = Morpheus::RestClient.execute(method: :post, url: url, timeout: 30, headers: headers, verify_ssl:false, payload: payload.to_json) JSON.parse(response.to_s) end |
#destroy(id) ⇒ Object
39 40 41 42 43 44 45 |
# 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' } response = Morpheus::RestClient.execute(method: :delete, url: url, timeout: 30, headers: headers, verify_ssl:false) JSON.parse(response.to_s) end |
#get(options = nil) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/morpheus/api/task_sets_interface.rb', line 12 def get(=nil) url = "#{@base_url}/api/task-sets" 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 response = Morpheus::RestClient.execute(method: :get, url: url, timeout: 30, headers: headers, verify_ssl:false) JSON.parse(response.to_s) end |