Class: Morpheus::ReadInterface

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

Overview

Interface class to be subclassed by interfaces that are read-only and only provide list() and get() methods, not full CRUD Subclasses must override the base_path method

Instance Method Summary collapse

Instance Method Details

#base_pathObject

subclasses should override in your interface Example: "/api/things"



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

def base_path
  raise "#{self.class} has not defined base_path!" if @options[:base_path].nil?
  @options[:base_path]
end

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



19
20
21
22
# File 'lib/morpheus/api/read_interface.rb', line 19

def get(id, params={}, headers={})
  validate_id!(id)
  execute(method: :get, url: "#{base_path}/#{CGI::escape(id.to_s)}", params: params, headers: headers)
end

#list(params = {}, headers = {}) ⇒ Object



15
16
17
# File 'lib/morpheus/api/read_interface.rb', line 15

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