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 {
desc {
en: """Client protocol name"""

View File

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

View File

@ -492,6 +492,7 @@ fields(client) ->
" Maximum number of subscriptions allowed by this client">>
})},
{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">>})},
{zone,
hoconsc:mk(binary(), #{
@ -849,7 +850,6 @@ format_channel_info({_, ClientInfo0, ClientStats}) ->
is_superuser,
sockport,
anonymous,
mountpoint,
socktype,
active_n,
await_rel_timeout,