chore: reformat mgmt
This commit is contained in:
parent
2b73a80dba
commit
c70462f287
|
@ -106,9 +106,11 @@ schema("/configs_reset/:rootname") ->
|
|||
post => #{
|
||||
tags => [conf],
|
||||
description =>
|
||||
<<"Reset the config entry specified by the query string parameter `conf_path`.<br/>\n"
|
||||
"- For a config entry that has default value, this resets it to the default value;\n"
|
||||
"- For a config entry that has no default value, an error 400 will be returned">>,
|
||||
<<
|
||||
"Reset the config entry specified by the query string parameter `conf_path`.<br/>\n"
|
||||
"- For a config entry that has default value, this resets it to the default value;\n"
|
||||
"- For a config entry that has no default value, an error 400 will be returned"
|
||||
>>,
|
||||
%% We only return "200" rather than the new configs that has been changed, as
|
||||
%% the schema of the changed configs is depends on the request parameter
|
||||
%% `conf_path`, it cannot be defined here.
|
||||
|
|
|
@ -61,10 +61,13 @@ schema("/listeners_status") ->
|
|||
get => #{
|
||||
tags => [<<"listeners">>],
|
||||
desc => <<"List all running node's listeners live status. group by listener type">>,
|
||||
responses => #{200 =>
|
||||
emqx_dashboard_swagger:schema_with_example(
|
||||
?ARRAY(?R_REF(listener_type_status)),
|
||||
listener_type_status_example())}
|
||||
responses => #{
|
||||
200 =>
|
||||
emqx_dashboard_swagger:schema_with_example(
|
||||
?ARRAY(?R_REF(listener_type_status)),
|
||||
listener_type_status_example()
|
||||
)
|
||||
}
|
||||
}
|
||||
};
|
||||
schema("/listeners") ->
|
||||
|
@ -80,10 +83,13 @@ schema("/listeners") ->
|
|||
#{desc => "Listener type", in => query, required => false, example => tcp}
|
||||
)}
|
||||
],
|
||||
responses => #{200 =>
|
||||
emqx_dashboard_swagger:schema_with_example(
|
||||
?ARRAY(?R_REF(listener_id_status)),
|
||||
listener_id_status_example())}
|
||||
responses => #{
|
||||
200 =>
|
||||
emqx_dashboard_swagger:schema_with_example(
|
||||
?ARRAY(?R_REF(listener_id_status)),
|
||||
listener_id_status_example()
|
||||
)
|
||||
}
|
||||
}
|
||||
};
|
||||
schema("/listeners/:id") ->
|
||||
|
@ -188,8 +194,11 @@ fields(listener_id_status) ->
|
|||
[
|
||||
{enable, ?HOCON(boolean(), #{desc => "Listener enable", required => true})},
|
||||
{number, ?HOCON(typerefl:pos_integer(), #{desc => "ListenerId counter"})},
|
||||
{bind, ?HOCON(hoconsc:union([emqx_schema:ip_port(), integer()]),
|
||||
#{desc => "Listener bind addr", required => true})},
|
||||
{bind,
|
||||
?HOCON(
|
||||
hoconsc:union([emqx_schema:ip_port(), integer()]),
|
||||
#{desc => "Listener bind addr", required => true}
|
||||
)},
|
||||
{acceptors, ?HOCON(typerefl:pos_integer(), #{desc => "ListenerId acceptors"})},
|
||||
{status, ?HOCON(?R_REF(status))},
|
||||
{node_status, ?HOCON(?ARRAY(?R_REF(node_status)))}
|
||||
|
@ -210,7 +219,8 @@ fields(Type) ->
|
|||
listener_schema(Opts) ->
|
||||
emqx_dashboard_swagger:schema_with_example(
|
||||
?UNION(lists:map(fun(#{ref := Ref}) -> Ref end, listeners_info(Opts))),
|
||||
tcp_schema_example()).
|
||||
tcp_schema_example()
|
||||
).
|
||||
|
||||
listeners_type() ->
|
||||
lists:map(
|
||||
|
@ -274,11 +284,13 @@ validate_id(Id) ->
|
|||
%% api
|
||||
listener_type_status(get, _Request) ->
|
||||
Listeners = maps:to_list(listener_status_by_type(list_listeners(), #{})),
|
||||
List = lists:map(fun({Type, L}) ->
|
||||
L1 = maps:without([bind, acceptors], L),
|
||||
L1#{type => Type}
|
||||
end,
|
||||
Listeners),
|
||||
List = lists:map(
|
||||
fun({Type, L}) ->
|
||||
L1 = maps:without([bind, acceptors], L),
|
||||
L1#{type => Type}
|
||||
end,
|
||||
Listeners
|
||||
),
|
||||
{200, List}.
|
||||
|
||||
list_listeners(get, #{query_string := Query}) ->
|
||||
|
@ -566,13 +578,15 @@ listener_type_status_example() ->
|
|||
node_status => #{
|
||||
'emqx@127.0.0.1' => #{
|
||||
current_connections => 11,
|
||||
max_connections => 1024000},
|
||||
max_connections => 1024000
|
||||
},
|
||||
'emqx@127.0.0.2' => #{
|
||||
current_connections => 10,
|
||||
max_connections => 1024000}
|
||||
max_connections => 1024000
|
||||
}
|
||||
},
|
||||
status => #{
|
||||
current_connections => 21,
|
||||
current_connections => 21,
|
||||
max_connections => 2048000
|
||||
},
|
||||
type => tcp
|
||||
|
@ -583,13 +597,15 @@ listener_type_status_example() ->
|
|||
node_status => #{
|
||||
'emqx@127.0.0.1' => #{
|
||||
current_connections => 31,
|
||||
max_connections => infinity},
|
||||
max_connections => infinity
|
||||
},
|
||||
'emqx@127.0.0.2' => #{
|
||||
current_connections => 40,
|
||||
max_connections => infinity}
|
||||
max_connections => infinity
|
||||
}
|
||||
},
|
||||
status => #{
|
||||
current_connections => 71,
|
||||
current_connections => 71,
|
||||
max_connections => infinity
|
||||
},
|
||||
type => ssl
|
||||
|
@ -600,8 +616,8 @@ listener_id_status_example() ->
|
|||
[
|
||||
#{
|
||||
acceptors => 16,
|
||||
bind => <<"0.0.0.0:1884">>,
|
||||
enable => true,
|
||||
bind => <<"0.0.0.0:1884">>,
|
||||
enable => true,
|
||||
id => <<"tcp:demo">>,
|
||||
node_status => #{
|
||||
'emqx@127.0.0.1' => #{
|
||||
|
@ -621,8 +637,8 @@ listener_id_status_example() ->
|
|||
},
|
||||
#{
|
||||
acceptors => 32,
|
||||
bind => <<"0.0.0.0:1883">>,
|
||||
enable => true,
|
||||
bind => <<"0.0.0.0:1883">>,
|
||||
enable => true,
|
||||
id => <<"tcp:default">>,
|
||||
node_status => #{
|
||||
'emqx@127.0.0.1' => #{
|
||||
|
@ -652,8 +668,8 @@ tcp_schema_example() ->
|
|||
max_connections => 204800,
|
||||
mountpoint => <<"/">>,
|
||||
proxy_protocol => false,
|
||||
proxy_protocol_timeout => <<"3s">>,
|
||||
running => true,
|
||||
proxy_protocol_timeout => <<"3s">>,
|
||||
running => true,
|
||||
tcp => #{
|
||||
active_n => 100,
|
||||
backlog => 1024,
|
||||
|
|
|
@ -22,14 +22,14 @@
|
|||
-include_lib("typerefl/include/types.hrl").
|
||||
|
||||
%% API
|
||||
-export([ api_spec/0
|
||||
, paths/0
|
||||
, schema/1
|
||||
, namespace/0
|
||||
]).
|
||||
-export([
|
||||
api_spec/0,
|
||||
paths/0,
|
||||
schema/1,
|
||||
namespace/0
|
||||
]).
|
||||
|
||||
-export([ sys/2
|
||||
]).
|
||||
-export([sys/2]).
|
||||
|
||||
-define(TAGS, [<<"sys">>]).
|
||||
|
||||
|
@ -61,8 +61,8 @@ schema("/mqtt/sys_topics") ->
|
|||
responses =>
|
||||
#{
|
||||
200 => schema_sys_topics()
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
put =>
|
||||
#{
|
||||
tags => ?TAGS,
|
||||
|
@ -71,20 +71,24 @@ schema("/mqtt/sys_topics") ->
|
|||
responses =>
|
||||
#{
|
||||
200 => schema_sys_topics()
|
||||
}
|
||||
}
|
||||
}.
|
||||
}
|
||||
}
|
||||
}.
|
||||
|
||||
schema_sys_topics() ->
|
||||
emqx_dashboard_swagger:schema_with_example(
|
||||
hoconsc:ref(emqx_schema, "sys_topics"), example_sys_topics()).
|
||||
hoconsc:ref(emqx_schema, "sys_topics"), example_sys_topics()
|
||||
).
|
||||
|
||||
example_sys_topics() ->
|
||||
#{<<"sys_event_messages">> =>
|
||||
#{<<"client_connected">> => true,
|
||||
<<"client_disconnected">> => true,
|
||||
<<"client_subscribed">> => false,
|
||||
<<"client_unsubscribed">> => false},
|
||||
<<"sys_heartbeat_interval">> => <<"30s">>,
|
||||
<<"sys_msg_interval">> => <<"1m">>
|
||||
}.
|
||||
#{
|
||||
<<"sys_event_messages">> =>
|
||||
#{
|
||||
<<"client_connected">> => true,
|
||||
<<"client_disconnected">> => true,
|
||||
<<"client_subscribed">> => false,
|
||||
<<"client_unsubscribed">> => false
|
||||
},
|
||||
<<"sys_heartbeat_interval">> => <<"30s">>,
|
||||
<<"sys_msg_interval">> => <<"1m">>
|
||||
}.
|
||||
|
|
|
@ -33,22 +33,27 @@ end_per_suite(_) ->
|
|||
t_get_put(_) ->
|
||||
{ok, Default} = get_sys_topics_config(),
|
||||
?assertEqual(
|
||||
#{<<"sys_event_messages">> =>
|
||||
#{<<"client_connected">> => true,
|
||||
<<"client_disconnected">> => true,
|
||||
<<"client_subscribed">> => false,
|
||||
<<"client_unsubscribed">> => false
|
||||
},
|
||||
<<"sys_heartbeat_interval">> => <<"30s">>,
|
||||
<<"sys_msg_interval">> => <<"1m">>}, Default),
|
||||
#{
|
||||
<<"sys_event_messages">> =>
|
||||
#{
|
||||
<<"client_connected">> => true,
|
||||
<<"client_disconnected">> => true,
|
||||
<<"client_subscribed">> => false,
|
||||
<<"client_unsubscribed">> => false
|
||||
},
|
||||
<<"sys_heartbeat_interval">> => <<"30s">>,
|
||||
<<"sys_msg_interval">> => <<"1m">>
|
||||
},
|
||||
Default
|
||||
),
|
||||
|
||||
NConfig = Default#{
|
||||
<<"sys_msg_interval">> => <<"4m">>,
|
||||
<<"sys_event_messages">> => #{<<"client_subscribed">> => false}
|
||||
},
|
||||
{ok, ConfigResp} = put_sys_topics_config(NConfig),
|
||||
?assertEqual(NConfig, ConfigResp),
|
||||
{ok, Default} = put_sys_topics_config(Default).
|
||||
NConfig = Default#{
|
||||
<<"sys_msg_interval">> => <<"4m">>,
|
||||
<<"sys_event_messages">> => #{<<"client_subscribed">> => false}
|
||||
},
|
||||
{ok, ConfigResp} = put_sys_topics_config(NConfig),
|
||||
?assertEqual(NConfig, ConfigResp),
|
||||
{ok, Default} = put_sys_topics_config(Default).
|
||||
|
||||
get_sys_topics_config() ->
|
||||
Path = emqx_mgmt_api_test_util:api_path(["mqtt", "sys_topics"]),
|
||||
|
|
Loading…
Reference in New Issue