Revision 453dc693
Added by Joseph Magen over 9 years ago
app/controllers/api/base_controller.rb | ||
---|---|---|
instance_variable_get :"@#{resource_name}" or raise 'no resource loaded'
|
||
end
|
||
|
||
# overwrites resource_scope in FindCommon to consider nested objects
|
||
def resource_scope(options = {})
|
||
options[:association] ||= controller_name
|
||
if nested_obj && nested_obj.respond_to?(options[:association])
|
||
association = nested_obj.send(options[:association])
|
||
if association.respond_to?(:authorized)
|
||
association.authorized(options[:permission], resource_class)
|
||
else
|
||
association
|
||
end
|
||
else
|
||
super(options)
|
||
end
|
||
end
|
||
|
||
def resource_scope_for_index(options = {})
|
||
resource_scope(options).search_for(*search_options).paginate(paginate_options)
|
||
end
|
||
|
||
def api_request?
|
||
true
|
||
end
|
||
... | ... | |
false
|
||
end
|
||
|
||
# searches for a resource based on its name and assign it to an instance variable
|
||
# required for models which implement the to_param method
|
||
#
|
||
# example:
|
||
# @host = Host.find_resource params[:id]
|
||
def find_resource(controller = controller_name)
|
||
scope = resource_scope(controller)
|
||
resource = scope.find(params[:id])
|
||
|
||
if resource
|
||
return instance_variable_set(:"@#{resource_name}", resource)
|
||
else
|
||
not_found
|
||
end
|
||
end
|
||
|
||
def set_default_response_format
|
||
request.format = :json if params[:format].blank?
|
||
end
|
app/controllers/api/v1/common_parameters_controller.rb | ||
---|---|---|
module Api
|
||
module V1
|
||
class CommonParametersController < V1::BaseController
|
||
before_filter(:only => %w{show update destroy}) { find_resource('globals') }
|
||
before_filter :find_resource, :only => %w{show update destroy}
|
||
|
||
api :GET, "/common_parameters/", "List all common parameters."
|
||
param :search, String, :desc => "filter results"
|
app/controllers/api/v1/config_templates_controller.rb | ||
---|---|---|
class ConfigTemplatesController < V1::BaseController
|
||
include Foreman::Renderer
|
||
|
||
before_filter(:only => %w{show update destroy}) { find_resource('templates') }
|
||
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]
|
||
|
app/controllers/api/v1/hosts_controller.rb | ||
---|---|---|
|
||
private
|
||
|
||
def resource_scope(controller = controller_name)
|
||
Host.authorized("#{action_permission}_#{controller}", Host)
|
||
def resource_class
|
||
Host::Managed
|
||
end
|
||
|
||
# this is required for template generation (such as pxelinux) which is not done via a web request
|
app/controllers/api/v1/lookup_keys_controller.rb | ||
---|---|---|
module Api
|
||
module V1
|
||
class LookupKeysController < V1::BaseController
|
||
before_filter(:only => %w{show update destroy}) { find_resource('external_variables') }
|
||
before_filter :find_resource, :only => %w{show update destroy}
|
||
before_filter :setup_search_options, :only => :index
|
||
|
||
api :GET, "/lookup_keys/", "List all lookup_keys."
|
app/controllers/api/v2/architectures_controller.rb | ||
---|---|---|
module Api
|
||
module V2
|
||
class ArchitecturesController < V2::BaseController
|
||
before_filter :find_optional_nested_object
|
||
before_filter :find_resource, :only => %w{show update destroy}
|
||
|
||
api :GET, "/architectures/", N_("List all architectures")
|
||
api :GET, "/operatingsystems/:operatingsystem_id/architectures", N_("List all architectures for operating system")
|
||
param_group :search_and_pagination, ::Api::V2::BaseController
|
||
param :operatingsystem_id, String, :desc => N_("ID of operating system")
|
||
|
||
def index
|
||
@architectures = Architecture.
|
||
authorized(:view_architectures).
|
||
includes(:operatingsystems).
|
||
search_for(*search_options).paginate(paginate_options)
|
||
@architectures = resource_scope_for_index
|
||
end
|
||
|
||
api :GET, "/architectures/:id/", N_("Show an architecture")
|
||
... | ... | |
def_param_group :architecture do
|
||
param :architecture, Hash, :required => true, :action_aware => true do
|
||
param :name, String, :required => true
|
||
param :operatingsystem_ids, Array, :desc => N_("Operatingsystem IDs")
|
||
param :operatingsystem_ids, Array, :desc => N_("Operating system IDs")
|
||
end
|
||
end
|
||
|
||
... | ... | |
def destroy
|
||
process_response @architecture.destroy
|
||
end
|
||
|
||
private
|
||
|
||
def allowed_nested_id
|
||
%w(operatingsystem_id)
|
||
end
|
||
|
||
end
|
||
end
|
||
end
|
app/controllers/api/v2/audits_controller.rb | ||
---|---|---|
module V2
|
||
class AuditsController < V2::BaseController
|
||
before_filter :find_resource, :only => %w{show}
|
||
before_filter(:only => %w{show}) { find_resource('audit_logs') }
|
||
before_filter :setup_search_options, :only => :index
|
||
|
||
api :GET, "/audits/", N_("List all audits")
|
||
... | ... | |
param_group :search_and_pagination, ::Api::V2::BaseController
|
||
|
||
def index
|
||
Audit.unscoped { @audits = Audit.authorized(:view_audit_logs).search_for(*search_options).paginate(paginate_options) }
|
||
Audit.unscoped { @audits = resource_scope_for_index(:permission => :view_audit_logs) }
|
||
end
|
||
|
||
api :GET, "/audits/:id/", N_("Show an audit")
|
app/controllers/api/v2/auth_source_ldaps_controller.rb | ||
---|---|---|
param_group :pagination, ::Api::V2::BaseController
|
||
|
||
def index
|
||
@auth_source_ldaps = AuthSourceLdap.paginate(paginate_options)
|
||
@auth_source_ldaps = resource_scope.paginate(paginate_options)
|
||
end
|
||
|
||
api :GET, "/auth_source_ldaps/:id/", N_("Show an LDAP authentication source")
|
app/controllers/api/v2/bookmarks_controller.rb | ||
---|---|---|
param_group :pagination, ::Api::V2::BaseController
|
||
|
||
def index
|
||
@bookmarks = Bookmark.paginate(paginate_options)
|
||
@bookmarks = resource_scope.paginate(paginate_options)
|
||
end
|
||
|
||
api :GET, "/bookmarks/:id/", N_("Show a bookmark")
|
app/controllers/api/v2/common_parameters_controller.rb | ||
---|---|---|
module Api
|
||
module V2
|
||
class CommonParametersController < V2::BaseController
|
||
before_filter(:only => %w{show update destroy}) { find_resource('globals') }
|
||
before_filter :find_resource, :only => %w{show update destroy}
|
||
|
||
api :GET, "/common_parameters/", N_("List all global parameters.")
|
||
param_group :search_and_pagination, ::Api::V2::BaseController
|
||
|
||
def index
|
||
@common_parameters = CommonParameter.
|
||
authorized(:view_globals, CommonParameter).
|
||
search_for(*search_options).
|
||
paginate(paginate_options)
|
||
@common_parameters = resource_scope_for_index(:permission => :view_globals)
|
||
end
|
||
|
||
api :GET, "/common_parameters/:id/", N_("Show a global parameter")
|
app/controllers/api/v2/compute_profiles_controller.rb | ||
---|---|---|
param_group :search_and_pagination, ::Api::V2::BaseController
|
||
|
||
def index
|
||
@compute_profiles = ComputeProfile.authorized(:view_config_profiles).
|
||
search_for(*search_options).paginate(paginate_options)
|
||
@compute_profiles = resource_scope_for_index
|
||
end
|
||
|
||
api :GET, "/compute_profiles/:id/", N_("Show a compute profile")
|
app/controllers/api/v2/compute_resources_controller.rb | ||
---|---|---|
param_group :search_and_pagination, ::Api::V2::BaseController
|
||
|
||
def index
|
||
@compute_resources = resource_scope.search_for(*search_options).paginate(paginate_options)
|
||
@compute_resources = resource_scope_for_index
|
||
end
|
||
|
||
api :GET, "/compute_resources/:id/", N_("Show a compute resource")
|
app/controllers/api/v2/config_groups_controller.rb | ||
---|---|---|
param_group :search_and_pagination, ::Api::V2::BaseController
|
||
|
||
def index
|
||
@config_groups = ConfigGroup.authorized(:view_config_groups).search_for(*search_options).paginate(paginate_options)
|
||
@config_groups = resource_scope_for_index
|
||
end
|
||
|
||
api :GET, "/config_groups/:id/", N_("Show a config group")
|
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
|
app/controllers/api/v2/domains_controller.rb | ||
---|---|---|
DOC
|
||
end
|
||
|
||
before_filter :find_optional_nested_object
|
||
before_filter :find_resource, :only => %w{show update destroy}
|
||
|
||
api :GET, "/domains/", N_("List of domains")
|
||
api :GET, "/subnets/:subnet_id/domains", N_("List of domains per subnet")
|
||
api :GET, "/locations/:location_id/domains", N_("List of domains per location")
|
||
api :GET, "/organizations/:organization_id/domains", N_("List of domains per organization")
|
||
param :subnet_id, String, :desc => N_("ID of subnet")
|
||
param_group :taxonomy_scope, ::Api::V2::BaseController
|
||
param_group :search_and_pagination, ::Api::V2::BaseController
|
||
|
||
def index
|
||
@domains = Domain.
|
||
authorized(:view_domains).
|
||
search_for(*search_options).paginate(paginate_options)
|
||
@domains = resource_scope_for_index
|
||
end
|
||
|
||
api :GET, "/domains/:id/", N_("Show a domain")
|
||
... | ... | |
def destroy
|
||
process_response @domain.destroy
|
||
end
|
||
|
||
private
|
||
|
||
def allowed_nested_id
|
||
%w(subnet_id location_id organization_id)
|
||
end
|
||
|
||
end
|
||
end
|
||
end
|
app/controllers/api/v2/environments_controller.rb | ||
---|---|---|
include Api::Version2
|
||
include Api::TaxonomyScope
|
||
include Api::ImportPuppetclassesCommonController
|
||
|
||
before_filter :find_optional_nested_object
|
||
before_filter :find_resource, :only => %w{show update destroy}
|
||
|
||
api :GET, "/environments/", N_("List all environments")
|
||
api :GET, "/puppetclasses/:puppetclass_id/environments", N_("List environments of Puppet class")
|
||
api :GET, "/locations/:location_id/environments", N_("List environments per location")
|
||
api :GET, "/organizations/:organization_id/environments", N_("List environments per organization")
|
||
param :puppetclass_id, String, :desc => N_("ID of Puppet class")
|
||
param_group :taxonomy_scope, ::Api::V2::BaseController
|
||
param_group :search_and_pagination, ::Api::V2::BaseController
|
||
|
||
def index
|
||
@environments = Environment.
|
||
authorized(:view_environments).
|
||
search_for(*search_options).paginate(paginate_options)
|
||
@environments = resource_scope_for_index
|
||
end
|
||
|
||
api :GET, "/environments/:id/", N_("Show an environment")
|
||
... | ... | |
def destroy
|
||
process_response @environment.destroy
|
||
end
|
||
|
||
private
|
||
|
||
def allowed_nested_id
|
||
%w(puppetclass_id location_id organization_id)
|
||
end
|
||
|
||
end
|
||
end
|
||
end
|
app/controllers/api/v2/external_usergroups_controller.rb | ||
---|---|---|
before_filter :find_required_nested_object, :only => [:index, :show, :create]
|
||
|
||
api :GET, '/usergroups/:usergroup_id/external_usergroups', N_('List all external user groups for user group')
|
||
api :GET, '/auth_source_ldaps/:auth_source_ldap_id/external_usergroups', N_('List all external user groups for LDAP authentication source')
|
||
param :usergroup_id, String, :required => true, :desc => N_('ID or name of user group')
|
||
|
||
def index
|
||
@external_usergroups = @nested_obj.external_usergroups.paginate(paginate_options)
|
||
@total = @nested_obj.external_usergroups.count
|
||
@external_usergroups = resource_scope.paginate(paginate_options)
|
||
end
|
||
|
||
api :GET, '/usergroups/:usergroup_id/external_usergroups/:id', N_('Show an external user group for user group')
|
||
api :GET, '/auth_source_ldaps/:auth_source_ldap_id/external_usergroups/:id', N_('Show an external user group for LDAP authentication source')
|
||
param :usergroup_id, String, :required => true, :desc => N_('ID or name of user group')
|
||
param :id, String, :required => true, :desc => N_('ID or name of external user group')
|
||
|
||
... | ... | |
def_param_group :external_usergroup do
|
||
param :external_usergroup, Hash, :required => true, :action_aware => true, :desc => N_('External user group information') do
|
||
param :name, String, :required => true, :desc => N_('External user group name')
|
||
param :auth_source_id, Fixnum, :required => true, :desc => N_('ID of linked auth source')
|
||
param :auth_source_id, Fixnum, :required => true, :desc => N_('ID of linked authentication source')
|
||
end
|
||
end
|
||
|
||
... | ... | |
end
|
||
|
||
def allowed_nested_id
|
||
%w(usergroup_id)
|
||
%w(usergroup_id auth_source_ldap_id)
|
||
end
|
||
end
|
||
end
|
app/controllers/api/v2/fact_values_controller.rb | ||
---|---|---|
param_group :search_and_pagination, ::Api::V2::BaseController
|
||
|
||
def index
|
||
values = resource_scope.includes(:fact_name, :host).search_for(*search_options).paginate(paginate_options)
|
||
values = resource_scope_for_index.includes(:fact_name, :host)
|
||
@fact_values = FactValue.build_facts_hash(values.all)
|
||
end
|
||
|
||
def resource_scope(controller = controller_name)
|
||
FactValue.authorized(:view_facts).my_facts.no_timestamp_facts
|
||
end
|
||
|
||
end
|
||
end
|
||
end
|
app/controllers/api/v2/filters_controller.rb | ||
---|---|---|
param_group :search_and_pagination, ::Api::V2::BaseController
|
||
|
||
def index
|
||
@filters = resource_scope.search_for(*search_options).paginate(paginate_options)
|
||
@filters = resource_scope_for_index
|
||
end
|
||
|
||
api :GET, "/filters/:id/", N_("Show a filter")
|
||
... | ... | |
%w(role_id)
|
||
end
|
||
|
||
def resource_scope(controller = controller_name)
|
||
@resource_scope ||= nested_obj.present? ?
|
||
nested_obj.filters.authorized("#{action_permission}_#{controller}") :
|
||
resource_class.scoped.authorized("#{action_permission}_#{controller}")
|
||
end
|
||
|
||
end
|
||
end
|
||
end
|
app/controllers/api/v2/host_classes_controller.rb | ||
---|---|---|
|
||
api :POST, "/hosts/:host_id/puppetclass_ids", N_("Add a Puppet class to host")
|
||
param :host_id, String, :required => true, :desc => N_("ID of host")
|
||
param :puppetclass_id, String, :required => true, :desc => N_("ID of puppetclass")
|
||
param :puppetclass_id, String, :required => true, :desc => N_("ID of Puppet class")
|
||
|
||
def create
|
||
@host_class = HostClass.create!(:host_id => @host.id, :puppetclass_id => params[:puppetclass_id].to_i)
|
app/controllers/api/v2/hostgroups_controller.rb | ||
---|---|---|
include Api::Version2
|
||
include Api::TaxonomyScope
|
||
|
||
before_filter :find_optional_nested_object
|
||
before_filter :find_resource, :only => %w{show update destroy clone}
|
||
|
||
api :GET, "/hostgroups/", N_("List all host groups")
|
||
api :GET, "/puppetclasses/:puppetclass_id/hostgroups", N_("List all host groups for a Puppet class")
|
||
api :GET, "/locations/:location_id/hostgroups", N_("List all host groups per location")
|
||
api :GET, "/organizations/:organization_id/hostgroups", N_("List all host groups per organization")
|
||
param :puppetclass_id, String, :desc => N_("ID of Puppet class")
|
||
param_group :taxonomy_scope, ::Api::V2::BaseController
|
||
param_group :search_and_pagination, ::Api::V2::BaseController
|
||
|
||
def index
|
||
@hostgroups = Hostgroup.
|
||
authorized(:view_hostgroups).
|
||
includes(:hostgroup_classes, :group_parameters).
|
||
search_for(*search_options).paginate(paginate_options)
|
||
@hostgroups = resource_scope_for_index
|
||
end
|
||
|
||
api :GET, "/hostgroups/:id/", N_("Show a host group")
|
||
... | ... | |
|
||
def destroy
|
||
if @hostgroup.has_children?
|
||
render :json => {'message'=> _("Cannot delete group %{current} because it has nested groups.") % { :current => @hostgroup.title } }, :status => :conflict
|
||
render :json => {'message'=> _("Cannot delete group %{current} because it has nested host groups.") % { :current => @hostgroup.title } }, :status => :conflict
|
||
else
|
||
process_response @hostgroup.destroy
|
||
end
|
||
... | ... | |
end
|
||
end
|
||
|
||
def allowed_nested_id
|
||
%w(puppetclass_id location_id organization_id)
|
||
end
|
||
|
||
end
|
||
end
|
||
end
|
app/controllers/api/v2/hosts_controller.rb | ||
---|---|---|
wrap_parameters :host, :include => (Host::Base.attribute_names + ['image_file', 'is_owned_by', 'overwrite', 'progress_report_id'])
|
||
|
||
include Api::Version2
|
||
#TODO - should TaxonomyScope be here. It wasn't here previously
|
||
include Api::TaxonomyScope
|
||
include Foreman::Controller::SmartProxyAuth
|
||
|
||
before_filter :find_resource, :except => %w{index create facts}
|
||
before_filter :find_optional_nested_object, :except => [:facts]
|
||
before_filter :find_resource, :except => [:index, :create, :facts]
|
||
before_filter :permissions_check, :only => %w{power boot puppetrun}
|
||
add_puppetmaster_filters :facts
|
||
|
||
api :GET, "/hosts/", N_("List all hosts")
|
||
api :GET, "/hostgroups/:hostgroup_id/hosts", N_("List all hosts for a host group")
|
||
api :GET, "/locations/:location_id/hosts", N_("List hosts per location")
|
||
api :GET, "/organizations/:organization_id/hosts", N_("List hosts per organization")
|
||
api :GET, "/environments/:environment_id/hosts", N_("List hosts per environment")
|
||
param :hostgroup_id, String, :desc => N_("ID of host group")
|
||
param :location_id, String, :desc => N_("ID of location")
|
||
param :organization_id, String, :desc => N_("ID of organization")
|
||
param :environment_id, String, :desc => N_("ID of environment")
|
||
param_group :search_and_pagination, ::Api::V2::BaseController
|
||
|
||
def index
|
||
@hosts = resource_scope.search_for(*search_options).paginate(paginate_options)
|
||
@hosts = resource_scope_for_index
|
||
end
|
||
|
||
api :GET, "/hosts/:id/", N_("Show a host")
|
||
... | ... | |
|
||
private
|
||
|
||
def resource_scope(controller = controller_name)
|
||
Host.authorized("#{action_permission}_#{controller}", Host)
|
||
end
|
||
|
||
def action_permission
|
||
case params[:action]
|
||
when 'puppetrun'
|
||
... | ... | |
deny_access unless Host.authorized(permission).find(@host.id)
|
||
end
|
||
|
||
private
|
||
|
||
def resource_class
|
||
Host::Managed
|
||
end
|
||
|
||
def allowed_nested_id
|
||
%w(hostgroup_id location_id organization_id environment_id)
|
||
end
|
||
|
||
end
|
||
end
|
||
end
|
app/controllers/api/v2/images_controller.rb | ||
---|---|---|
module Api
|
||
module V2
|
||
class ImagesController < V2::BaseController
|
||
|
||
before_filter :find_required_nested_object
|
||
before_filter :find_resource, :only => %w{show update destroy}
|
||
before_filter :find_compute_resource
|
||
|
||
api :GET, "/compute_resources/:compute_resource_id/images/", N_("List all images for a compute resource")
|
||
api :GET, "/operatingsystems/:operatingsystem_id/images/", N_("List all images for operating system")
|
||
api :GET, "/architectures/:architecture_id/images/", N_("List all images for architecture")
|
||
param :compute_resource_id, String, :desc => N_("ID of compute resource")
|
||
param :architecture_id, String, :desc => N_("ID of architecture")
|
||
param :operatingsystem_id, String, :desc => N_("ID of operating system")
|
||
param_group :search_and_pagination, ::Api::V2::BaseController
|
||
param :compute_resource_id, :identifier, :required => true
|
||
|
||
def index
|
||
base = @compute_resource.images.authorized(:view_images)
|
||
@images = base.search_for(*search_options).paginate(paginate_options)
|
||
@total = base.count
|
||
@images = resource_scope_for_index
|
||
end
|
||
|
||
api :GET, "/compute_resources/:compute_resource_id/images/:id/", N_("Show an image")
|
||
api :GET, "/operatingsystems/:operatingsystem_id/images/:id/", N_("Show an image")
|
||
api :GET, "/architectures/:architecture_id/images/:id/", N_("Show an image")
|
||
param :id, :identifier, :required => true
|
||
param :compute_resource_id, :identifier, :required => true
|
||
param :compute_resource_id, String, :desc => N_("ID of compute resource")
|
||
param :architecture_id, String, :desc => N_("ID of architecture")
|
||
param :operatingsystem_id, String, :desc => N_("ID of operating system")
|
||
|
||
def show
|
||
end
|
||
... | ... | |
param :name, String, :required => true
|
||
param :username, String, :required => true
|
||
param :uuid, String, :required => true
|
||
param :compute_resource_id, :number, :required => true
|
||
param :architecture_id, :number, :required => true
|
||
param :operatingsystem_id, :number, :required => true
|
||
param :compute_resource_id, String, :desc => N_("ID of compute resource")
|
||
param :architecture_id, String, :desc => N_("ID of architecture")
|
||
param :operatingsystem_id, String, :desc => N_("ID of operating system")
|
||
end
|
||
end
|
||
|
||
... | ... | |
param_group :image, :as => :create
|
||
|
||
def create
|
||
@image = @compute_resource.images.new(params[:image])
|
||
process_response @image.save, @compute_resource
|
||
@image = nested_obj.images.new(params[:image])
|
||
process_response @image.save, nested_obj
|
||
end
|
||
|
||
api :PUT, "/compute_resources/:compute_resource_id/images/:id/", N_("Update an image")
|
||
... | ... | |
|
||
private
|
||
|
||
def find_compute_resource
|
||
@compute_resource = ComputeResource.authorized(:view_compute_resources).find(params[:compute_resource_id])
|
||
def allowed_nested_id
|
||
%w(compute_resource_id operatingsystem_id architecture_id)
|
||
end
|
||
|
||
end
|
app/controllers/api/v2/interfaces_controller.rb | ||
---|---|---|
include Api::Version2
|
||
include Api::TaxonomyScope
|
||
|
||
before_filter :find_required_nested_object, :only => [:index, :show, :create, :destroy]
|
||
before_filter :find_resource, :only => [:show, :update, :destroy]
|
||
before_filter :find_required_nested_object, :only => [:index, :show, :create]
|
||
|
||
api :GET, '/hosts/:host_id/interfaces', N_("List all interfaces for host")
|
||
api :GET, '/domains/:domain_id/interfaces', N_('List all interfaces for domain')
|
||
api :GET, '/subnets/:subnet_id/interfaces', N_('List all interfaces for subnet')
|
||
param :host_id, String, :required => true, :desc => N_("ID or name of host")
|
||
param :domain_id, String, :required => false, :desc => N_('ID or name of domain')
|
||
param :subnet_id, String, :required => false, :desc => N_('ID or name of subnet')
|
||
param :page, String, :desc => N_("paginate results")
|
||
param :per_page, String, :desc => N_("number of entries per request")
|
||
|
||
def index
|
||
@interfaces = @nested_obj.interfaces.paginate(paginate_options)
|
||
@total = @nested_obj.interfaces.count
|
||
@interfaces = resource_scope.paginate(paginate_options)
|
||
end
|
||
|
||
api :GET, '/hosts/:host_id/interfaces/:id', N_("Show an interface for host")
|
||
... | ... | |
private
|
||
|
||
def allowed_nested_id
|
||
%w(host_id)
|
||
%w(host_id domain_id subnet_id)
|
||
end
|
||
|
||
def resource_class
|
app/controllers/api/v2/media_controller.rb | ||
---|---|---|
include Api::Version2
|
||
include Api::TaxonomyScope
|
||
|
||
before_filter :find_optional_nested_object
|
||
before_filter :find_resource, :only => %w{show update destroy}
|
||
|
||
PATH_INFO = <<-eos
|
||
... | ... | |
OS_FAMILY_INFO = N_("Operating system family, available values: %{operatingsystem_families}")
|
||
|
||
api :GET, "/media/", N_("List all installation media")
|
||
api :GET, "/operatingsystems/:operatingsystem_id/media", N_("List all media for an operating system")
|
||
api :GET, "/locations/:location_id/media", N_("List all media per location")
|
||
api :GET, "/organizations/:organization_id/media", N_("List all media 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
|
||
@media = Medium.
|
||
authorized(:view_media).
|
||
search_for(*search_options).paginate(paginate_options)
|
||
@media = resource_scope_for_index
|
||
end
|
||
|
||
api :GET, "/media/:id/", N_("Show a medium")
|
||
... | ... | |
process_response @medium.destroy
|
||
end
|
||
|
||
private
|
||
|
||
def allowed_nested_id
|
||
%w(operatingsystem_id location_id organization_id)
|
||
end
|
||
|
||
end
|
||
end
|
||
end
|
app/controllers/api/v2/models_controller.rb | ||
---|---|---|
param_group :search_and_pagination, ::Api::V2::BaseController
|
||
|
||
def index
|
||
@models = Model.
|
||
authorized(:view_models).
|
||
search_for(*search_options).
|
||
paginate(paginate_options)
|
||
@models = resource_scope_for_index
|
||
end
|
||
|
||
api :GET, "/models/:id/", N_("Show a hardware model")
|
app/controllers/api/v2/operatingsystems_controller.rb | ||
---|---|---|
name 'Operating systems'
|
||
end
|
||
|
||
before_filter :find_optional_nested_object
|
||
before_filter :find_resource, :only => %w{show edit update destroy bootfiles}
|
||
|
||
api :GET, "/operatingsystems/", N_("List all operating systems")
|
||
api :GET, "/architectures/:architecture_id/operatingsystems", N_("List all operating systems for nested architecture")
|
||
api :GET, "/media/:medium_id/operatingsystems", N_("List all operating systems for nested medium")
|
||
api :GET, "/ptables/:ptable_id/operatingsystems", N_("List all operating systems for nested partition table")
|
||
api :GET, "/config_templates/:config_template_id/operatingsystems", N_("List all operating systems for nested provisioning template")
|
||
param :architecture_id, String, :desc => N_("ID of architecture")
|
||
param :medium_id, String, :desc => N_("ID of medium")
|
||
param :ptable_id, String, :desc => N_("ID of partition table")
|
||
param :config_template_id, String, :desc => N_("ID of template")
|
||
param_group :search_and_pagination, ::Api::V2::BaseController
|
||
|
||
def index
|
||
@operatingsystems = Operatingsystem.
|
||
authorized(:view_operatingsystems).
|
||
includes(:media, :architectures, :ptables, :config_templates, :os_default_templates).
|
||
search_for(*search_options).paginate(paginate_options)
|
||
@operatingsystems = resource_scope_for_index
|
||
end
|
||
|
||
api :GET, "/operatingsystems/:id/", N_("Show an OS")
|
||
api :GET, "/operatingsystems/:id/", N_("Show an operating system")
|
||
param :id, String, :required => true
|
||
|
||
def show
|
||
... | ... | |
end
|
||
end
|
||
|
||
api :POST, "/operatingsystems/", N_("Create an OS")
|
||
api :POST, "/operatingsystems/", N_("Create an operating system")
|
||
param_group :operatingsystem, :as => :create
|
||
|
||
def create
|
||
... | ... | |
process_response @operatingsystem.save
|
||
end
|
||
|
||
api :PUT, "/operatingsystems/:id/", N_("Update an OS")
|
||
api :PUT, "/operatingsystems/:id/", N_("Update an operating system")
|
||
param :id, String, :required => true
|
||
param_group :operatingsystem
|
||
|
||
... | ... | |
process_response @operatingsystem.update_attributes(params[:operatingsystem])
|
||
end
|
||
|
||
api :DELETE, "/operatingsystems/:id/", N_("Delete an OS")
|
||
api :DELETE, "/operatingsystems/:id/", N_("Delete an operating system")
|
||
param :id, String, :required => true
|
||
|
||
def destroy
|
||
process_response @operatingsystem.destroy
|
||
end
|
||
|
||
api :GET, "/operatingsystems/:id/bootfiles/", N_("List boot files for an OS")
|
||
api :GET, "/operatingsystems/:id/bootfiles/", N_("List boot files for an operating system")
|
||
param :id, String, :required => true
|
||
param :medium, String
|
||
param :architecture, String
|
||
... | ... | |
render :json => e.to_s, :status => :unprocessable_entity
|
||
end
|
||
|
||
private
|
||
|
||
def allowed_nested_id
|
||
%w(architecture_id medium_id ptable_id config_template_id)
|
||
end
|
||
|
||
end
|
||
end
|
||
end
|
app/controllers/api/v2/os_default_templates_controller.rb | ||
---|---|---|
before_filter :find_resource, :only => %w{show update destroy}
|
||
|
||
api :GET, '/operatingsystems/:operatingsystem_id/os_default_templates', N_('List default templates combinations for an operating system')
|
||
api :GET, '/config_templates/:config_template_id/os_default_templates', N_('List operating systems where this template is set as a default')
|
||
param :operatingsystem_id, String, :desc => N_("ID of operating system")
|
||
param :config_template_id, String, :desc => N_('ID of provisioning template')
|
||
param_group :pagination, ::Api::V2::BaseController
|
||
|
||
def index
|
||
@os_default_templates = nested_obj.os_default_templates.paginate(paginate_options)
|
||
@total = nested_obj.os_default_templates.count
|
||
@os_default_templates = resource_scope.paginate(paginate_options)
|
||
end
|
||
|
||
api :GET, "/operatingsystems/:operatingsystem_id/os_default_templates/:id", N_("Show a default template combination for an operating system")
|
||
... | ... | |
private
|
||
|
||
def allowed_nested_id
|
||
%w(operatingsystem_id)
|
||
%w(operatingsystem_id config_template_id)
|
||
end
|
||
|
||
|
app/controllers/api/v2/parameters_controller.rb | ||
---|---|---|
api :GET, "/locations/:location_id/parameters", N_("List all parameters for a location")
|
||
api :GET, "/organizations/:organization_id/parameters", N_("List all parameters for an organization")
|
||
param :host_id, String, :desc => N_("ID of host")
|
||
param :hostgroup_id, String, :desc => N_("ID of hostgroup")
|
||
param :hostgroup_id, String, :desc => N_("ID of host group")
|
||
param :domain_id, String, :desc => N_("ID of domain")
|
||
param :operatingsystem_id, String, :desc => N_("ID of operating system")
|
||
param :location_id, String, :desc => N_("ID of location")
|
||
... | ... | |
api :GET, "/locations/:location_id/parameters/:id", N_("Show a nested parameter for a location")
|
||
api :GET, "/organizations/:organization_id/parameters/:id", N_("Show a nested parameter for an organization")
|
||
param :host_id, String, :desc => N_("ID of host")
|
||
param :hostgroup_id, String, :desc => N_("ID of hostgroup")
|
||
param :hostgroup_id, String, :desc => N_("ID of host group")
|
||
param :domain_id, String, :desc => N_("ID of domain")
|
||
param :operatingsystem_id, String, :desc => N_("ID of operating system")
|
||
param :location_id, String, :desc => N_("ID of location")
|
||
... | ... | |
api :POST, "/locations/:location_id/parameters/", N_("Create a nested parameter for a location")
|
||
api :POST, "/organizations/:organization_id/parameters/", N_("Create a nested parameter for an organization")
|
||
param :host_id, String, :desc => N_("ID of host")
|
||
param :hostgroup_id, String, :desc => N_("ID of hostgroup")
|
||
param :hostgroup_id, String, :desc => N_("ID of host group")
|
||
param :domain_id, String, :desc => N_("ID of domain")
|
||
param :operatingsystem_id, String, :desc => N_("ID of operating system")
|
||
param :location_id, String, :desc => N_("ID of location")
|
||
... | ... | |
api :PUT, "/locations/:location_id/parameters/:id", N_("Update a nested parameter for a location")
|
||
api :PUT, "/organizations/:organization_id/parameters/:id", N_("Update a nested parameter for an organization")
|
||
param :host_id, String, :desc => N_("ID of host")
|
||
param :hostgroup_id, String, :desc => N_("ID of hostgroup")
|
||
param :hostgroup_id, String, :desc => N_("ID of host group")
|
||
param :domain_id, String, :desc => N_("ID of domain")
|
||
param :operatingsystem_id, String, :desc => N_("ID of operating system")
|
||
param :location_id, String, :desc => N_("ID of location")
|
||
... | ... | |
api :DELETE, "/locations/:location_id/parameters/:id", N_("Delete a nested parameter for a location")
|
||
api :DELETE, "/organizations/:organization_id/parameters/:id", N_("Delete a nested parameter for an organization")
|
||
param :host_id, String, :desc => N_("ID of host")
|
||
param :hostgroup_id, String, :desc => N_("ID of hostgroup")
|
||
param :hostgroup_id, String, :desc => N_("ID of host group")
|
||
param :domain_id, String, :desc => N_("ID of domain")
|
||
param :operatingsystem_id, String, :desc => N_("ID of operating system")
|
||
param :location_id, String, :desc => N_("ID of location")
|
||
... | ... | |
api :DELETE, "/locations/:location_id/parameters", N_("Delete all nested parameter for a location")
|
||
api :DELETE, "/organizations/:organization_id/parameters", N_("Delete all nested parameter for an organization")
|
||
param :host_id, String, :desc => N_("ID of host")
|
||
param :hostgroup_id, String, :desc => N_("ID of hostgroup")
|
||
param :hostgroup_id, String, :desc => N_("ID of host group")
|
||
param :domain_id, String, :desc => N_("ID of domain")
|
||
param :operatingsystem_id, String, :desc => N_("ID of operating system")
|
||
param :location_id, String, :desc => N_("ID of location")
|
app/controllers/api/v2/ptables_controller.rb | ||
---|---|---|
module Api
|
||
module V2
|
||
class PtablesController < V2::BaseController
|
||
|
||
before_filter :find_optional_nested_object
|
||
before_filter :find_resource, :only => %w{show update destroy}
|
||
|
||
api :GET, "/ptables/", N_("List all partition tables")
|
||
api :GET, "/operatingsystems/:operatingsystem_id/ptables", N_("List all partition tables for an operating system")
|
||
param :operatingsystem_id, String, :desc => N_("ID of operating system")
|
||
param_group :search_and_pagination, ::Api::V2::BaseController
|
||
|
||
def index
|
||
@ptables = Ptable.
|
||
authorized(:view_ptables).
|
||
search_for(*search_options).paginate(paginate_options)
|
||
@ptables = resource_scope_for_index
|
||
end
|
||
|
||
api :GET, "/ptables/:id/", N_("Show a partition table")
|
||
... | ... | |
process_response @ptable.destroy
|
||
end
|
||
|
||
private
|
||
|
||
def allowed_nested_id
|
||
%w(operatingsystem_id)
|
||
end
|
||
|
||
end
|
||
end
|
||
end
|
app/controllers/api/v2/puppetclasses_controller.rb | ||
---|---|---|
include Api::Version2
|
||
include Api::TaxonomyScope
|
||
|
||
before_filter :find_optional_nested_object
|
||
before_filter :find_resource, :only => %w{show update destroy}
|
||
before_filter :find_optional_nested_object, :only => [:index, :show]
|
||
|
||
api :GET, "/puppetclasses/", N_("List all Puppet classes")
|
||
api :GET, "/hosts/:host_id/puppetclasses", N_("List all Puppet classes for a host")
|
||
... | ... | |
param :host_id, String, :desc => N_("ID of host")
|
||
param :hostgroup_id, String, :desc => N_("ID of host group")
|
||
param :environment_id, String, :desc => N_("ID of environment")
|
||
param :id, String, :required => true, :desc => N_("ID of puppetclass")
|
||
param :id, String, :required => true, :desc => N_("ID of Puppet class")
|
||
|
||
def show
|
||
end
|
app/controllers/api/v2/realms_controller.rb | ||
---|---|---|
param_group :search_and_pagination, ::Api::V2::BaseController
|
||
|
||
def index
|
||
@realms = Realm.
|
||
authorized(:view_realms).
|
||
search_for(*search_options).paginate(paginate_options)
|
||
@realms = resource_scope_for_index
|
||
end
|
||
|
||
api :GET, "/realms/:id/", N_("Show a realm")
|
app/controllers/api/v2/reports_controller.rb | ||
---|---|---|
param_group :search_and_pagination, ::Api::V2::BaseController
|
||
|
||
def index
|
||
@reports = Report.
|
||
authorized(:view_reports).
|
||
my_reports.
|
||
includes(:logs => [:source, :message]).
|
||
search_for(*search_options).paginate(paginate_options)
|
||
@reports = resource_scope_for_index.my_reports.includes(:logs => [:source, :message])
|
||
@total = Report.my_reports.count
|
||
end
|
||
|
app/controllers/api/v2/roles_controller.rb | ||
---|---|---|
module Api
|
||
module V2
|
||
class RolesController < V2::BaseController
|
||
|
||
before_filter :find_optional_nested_object
|
||
before_filter :find_resource, :only => %w{show update destroy}
|
||
|
||
api :GET, "/roles/", N_("List all roles")
|
||
param_group :search_and_pagination, ::Api::V2::BaseController
|
||
|
||
def index
|
||
@roles = Role.search_for(*search_options).paginate(paginate_options)
|
||
@roles = resource_scope_for_index
|
||
end
|
||
|
||
api :GET, "/roles/:id/", N_("Show a role")
|
||
... | ... | |
def destroy
|
||
process_response @role.destroy
|
||
end
|
||
|
||
private
|
||
|
||
def allowed_nested_id
|
||
%w(user_id)
|
||
end
|
||
|
||
end
|
||
end
|
||
end
|
app/controllers/api/v2/settings_controller.rb | ||
---|---|---|
param_group :search_and_pagination, ::Api::V2::BaseController
|
||
|
||
def index
|
||
@settings = Setting.search_for(*search_options).paginate(paginate_options)
|
||
@settings = resource_scope_for_index
|
||
end
|
||
|
||
api :GET, "/settings/:id/", N_("Show a setting")
|
app/controllers/api/v2/smart_proxies_controller.rb | ||
---|---|---|
param_group :search_and_pagination, ::Api::V2::BaseController
|
||
|
||
def index
|
||
@smart_proxies = SmartProxy.authorized(:view_smart_proxies).includes(:features).
|
||
search_for(*search_options).paginate(paginate_options)
|
||
@total = SmartProxy.authorized(:view_smart_proxies).includes(:features).count
|
||
@smart_proxies = resource_scope_for_index.includes(:features)
|
||
end
|
||
|
||
api :GET, "/smart_proxies/:id/", N_("Show a smart proxy")
|
app/controllers/api/v2/subnets_controller.rb | ||
---|---|---|
include Api::Version2
|
||
include Api::TaxonomyScope
|
||
|
||
before_filter :find_optional_nested_object
|
||
before_filter :find_resource, :only => %w{show update destroy}
|
||
|
||
api :GET, '/subnets', N_("List of subnets")
|
||
api :GET, "/domains/:domain_id/subnets", N_("List of subnets for a domain")
|
||
api :GET, "/locations/:location_id/subnets", N_("List of subnets per location")
|
||
api :GET, "/organizations/:organization_id/subnets", N_("List of subnets per organization")
|
||
param :domain_id, String, :desc => N_("ID of domain")
|
||
param_group :taxonomy_scope, ::Api::V2::BaseController
|
||
param_group :search_and_pagination, ::Api::V2::BaseController
|
||
|
||
def index
|
||
@subnets = Subnet.
|
||
authorized(:view_subnets).
|
||
includes(:tftp, :dhcp, :dns).
|
||
search_for(*search_options).paginate(paginate_options)
|
||
@subnets = resource_scope_for_index.includes(:tftp, :dhcp, :dns)
|
||
end
|
||
|
||
api :GET, "/subnets/:id/", N_("Show a subnet")
|
||
... | ... | |
process_response @subnet.destroy
|
||
end
|
||
|
||
private
|
||
|
||
def allowed_nested_id
|
||
%w(domain_id location_id organization_id)
|
||
end
|
||
|
||
end
|
||
end
|
||
end
|
app/controllers/api/v2/usergroups_controller.rb | ||
---|---|---|
module Api
|
||
module V2
|
||
class UsergroupsController < V2::BaseController
|
||
|
||
before_filter :find_optional_nested_object
|
||
before_filter :find_resource, :only => %w{show update destroy}
|
||
|
||
api :GET, "/usergroups/", N_("List all user groups")
|
||
param_group :search_and_pagination, ::Api::V2::BaseController
|
||
|
||
def index
|
||
@usergroups = Usergroup.
|
||
authorized(:view_usergroups).
|
||
search_for(*search_options).paginate(paginate_options)
|
||
@usergroups = resource_scope_for_index
|
||
end
|
||
|
||
api :GET, "/usergroups/:id/", N_("Show a user group")
|
||
... | ... | |
process_response @usergroup.destroy
|
||
end
|
||
|
||
private
|
||
|
||
def allowed_nested_id
|
||
%w(user_id usergroup_id)
|
||
end
|
||
|
||
end
|
||
end
|
||
end
|
app/controllers/api/v2/users_controller.rb | ||
---|---|---|
include Foreman::Controller::UsersMixin
|
||
include Api::Version2
|
||
include Api::TaxonomyScope
|
||
before_filter :find_optional_nested_object
|
||
before_filter :find_resource, :only => [:show, :update, :destroy]
|
||
|
||
api :GET, "/users/", N_("List all users")
|
||
api :GET, "/auth_source_ldaps/:auth_source_ldap_id/users", N_("List all users for LDAP authentication source")
|
||
api :GET, "/usergroups/:usergroup_id/users", N_("List all users for user group")
|
||
api :GET, "/roles/:role_id/users", N_("List all users for role")
|
||
api :GET, "/locations/:location_id/users", N_("List all users for location")
|
||
api :GET, "/organizations/:organization_id/users", N_("List all users for organization")
|
||
param :auth_source_ldap_id, String, :desc => N_("ID of LDAP authentication source")
|
||
param :usergroup_id, String, :desc => N_("ID of user group")
|
||
param :role_id, String, :desc => N_("ID of role")
|
||
param_group :taxonomy_scope, ::Api::V2::BaseController
|
||
param_group :search_and_pagination, ::Api::V2::BaseController
|
||
|
||
def index
|
||
@users = User.
|
||
authorized(:view_users).except_hidden.
|
||
search_for(*search_options).paginate(paginate_options)
|
||
@users = resource_scope_for_index
|
||
end
|
||
|
||
api :GET, "/users/:id/", N_("Show a user")
|
||
... | ... | |
end
|
||
end
|
||
|
||
private
|
||
|
||
def allowed_nested_id
|
||
%w(auth_source_ldap_id role_id location_id organization_id usergroup_id)
|
||
end
|
||
|
||
end
|
||
end
|
||
end
|
app/controllers/concerns/api/v2/taxonomies_controller.rb | ||
---|---|---|
extend ActiveSupport::Concern
|
||
|
||
included do
|
||
before_filter :find_optional_nested_object
|
||
before_filter :find_taxonomy, :only => %w(show update destroy settings
|
||
domain_ids subnet_ids hostgroup_ids config_template_ids compute_resource_ids
|
||
medium_ids smart_proxy_ids environment_ids user_ids organization_ids realm_ids)
|
||
before_filter :find_optional_nested_object, :only => %w(index show)
|
||
before_filter :params_match_database, :only => %w(create update)
|
||
end
|
||
|
||
... | ... | |
param_group :search_and_pagination, ::Api::V2::BaseController
|
||
def index
|
||
if @nested_obj
|
||
#@taxonomies = @domain.locations.search_for(*search_options).paginate(paginate_options)
|
||
@taxonomies = @nested_obj.send(taxonomies_plural).search_for(*search_options).paginate(paginate_options)
|
||
@total = @nested_obj.send(taxonomies_plural).count
|
||
else
|
app/controllers/concerns/find_common.rb | ||
---|---|---|
@resource_class ||= resource_name.classify.constantize
|
||
end
|
||
|
||
def resource_scope(controller = controller_name)
|
||
def resource_scope(options = {})
|
||
@resource_scope ||= begin
|
||
options[:controller] ||= controller_name
|
||
options[:permission] ||= "#{action_permission}_#{options[:controller]}"
|
||
scope = resource_class.scoped
|
||
if resource_class.respond_to?(:authorized)
|
||
scope.authorized("#{action_permission}_#{controller}", resource_class)
|
||
scope.authorized(options[:permission], resource_class)
|
||
else
|
||
scope
|
||
end
|
app/controllers/concerns/foreman/controller/users_mixin.rb | ||
---|---|---|
before_filter :clear_params_on_update, :update_admin_flag, :only => :update
|
||
end
|
||
|
||
def resource_scope(controller = controller_name)
|
||
super(controller).except_hidden
|
||
def resource_scope(options = {})
|
||
super(options).except_hidden
|
||
end
|
||
|
||
protected
|
app/services/foreman/access_permissions.rb | ||
---|---|---|
:"api/v2/architectures" => [:index, :show]
|
||
map.permission :create_architectures,
|
||
:architectures => [:new, :create],
|
||
:"api/v1/architectures" => [:new, :create],
|
||
:"api/v2/architectures" => [:new, :create]
|
||
:"api/v1/architectures" => [:create],
|
||
:"api/v2/architectures" => [:create]
|
||
map.permission :edit_architectures,
|
||
:architectures => [:edit, :update],
|
||
:"api/v1/architectures" => [:edit, :update],
|
||
:"api/v2/architectures" => [:edit, :update]
|
||
:"api/v1/architectures" => [:update],
|
||
:"api/v2/architectures" => [:update]
|
||
map.permission :destroy_architectures,
|
||
:architectures => [:destroy],
|
||
:"api/v1/architectures" => [:destroy],
|
app/views/api/v2/auth_source_ldaps/show.json.rabl | ||
---|---|---|
object @auth_source_ldap
|
||
|
||
extends "api/v2/auth_source_ldaps/main"
|
||
|
||
child :external_usergroups do
|
||
extends "api/v2/external_usergroups/base"
|
||
end
|
app/views/api/v2/domains/show.json.rabl | ||
---|---|---|
node do |domain|
|
||
partial("api/v2/taxonomies/children_nodes", :object => domain)
|
||
end
|
||
|
||
child :interfaces => :interfaces do
|
||
extends "api/v2/interfaces/base"
|
||
end
|
app/views/api/v2/subnets/show.json.rabl | ||
---|---|---|
node do |subnet|
|
||
partial("api/v2/taxonomies/children_nodes", :object => subnet)
|
||
end
|
||
|
||
child :interfaces => :interfaces do
|
||
extends "api/v2/interfaces/base"
|
||
end
|
config/routes/api/v2.rb | ||
---|---|---|
# new v2 routes that point to v2
|
||
scope "(:apiv)", :module => :v2, :defaults => {:apiv => 'v2'}, :apiv => /v1|v2/, :constraints => ApiConstraints.new(:version => 2) do
|
||
|
||
resources :architectures, :except => [:new, :edit]
|
||
resources :architectures, :except => [:new, :edit] do
|
||
constraints(:id => /[^\/]+/) do
|
||
resources :hosts, :except => [:new, :edit]
|
||
end
|
||
resources :hostgroups, :except => [:new, :edit]
|
||
resources :images, :except => [:new, :edit]
|
||
resources :operatingsystems, :except => [:new, :edit]
|
||
end
|
||
|
||
resources :audits, :only => [:index, :show]
|
||
|
||
resources :auth_source_ldaps, :except => [:new, :edit]
|
||
resources :auth_source_ldaps, :except => [:new, :edit] do
|
||
resources :users, :except => [:new, :edit]
|
||
resources :external_usergroups, :except => [:new, :edit]
|
||
end
|
||
|
||
resources :bookmarks, :except => [:new, :edit]
|
||
|
||
... | ... | |
get 'revision'
|
||
end
|
||
resources :template_combinations, :only => [:index, :create]
|
||
resources :operatingsystems, :except => [:new, :edit]
|
||
resources :os_default_templates, :except => [:new, :edit]
|
||
end
|
||
|
||
resources :dashboard, :only => [:index]
|
||
... | ... | |
resources :override_values, :except => [:new, :edit]
|
||
end
|
||
end
|
||
resources :hosts, :except => [:new, :edit]
|
||
end
|
||
|
||
resources :fact_values, :only => [:index]
|
||
... | ... | |
end
|
||
resources :puppetclasses, :except => [:new, :edit]
|
||
resources :hostgroup_classes, :path => :puppetclass_ids, :only => [:index, :create, :destroy]
|
||
resources :hosts, :except => [:new, :edit]
|
||
end
|
||
|
||
resources :media, :except => [:new, :edit] do
|
||
(resources :locations, :only => [:index, :show]) if SETTINGS[:locations_enabled]
|
||
(resources :organizations, :only => [:index, :show]) if SETTINGS[:organizations_enabled]
|
||
resources :operatingsystems, :except => [:new, :edit]
|
||
end
|
||
|
||
resources :models, :except => [:new, :edit]
|
||
... | ... | |
end
|
||
end
|
||
resources :os_default_templates, :except => [:new, :edit]
|
||
resources :ptables, :except => [:new, :edit]
|
||
resources :architectures, :except => [:new, :edit]
|
||
resources :config_templates, :except => [:new, :edit]
|
||
resources :images, :except => [:new, :edit]
|
||
resources :media, :only => [:index, :show]
|
||
end
|
||
resources :os_default_templates, :except => [:new, :edit]
|
||
resources :hosts, :except => [:new, :edit]
|
||
resources :hostgroups, :except => [:new, :edit]
|
||
resources :media, :except => [:new, :edit]
|
||
resources :ptables, :except => [:new, :edit]
|
||
resources :architectures, :except => [:new, :edit]
|
||
resources :puppetclasses, :except => [:new, :edit]
|
||
resources :config_templates, :except => [:new, :edit]
|
||
resources :os_default_templates, :except => [:new, :edit]
|
||
end
|
||
|
||
resources :puppetclasses, :except => [:new, :edit] do
|
||
... | ... | |
resources :override_values, :except => [:new, :edit]
|
||
end
|
||
end
|
||
resources :hostgroups, :only => [:index]
|
||
resources :hostgroups, :only => [:index, :show]
|
||
resources :environments, :only => [:index, :show]
|
||
end
|
||
|
||
resources :ptables, :except => [:new, :edit]
|
||
resources :ptables, :except => [:new, :edit] do
|
||
resources :operatingsystems, :except => [:new, :edit]
|
||
end
|
||
|
||
resources :reports, :only => [:index, :show, :destroy] do
|
||
get :last, :on => :collection
|
||
... | ... | |
(resources :locations, :only => [:index, :show]) if SETTINGS[:locations_enabled]
|
||
(resources :organizations, :only => [:index, :show]) if SETTINGS[:organizations_enabled]
|
||
end
|
||
resources :users, :except => [:new, :edit]
|
||
end
|
||
resources :permissions, :only => [:index, :show] do
|
||
collection do
|
||
... | ... | |
resources :subnets, :except => [:new, :edit] do
|
||
(resources :locations, :only => [:index, :show]) if SETTINGS[:locations_enabled]
|
||
(resources :organizations, :only => [:index, :show]) if SETTINGS[:organizations_enabled]
|
||
resources :domains, :except => [:new, :edit]
|
||
resources :interfaces, :except => [:new, :edit]
|
||
end
|
||
|
||
resources :usergroups, :except => [:new, :edit] do
|
||
resources :users, :except => [:new, :edit]
|
||
resources :usergroups, :except => [:new, :edit]
|
||
end
|
||
|
||
resources :usergroups, :except => [:new, :edit] do
|
||
... | ... | |
resources :users, :except => [:new, :edit] do
|
||
(resources :locations, :only => [:index, :show]) if SETTINGS[:locations_enabled]
|
||
(resources :organizations, :only => [:index, :show]) if SETTINGS[:organizations_enabled]
|
||
resources :roles, :except => [:new, :edit]
|
||
resources :usergroups, :except => [:new, :edit]
|
||
end
|
||
|
||
resources :template_kinds, :only => [:index]
|
||
... | ... | |
resources :realms, :except => [:new, :edit] do
|
||
(resources :locations, :only => [:index, :show]) if SETTINGS[:locations_enabled]
|
||
(resources :organizations, :only => [:index, :show]) if SETTINGS[:organizations_enabled]
|
||
resources :hosts, :except => [:new, :edit]
|
||
resources :users, :except => [:new, :edit]
|
||
end
|
||
resources :domains, :except => [:new, :edit] do
|
||
(resources :locations, :only => [:index, :show]) if SETTINGS[:locations_enabled]
|
||
... | ... | |
delete '/', :to => :reset
|
||
end
|
||
end
|
||
resources :hosts, :except => [:new, :edit]
|
||
resources :hostgroups, :except => [:new, :edit]
|
||
resources :subnets, :except => [:new, :edit]
|
||
resources :users, :except => [:new, :edit]
|
||
resources :interfaces, :except => [:new, :edit]
|
||
end
|
||
resources :smart_proxies, :except => [:new, :edit] do
|
||
(resources :locations, :only => [:index, :show]) if SETTINGS[:locations_enabled]
|
||
... | ... | |
resources :media, :only => [:index, :show]
|
||
resources :smart_proxies, :only => [:index, :show]
|
||
resources :filters, :only => [:index, :show]
|
||
|
||
resources :hosts, :except => [:new, :edit]
|
||
resources :parameters, :except => [:new, :edit] do
|
||
collection do
|
||
delete '/', :to => :reset
|
Also available in: Unified diff
fixes #3492 - API v2 nested routes for each controller