%%%----------------------------------------------------------------------------- %%% @copyright (C) 2011-2019, 2600Hz %%% @doc Display various information %%% @author Edouard Swiac %%% @author James Aimonetti %%% @end %%%----------------------------------------------------------------------------- -module(cb_about). -export([init/0 ,allowed_methods/0 ,resource_exists/0 ,validate/1 ]). -include("crossbar.hrl"). %%%============================================================================= %%% API %%%============================================================================= %%------------------------------------------------------------------------------ %% @doc Initializes the bindings this module will respond to. %% @end %%------------------------------------------------------------------------------ -spec init() -> 'ok'. init() -> _ = crossbar_bindings:bind(<<"*.allowed_methods.about">>, ?MODULE, 'allowed_methods'), _ = crossbar_bindings:bind(<<"*.resource_exists.about">>, ?MODULE, 'resource_exists'), _ = crossbar_bindings:bind(<<"*.validate.about">>, ?MODULE, 'validate'). %%------------------------------------------------------------------------------ %% @doc Given the path tokens related to this module, what HTTP methods are %% going to be responded to. %% @end %%------------------------------------------------------------------------------ -spec allowed_methods() -> http_methods(). allowed_methods() -> [?HTTP_GET]. %%------------------------------------------------------------------------------ %% @doc This function determines if the provided list of Nouns are valid. %% Failure here returns `404 Not Found'. %% @end %%------------------------------------------------------------------------------ -spec resource_exists() -> 'true'. resource_exists() -> 'true'. %%------------------------------------------------------------------------------ %% @doc This function determines if the parameters and content are correct %% for this request %% %% Failure here returns 400. %% @end %%------------------------------------------------------------------------------ -spec validate(cb_context:context()) -> cb_context:context(). validate(Context) -> display_version(Context). %%%============================================================================= %%% Internal functions %%%============================================================================= %%------------------------------------------------------------------------------ %% @doc Display the current version of kazoo %% @end %%------------------------------------------------------------------------------ -spec display_version(cb_context:context()) -> cb_context:context(). display_version(Context) -> JObj = kz_json:from_list( [{<<"version">>, kz_util:kazoo_version()} ,{<<"used_memory">>, erlang:memory('total')} ,{<<"processes">>, erlang:system_info('process_count')} ,{<<"ports">>, length(erlang:ports())} ,{<<"erlang_version">>, kz_term:to_binary(erlang:system_info('otp_release'))} ]), crossbar_util:response(JObj, Context).