1
%% The contents of this file are subject to the Mozilla Public License
2
%% Version 1.1 (the "License"); you may not use this file except in
3
%% compliance with the License. You may obtain a copy of the License at
4
%% http://www.mozilla.org/MPL/
6
%% Software distributed under the License is distributed on an "AS IS"
7
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
8
%% License for the specific language governing rights and limitations
11
%% The Original Code is RabbitMQ Management Plugin.
13
%% The Initial Developer of the Original Code is VMware, Inc.
14
%% Copyright (c) 2010-2012 VMware, Inc. All rights reserved.
17
-module(rabbit_mgmt_wm_parameters).
19
-export([init/1, to_json/2, content_types_provided/2, is_authorized/2,
20
resource_exists/2, basic/1]).
22
-include("rabbit_mgmt.hrl").
23
-include_lib("webmachine/include/webmachine.hrl").
24
-include_lib("rabbit_common/include/rabbit.hrl").
26
%%--------------------------------------------------------------------
28
init(_Config) -> {ok, #context{}}.
30
content_types_provided(ReqData, Context) ->
31
{[{"application/json", to_json}], ReqData, Context}.
33
resource_exists(ReqData, Context) ->
34
{case basic(ReqData) of
37
end, ReqData, Context}.
39
to_json(ReqData, Context) ->
40
rabbit_mgmt_util:reply_list(basic(ReqData), ReqData, Context).
42
is_authorized(ReqData, Context) ->
43
rabbit_mgmt_util:is_authorized_admin(ReqData, Context).
45
%%--------------------------------------------------------------------
48
Raw = case rabbit_mgmt_util:id(component, ReqData) of
49
none -> rabbit_runtime_parameters:list();
50
Name -> case rabbit_mgmt_util:vhost(ReqData) of
51
none -> rabbit_runtime_parameters:list_strict(
53
not_found -> not_found;
54
VHost -> rabbit_runtime_parameters:list_strict(
59
not_found -> not_found;
60
_ -> [rabbit_mgmt_format:parameter(P) || P <- Raw]