class Morpheus::SecondaryRestInterface

Interface class to be subclassed by interfaces that provide CRUD endpoints for objects underneath another resource Subclasses must override the base_path(parent_id) method

Public Instance Methods

base_path(parent_id) click to toggle source

subclasses should override in your interface Example: “/api/things/#{parent_id}/widgets”

# File lib/morpheus/api/secondary_rest_interface.rb, line 10
def base_path(parent_id)
  raise "#{self.class} has not defined base_path(parent_id)!"
end
create(parent_id, payload, params={}, headers={}) click to toggle source
# File lib/morpheus/api/secondary_rest_interface.rb, line 25
def create(parent_id, payload, params={}, headers={})
  validate_id!(parent_id)
  execute(method: :post, url: "#{base_path(parent_id)}", params: params, payload: payload, headers: headers)
end
destroy(parent_id, id, params = {}, headers={}) click to toggle source
# File lib/morpheus/api/secondary_rest_interface.rb, line 36
def destroy(parent_id, id, params = {}, headers={})
  validate_id!(parent_id)
  validate_id!(id)
  execute(method: :delete, url: "#{base_path(parent_id)}/#{CGI::escape(id.to_s)}", params: params, headers: headers)
end
get(parent_id, id, params={}, headers={}) click to toggle source
# File lib/morpheus/api/secondary_rest_interface.rb, line 19
def get(parent_id, id, params={}, headers={})
  validate_id!(parent_id)
  validate_id!(id)
  execute(method: :get, url: "#{base_path(parent_id)}/#{CGI::escape(id.to_s)}", params: params, headers: headers)
end
list(parent_id, params={}, headers={}) click to toggle source
# File lib/morpheus/api/secondary_rest_interface.rb, line 14
def list(parent_id, params={}, headers={})
  validate_id!(parent_id)
  execute(method: :get, url: "#{base_path(parent_id)}", params: params, headers: headers)
end
update(parent_id, id, payload, params={}, headers={}) click to toggle source
# File lib/morpheus/api/secondary_rest_interface.rb, line 30
def update(parent_id, id, payload, params={}, headers={})
  validate_id!(parent_id)
  validate_id!(id)
  execute(method: :put, url: "#{base_path(parent_id)}/#{CGI::escape(id.to_s)}", params: params, payload: payload, headers: headers)
end