class Morpheus::RestInterface

Interface class to be subclassed by interfaces that provide CRUD endpoints Subclasses must override the base_path method

Public Instance Methods

base_path() click to toggle source

subclasses should override in your interface Example: “/api/things”

# File lib/morpheus/api/rest_interface.rb, line 9
def base_path
  raise "#{self.class} has not defined base_path!" if @options[:base_path].nil?
  @options[:base_path]
end
create(payload, params={}, headers={}) click to toggle source
# File lib/morpheus/api/rest_interface.rb, line 23
def create(payload, params={}, headers={})
  execute(method: :post, url: "#{base_path}", params: params, payload: payload, headers: headers)
end
destroy(id, params = {}, headers={}) click to toggle source
# File lib/morpheus/api/rest_interface.rb, line 32
def destroy(id, params = {}, headers={})
  validate_id!(id)
  execute(method: :delete, url: "#{base_path}/#{CGI::escape(id.to_s)}", params: params, headers: headers)
end
get(id, params={}, headers={}) click to toggle source
# File lib/morpheus/api/rest_interface.rb, line 18
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={}) click to toggle source
# File lib/morpheus/api/rest_interface.rb, line 14
def list(params={}, headers={})
  execute(method: :get, url: "#{base_path}", params: params, headers: headers)
end
update(id, payload, params={}, headers={}) click to toggle source
# File lib/morpheus/api/rest_interface.rb, line 27
def update(id, payload, params={}, headers={})
  validate_id!(id)
  execute(method: :put, url: "#{base_path}/#{CGI::escape(id.to_s)}", params: params, payload: payload, headers: headers)
end