foreman/app/controllers/api/v1/lookup_keys_controller.rb @ 30105266
d076d573 | Joseph Mitchell Magen | module Api
|
|
module V1
|
|||
class LookupKeysController < V1::BaseController
|
|||
453dc693 | Joseph Magen | before_filter :find_resource, :only => %w{show update destroy}
|
|
25d4ca6d | Joseph Mitchell Magen | before_filter :setup_search_options, :only => :index
|
|
d076d573 | Joseph Mitchell Magen | ||
api :GET, "/lookup_keys/", "List all lookup_keys."
|
|||
param :search, String, :desc => "filter results"
|
|||
param :order, String, :desc => "sort results"
|
|||
param :page, String, :desc => "paginate results"
|
|||
param :per_page, String, :desc => "number of entries per request"
|
|||
def index
|
|||
6b4b489f | Ori Rabin | @lookup_keys = PuppetclassLookupKey.authorized(:view_external_variables).
|
|
search_for(*search_options).paginate(paginate_options).to_a +
|
|||
VariableLookupKey.authorized(:view_external_variables).
|
|||
search_for(*search_options).paginate(paginate_options).to_a
|
|||
d076d573 | Joseph Mitchell Magen | end
|
|
api :GET, "/lookup_keys/:id/", "Show a lookup key."
|
|||
param :id, :identifier, :required => true
|
|||
def show
|
|||
end
|
|||
api :POST, "/lookup_keys/", "Create a lookup key."
|
|||
param :lookup_key, Hash, :required => true do
|
|||
param :key, String, :required => true
|
|||
param :puppetclass_id, :number
|
|||
param :default_value, String
|
|||
param :path, String
|
|||
param :description, String
|
|||
param :lookup_values_count, :number
|
|||
end
|
|||
def create
|
|||
@lookup_key = LookupKey.new(params[:lookup_key])
|
|||
process_response @lookup_key.save
|
|||
end
|
|||
api :PUT, "/lookup_keys/:id/", "Update a lookup key."
|
|||
param :id, :identifier, :required => true
|
|||
param :lookup_key, Hash, :required => true do
|
|||
73f028b0 | Joseph Mitchell Magen | param :key, String
|
|
d076d573 | Joseph Mitchell Magen | param :puppetclass_id, :number
|
|
param :default_value, String
|
|||
param :path, String
|
|||
param :description, String
|
|||
param :lookup_values_count, :number
|
|||
end
|
|||
def update
|
|||
process_response @lookup_key.update_attributes(params[:lookup_key])
|
|||
end
|
|||
api :DELETE, "/lookup_keys/:id/", "Delete a lookup key."
|
|||
param :id, :identifier, :required => true
|
|||
def destroy
|
|||
8076e753 | Ondrej Prazak | if @lookup_key.type == "PuppetclassLookupKey"
|
|
30105266 | Daniel Lobato | render_message 'Smart class parameters cannot be destroyed',
|
|
:status => :unprocessable_entity
|
|||
8076e753 | Ondrej Prazak | else
|
|
process_response @lookup_key.destroy
|
|||
end
|
|||
d076d573 | Joseph Mitchell Magen | end
|
|
end
|
|||
end
|
|||
end
|