Class: Morpheus::SecondaryReadInterface
- Inherits:
-
APIClient
- Object
- APIClient
- Morpheus::SecondaryReadInterface
- Defined in:
- lib/morpheus/api/secondary_read_interface.rb
Overview
Interface class to be subclassed by interfaces that provide CRUD endpoints for objects underneath another resource Subclasses must override the base_path(resource_id) method
Instance Method Summary collapse
-
#base_path(resource_id) ⇒ Object
subclasses should override in your interface Example: "/api/things/#resource_id/widgets".
- #get(resource_id, id, params = {}, headers = {}) ⇒ Object
- #list(resource_id, params = {}, headers = {}) ⇒ Object
Instance Method Details
#base_path(resource_id) ⇒ Object
subclasses should override in your interface Example: "/api/things/#resource_id/widgets"
10 11 12 |
# File 'lib/morpheus/api/secondary_read_interface.rb', line 10 def base_path(resource_id) raise "#{self.class} has not defined base_path(resource_id)!" end |
#get(resource_id, id, params = {}, headers = {}) ⇒ Object
19 20 21 22 23 |
# File 'lib/morpheus/api/secondary_read_interface.rb', line 19 def get(resource_id, id, params={}, headers={}) validate_id!(resource_id) validate_id!(id) execute(method: :get, url: "#{base_path(resource_id)}/#{CGI::escape(id.to_s)}", params: params, headers: headers) end |
#list(resource_id, params = {}, headers = {}) ⇒ Object
14 15 16 17 |
# File 'lib/morpheus/api/secondary_read_interface.rb', line 14 def list(resource_id, params={}, headers={}) validate_id!(resource_id) execute(method: :get, url: "#{base_path(resource_id)}", params: params, headers: headers) end |