Revision d4449f45
Added by Tomer Brisker over 6 years ago
config/initializers/rabl_init.rb | ||
---|---|---|
module Foreman
|
||
module RablEngineExt
|
||
def api_version
|
||
respond_to?(:response) ? response.headers["Foreman_api_version"] : '1'
|
||
respond_to?(:response) ? response.headers["Foreman_api_version"] : '2'
|
||
end
|
||
|
||
def default_options
|
||
return {:root => false, :object_root => false} if api_version.to_i > 1
|
||
{}
|
||
{:root => false, :object_root => false}
|
||
end
|
||
|
||
def collection(data, options = default_options)
|
||
... | ... | |
def data_name(data_token)
|
||
# custom object root
|
||
return params['root_name'] if respond_to?(:params) && params['root_name'].present? && !['false', false].include?(params['root_name'])
|
||
# no object root for v2
|
||
return nil if !respond_to?(:params) || api_version.to_i > 1 || ['false', false].include?(params['root_name'])
|
||
# otherwise return super since v1 has object root (config.include_child_root = true)
|
||
super
|
||
end
|
||
|
||
# Lists all extension templates that are defined in plugins
|
Also available in: Unified diff
Fixes #11389 - Remove API v1
API v1 has been deprecated since Foreman 1.9 - over 2 years ago.
This is more then enough time for anyone needing to migrate to v2.
Even though the original issue requests extraction to a plugin, I do not
see any point in investing the time and effort to maintain a long
deprecated API.