feat(api-clients): return client mountpoint property

This commit is contained in:
JianBo He 2022-05-03 16:52:38 +08:00
parent 8ff552c9cf
commit 7813f402c6
3 changed files with 17 additions and 6 deletions

View File

@ -245,6 +245,13 @@ emqx_gateway_api_clients {
} }
} }
mountpoint {
desc {
en: """Topic mountpoint"""
zh: """主题固定前缀"""
}
}
proto_name { proto_name {
desc { desc {
en: """Client protocol name""" en: """Client protocol name"""

View File

@ -174,9 +174,7 @@ clients_insta(delete, #{
{204} {204}
end). end).
%% FIXME: %% List the established subscriptions with mountpoint
%% List the subscription without mountpoint, but has SubOpts,
%% for example, share group ...
subscriptions(get, #{ subscriptions(get, #{
bindings := #{ bindings := #{
name := Name0, name := Name0,
@ -189,7 +187,7 @@ subscriptions(get, #{
{error, not_found} -> {error, not_found} ->
return_http_error(404, "client process not found"); return_http_error(404, "client process not found");
{error, Reason} -> {error, Reason} ->
return_http_error(500, Reason); return_http_error(400, Reason);
{ok, Subs} -> {ok, Subs} ->
{200, Subs} {200, Subs}
end end
@ -216,7 +214,7 @@ subscriptions(post, #{
{error, not_found} -> {error, not_found} ->
return_http_error(404, "client process not found"); return_http_error(404, "client process not found");
{error, Reason} -> {error, Reason} ->
return_http_error(500, Reason); return_http_error(400, Reason);
{ok, {NTopic, NSubOpts}} -> {ok, {NTopic, NSubOpts}} ->
{201, maps:merge(NSubOpts, #{topic => NTopic})} {201, maps:merge(NSubOpts, #{topic => NTopic})}
end end
@ -368,6 +366,7 @@ format_channel_info({_, Infos, Stats} = R) ->
{node, ClientInfo, Node}, {node, ClientInfo, Node},
{clientid, ClientInfo}, {clientid, ClientInfo},
{username, ClientInfo}, {username, ClientInfo},
{mountpoint, ClientInfo},
{proto_name, ConnInfo}, {proto_name, ConnInfo},
{proto_ver, ConnInfo}, {proto_ver, ConnInfo},
{ip_address, {peername, ConnInfo, fun peer_to_binary_addr/1}}, {ip_address, {peername, ConnInfo, fun peer_to_binary_addr/1}},
@ -813,6 +812,11 @@ common_client_props() ->
binary(), binary(),
#{desc => ?DESC(username)} #{desc => ?DESC(username)}
)}, )},
{mountpoint,
mk(
binary(),
#{desc => ?DESC(mountpoint)}
)},
{proto_name, {proto_name,
mk( mk(
binary(), binary(),

View File

@ -492,6 +492,7 @@ fields(client) ->
" Maximum number of subscriptions allowed by this client">> " Maximum number of subscriptions allowed by this client">>
})}, })},
{username, hoconsc:mk(binary(), #{desc => <<"User name of client when connecting">>})}, {username, hoconsc:mk(binary(), #{desc => <<"User name of client when connecting">>})},
{mountpoint, hoconsc:mk(binary(), #{desc => <<"Topic mountpoint">>})},
{will_msg, hoconsc:mk(binary(), #{desc => <<"Client will message">>})}, {will_msg, hoconsc:mk(binary(), #{desc => <<"Client will message">>})},
{zone, {zone,
hoconsc:mk(binary(), #{ hoconsc:mk(binary(), #{
@ -849,7 +850,6 @@ format_channel_info({_, ClientInfo0, ClientStats}) ->
is_superuser, is_superuser,
sockport, sockport,
anonymous, anonymous,
mountpoint,
socktype, socktype,
active_n, active_n,
await_rel_timeout, await_rel_timeout,