mirror of
https://github.com/fluent/fluentd-ui.git
synced 2026-05-05 19:06:12 +02:00
Add Api::ConfigDefinitionsController to fetch plugin definitions
Signed-off-by: Kenji Okimoto <okimoto@clear-code.com>
This commit is contained in:
parent
a6d27c0b14
commit
322bfefab3
53
app/controllers/api/config_definitions_controller.rb
Normal file
53
app/controllers/api/config_definitions_controller.rb
Normal file
@ -0,0 +1,53 @@
|
||||
class Api::ConfigDefinitionsController < ApplicationController
|
||||
before_action :login_required
|
||||
|
||||
def index
|
||||
name = params[:name]
|
||||
type = params[:type]
|
||||
prefix = case type
|
||||
when "input"
|
||||
"in"
|
||||
when "output"
|
||||
"out"
|
||||
when "filter"
|
||||
"filter"
|
||||
when "parse"
|
||||
"parser"
|
||||
when "format"
|
||||
"formatter"
|
||||
when "parser", "formatter", "buffer", "storage"
|
||||
type
|
||||
end
|
||||
|
||||
target_class = Fluentd::Setting.const_get("#{prefix}_#{name}".classify)
|
||||
target = target_class.new
|
||||
|
||||
common_options = target.common_options.map do |key|
|
||||
h = {
|
||||
name: key,
|
||||
type: target.column_type(key),
|
||||
desc: target.desc(key)
|
||||
}
|
||||
h[:list] = target.list_of(key) if target.column_type(key) == :enum
|
||||
h
|
||||
end
|
||||
|
||||
advanced_options = target.advanced_options.map do |key|
|
||||
h = {
|
||||
name: key,
|
||||
type: target.column_type(key),
|
||||
desc: target.desc(key)
|
||||
}
|
||||
h[:list] = target.list_of(key) if target.column_type(key) == :enum
|
||||
h
|
||||
end
|
||||
|
||||
options = {
|
||||
type: type,
|
||||
name: name,
|
||||
commonOptions: common_options,
|
||||
advancedOptions: advanced_options
|
||||
}
|
||||
render json: options
|
||||
end
|
||||
end
|
||||
@ -129,5 +129,6 @@ Rails.application.routes.draw do
|
||||
post "grok_to_regexp"
|
||||
|
||||
resources :settings, only: [:index, :show, :update, :destroy], defaults: { format: "json" }
|
||||
resources :config_definitions, only: [:index], defaults: { format: "json" }
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user