Project

General

Profile

« Previous | Next » 

Revision 453dc693

Added by Joseph Magen over 9 years ago

fixes #3492 - API v2 nested routes for each controller

View differences:

app/controllers/api/v2/config_templates_controller.rb
include Api::TaxonomyScope
include Foreman::Renderer
before_filter(:only => %w{show update destroy}) { find_resource('templates') }
before_filter :find_optional_nested_object
before_filter :find_resource, :only => %w{show update destroy}
before_filter :handle_template_upload, :only => [:create, :update]
before_filter :process_template_kind, :only => [:create, :update]
before_filter :process_operatingsystems, :only => [:create, :update]
api :GET, "/config_templates/", N_("List provisioning templates")
api :GET, "/operatingsystem/:operatingsystem_id/config_templates", N_("List provisioning templates per operating system")
api :GET, "/locations/:location_id/config_templates/", N_("List provisioning templates per location")
api :GET, "/organizations/:organization_id/config_templates/", N_("List provisioning templates per organization")
param :operatingsystem_id, String, :desc => N_("ID of operating system")
param_group :taxonomy_scope, ::Api::V2::BaseController
param_group :search_and_pagination, ::Api::V2::BaseController
def index
@config_templates = ConfigTemplate.
authorized(:view_templates).
search_for(*search_options).paginate(paginate_options).
includes(:operatingsystems, :template_combinations, :template_kind)
@config_templates = resource_scope_for_index(:permission => :view_templates).includes(:template_kind)
end
api :GET, "/config_templates/:id", N_("Show provisioning template details")
......
ct[:operatingsystem_ids] = operatingsystems.collect {|os| os[:id]}
end
def allowed_nested_id
%w(operatingsystem_id location_id organization_id)
end
end
end
end

Also available in: Unified diff