Skip to content

Commit

Permalink
Add the /api/product_info route with product and branding info
Browse files Browse the repository at this point in the history
  • Loading branch information
skateman committed Oct 2, 2018
1 parent 83e07df commit d262868
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 13 deletions.
36 changes: 27 additions & 9 deletions app/controllers/api/api_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,30 @@ def options

def index
res = {
:name => ApiConfig.base.name,
:description => ApiConfig.base.description,
:version => ManageIQ::Api::VERSION,
:versions => entrypoint_versions,
:settings => user_settings,
:identity => auth_identity,
:server_info => server_info,
:product_info => product_info
:name => ApiConfig.base.name,
:description => ApiConfig.base.description,
:version => ManageIQ::Api::VERSION,
:versions => entrypoint_versions,
:settings => user_settings,
:identity => auth_identity,
:server_info => server_info,
:product_info => product_info_data,
:branding_info => branding_info
}
res[:authorization] = auth_authorization if attribute_selection.include?("authorization")
res[:collections] = entrypoint_collections
render_resource :entrypoint, res
end

def product_info
res = {
:product_info => product_info_data,
:branding_info => branding_info
}

render_resource :product_info, res
end

private

def entrypoint_versions
Expand All @@ -46,6 +56,14 @@ def auth_identity
}
end

def branding_info
{
:brand => Settings.server.custom_brand || ActionController::Base.helpers.image_path("layout/brand.svg"),
:logo => Settings.server.custom_logo || ActionController::Base.helpers.image_path("layout/login-screen-logo.png"),
:login_logo => Settings.server.custom_login_logo
}
end

def entrypoint_collections
collection_config.collections_with_description.sort.collect do |collection_name, description|
{
Expand All @@ -70,7 +88,7 @@ def server_info
}
end

def product_info
def product_info_data
{
:name => Vmdb::Appliance.PRODUCT_NAME,
:name_full => I18n.t("product.name_full"),
Expand Down
8 changes: 4 additions & 4 deletions app/controllers/api/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ class BaseController < ActionController::API
include ActionController::HttpAuthentication::Basic::ControllerMethods

before_action :log_request_initiated
before_action :require_api_user_or_token, :except => [:options]
before_action :set_gettext_locale, :set_access_control_headers, :parse_api_request, :log_api_request,
:validate_api_request
before_action :validate_api_action, :except => [:options]
before_action :require_api_user_or_token, :except => [:options, :product_info]
before_action :set_gettext_locale, :set_access_control_headers, :parse_api_request, :log_api_request
before_action :validate_api_request, :except => [:product_info]
before_action :validate_api_action, :except => [:options, :product_info]
before_action :validate_response_format, :except => [:destroy]
before_action :ensure_pagination, :only => :index
after_action :log_api_response
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
match "/", :to => "api#options", :via => :options

get "/ping" => "ping#index"
get "/product_info" => "api#product_info"

Api::ApiConfig.collections.each do |collection_name, collection|
# OPTIONS action for each collection
Expand Down

0 comments on commit d262868

Please sign in to comment.