fix(api): desc & remove useless api
This commit is contained in:
parent
010dbbdb26
commit
e517b41a4d
|
@ -117,7 +117,7 @@ param_path_id() ->
|
||||||
[{id, mk(binary(),
|
[{id, mk(binary(),
|
||||||
#{ in => path
|
#{ in => path
|
||||||
, example => <<"mqtt:my_mqtt_connector">>
|
, example => <<"mqtt:my_mqtt_connector">>
|
||||||
, description => <<"The connector Id. Must be of format {type}:{name}">>
|
, desc => <<"The connector Id. Must be of format {type}:{name}">>
|
||||||
})}].
|
})}].
|
||||||
|
|
||||||
schema("/connectors_test") ->
|
schema("/connectors_test") ->
|
||||||
|
@ -125,7 +125,7 @@ schema("/connectors_test") ->
|
||||||
'operationId' => '/connectors_test',
|
'operationId' => '/connectors_test',
|
||||||
post => #{
|
post => #{
|
||||||
tags => [<<"connectors">>],
|
tags => [<<"connectors">>],
|
||||||
description => <<"Test creating a new connector by given Id <br>"
|
desc => <<"Test creating a new connector by given Id <br>"
|
||||||
"The ID must be of format '{type}:{name}'">>,
|
"The ID must be of format '{type}:{name}'">>,
|
||||||
summary => <<"Test creating connector">>,
|
summary => <<"Test creating connector">>,
|
||||||
'requestBody' => post_request_body_schema(),
|
'requestBody' => post_request_body_schema(),
|
||||||
|
@ -141,7 +141,7 @@ schema("/connectors") ->
|
||||||
'operationId' => '/connectors',
|
'operationId' => '/connectors',
|
||||||
get => #{
|
get => #{
|
||||||
tags => [<<"connectors">>],
|
tags => [<<"connectors">>],
|
||||||
description => <<"List all connectors">>,
|
desc => <<"List all connectors">>,
|
||||||
summary => <<"List connectors">>,
|
summary => <<"List connectors">>,
|
||||||
responses => #{
|
responses => #{
|
||||||
200 => emqx_dashboard_swagger:schema_with_example(
|
200 => emqx_dashboard_swagger:schema_with_example(
|
||||||
|
@ -151,7 +151,7 @@ schema("/connectors") ->
|
||||||
},
|
},
|
||||||
post => #{
|
post => #{
|
||||||
tags => [<<"connectors">>],
|
tags => [<<"connectors">>],
|
||||||
description => <<"Create a new connector">>,
|
desc => <<"Create a new connector">>,
|
||||||
summary => <<"Create connector">>,
|
summary => <<"Create connector">>,
|
||||||
'requestBody' => post_request_body_schema(),
|
'requestBody' => post_request_body_schema(),
|
||||||
responses => #{
|
responses => #{
|
||||||
|
@ -166,7 +166,7 @@ schema("/connectors/:id") ->
|
||||||
'operationId' => '/connectors/:id',
|
'operationId' => '/connectors/:id',
|
||||||
get => #{
|
get => #{
|
||||||
tags => [<<"connectors">>],
|
tags => [<<"connectors">>],
|
||||||
description => <<"Get the connector by Id">>,
|
desc => <<"Get the connector by Id">>,
|
||||||
summary => <<"Get connector">>,
|
summary => <<"Get connector">>,
|
||||||
parameters => param_path_id(),
|
parameters => param_path_id(),
|
||||||
responses => #{
|
responses => #{
|
||||||
|
@ -177,7 +177,7 @@ schema("/connectors/:id") ->
|
||||||
},
|
},
|
||||||
put => #{
|
put => #{
|
||||||
tags => [<<"connectors">>],
|
tags => [<<"connectors">>],
|
||||||
description => <<"Update an existing connector by Id">>,
|
desc => <<"Update an existing connector by Id">>,
|
||||||
summary => <<"Update connector">>,
|
summary => <<"Update connector">>,
|
||||||
parameters => param_path_id(),
|
parameters => param_path_id(),
|
||||||
'requestBody' => put_request_body_schema(),
|
'requestBody' => put_request_body_schema(),
|
||||||
|
@ -188,7 +188,7 @@ schema("/connectors/:id") ->
|
||||||
}},
|
}},
|
||||||
delete => #{
|
delete => #{
|
||||||
tags => [<<"connectors">>],
|
tags => [<<"connectors">>],
|
||||||
description => <<"Delete a connector by Id">>,
|
desc => <<"Delete a connector by Id">>,
|
||||||
summary => <<"Delete connector">>,
|
summary => <<"Delete connector">>,
|
||||||
parameters => param_path_id(),
|
parameters => param_path_id(),
|
||||||
responses => #{
|
responses => #{
|
||||||
|
|
|
@ -48,22 +48,22 @@ schema("/login") ->
|
||||||
'operationId' => login,
|
'operationId' => login,
|
||||||
post => #{
|
post => #{
|
||||||
tags => [<<"dashboard">>],
|
tags => [<<"dashboard">>],
|
||||||
description => <<"Dashboard Auth">>,
|
desc => <<"Dashboard Auth">>,
|
||||||
summary => <<"Dashboard Auth">>,
|
summary => <<"Dashboard Auth">>,
|
||||||
'requestBody' => [
|
'requestBody' => [
|
||||||
{username, mk(binary(),
|
{username, mk(binary(),
|
||||||
#{description => <<"The User for which to create the token.">>,
|
#{desc => <<"The User for which to create the token.">>,
|
||||||
'maxLength' => 100, example => <<"admin">>})},
|
'maxLength' => 100, example => <<"admin">>})},
|
||||||
{password, mk(binary(),
|
{password, mk(binary(),
|
||||||
#{description => "password", example => "public"})}
|
#{desc => "password", example => "public"})}
|
||||||
],
|
],
|
||||||
responses => #{
|
responses => #{
|
||||||
200 => [
|
200 => [
|
||||||
{token, mk(string(), #{description => <<"JWT Token">>})},
|
{token, mk(string(), #{desc => <<"JWT Token">>})},
|
||||||
{license, [{edition,
|
{license, [{edition,
|
||||||
mk(enum([community, enterprise]), #{description => <<"license">>,
|
mk(enum([community, enterprise]), #{desc => <<"license">>,
|
||||||
example => "community"})}]},
|
example => "community"})}]},
|
||||||
{version, mk(string(), #{description => <<"version">>, example => <<"5.0.0">>})}
|
{version, mk(string(), #{desc => <<"version">>, example => <<"5.0.0">>})}
|
||||||
],
|
],
|
||||||
401 => [
|
401 => [
|
||||||
{code, mk(string(), #{example => 'ERROR_USERNAME_OR_PWD'})},
|
{code, mk(string(), #{example => 'ERROR_USERNAME_OR_PWD'})},
|
||||||
|
@ -77,10 +77,10 @@ schema("/logout") ->
|
||||||
'operationId' => logout,
|
'operationId' => logout,
|
||||||
post => #{
|
post => #{
|
||||||
tags => [<<"dashboard">>],
|
tags => [<<"dashboard">>],
|
||||||
description => <<"Dashboard User logout">>,
|
desc => <<"Dashboard User logout">>,
|
||||||
'requestBody' => [
|
'requestBody' => [
|
||||||
{username, mk(binary(),
|
{username, mk(binary(),
|
||||||
#{description => <<"The User for which to create the token.">>,
|
#{desc => <<"The User for which to create the token.">>,
|
||||||
'maxLength' => 100, example => <<"admin">>})}
|
'maxLength' => 100, example => <<"admin">>})}
|
||||||
],
|
],
|
||||||
responses => #{
|
responses => #{
|
||||||
|
@ -93,19 +93,19 @@ schema("/users") ->
|
||||||
'operationId' => users,
|
'operationId' => users,
|
||||||
get => #{
|
get => #{
|
||||||
tags => [<<"dashboard">>],
|
tags => [<<"dashboard">>],
|
||||||
description => <<"Get dashboard users list">>,
|
desc => <<"Get dashboard users list">>,
|
||||||
responses => #{
|
responses => #{
|
||||||
200 => mk( array(ref(?MODULE, user))
|
200 => mk( array(ref(?MODULE, user))
|
||||||
, #{description => "User lists"})
|
, #{desc => "User lists"})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
post => #{
|
post => #{
|
||||||
tags => [<<"dashboard">>],
|
tags => [<<"dashboard">>],
|
||||||
description => <<"Create dashboard users">>,
|
desc => <<"Create dashboard users">>,
|
||||||
'requestBody' => fields(user_password),
|
'requestBody' => fields(user_password),
|
||||||
responses => #{
|
responses => #{
|
||||||
200 => mk( ref(?MODULE, user)
|
200 => mk( ref(?MODULE, user)
|
||||||
, #{description => <<"Create User successfully">>}),
|
, #{desc => <<"Create User successfully">>}),
|
||||||
400 => [{code, mk(string(), #{example => 'CREATE_FAIL'})},
|
400 => [{code, mk(string(), #{example => 'CREATE_FAIL'})},
|
||||||
{message, mk(string(), #{example => "Create user failed"})}
|
{message, mk(string(), #{example => "Create user failed"})}
|
||||||
]
|
]
|
||||||
|
@ -118,17 +118,17 @@ schema("/users/:username") ->
|
||||||
'operationId' => user,
|
'operationId' => user,
|
||||||
put => #{
|
put => #{
|
||||||
tags => [<<"dashboard">>],
|
tags => [<<"dashboard">>],
|
||||||
description => <<"Update dashboard users">>,
|
desc => <<"Update dashboard users">>,
|
||||||
parameters => [{username, mk(binary(),
|
parameters => [{username, mk(binary(),
|
||||||
#{in => path, example => <<"admin">>})}],
|
#{in => path, example => <<"admin">>})}],
|
||||||
'requestBody' => [
|
'requestBody' => [
|
||||||
{ description
|
{ description
|
||||||
, mk(binary(),
|
, mk(binary(),
|
||||||
#{description => <<"User description">>, example => <<"administrator">>})}
|
#{desc => <<"User description">>, example => <<"administrator">>})}
|
||||||
],
|
],
|
||||||
responses => #{
|
responses => #{
|
||||||
200 => mk( ref(?MODULE, user)
|
200 => mk( ref(?MODULE, user)
|
||||||
, #{description => <<"Update User successfully">>}),
|
, #{desc => <<"Update User successfully">>}),
|
||||||
400 => [
|
400 => [
|
||||||
{code, mk(string(), #{example => 'UPDATE_FAIL'})},
|
{code, mk(string(), #{example => 'UPDATE_FAIL'})},
|
||||||
{message, mk(string(), #{example => "Update Failed unknown"})}
|
{message, mk(string(), #{example => "Update Failed unknown"})}
|
||||||
|
@ -138,7 +138,7 @@ schema("/users/:username") ->
|
||||||
},
|
},
|
||||||
delete => #{
|
delete => #{
|
||||||
tags => [<<"dashboard">>],
|
tags => [<<"dashboard">>],
|
||||||
description => <<"Delete dashboard users">>,
|
desc => <<"Delete dashboard users">>,
|
||||||
parameters => [{username, mk(binary(),
|
parameters => [{username, mk(binary(),
|
||||||
#{in => path, example => <<"admin">>})}],
|
#{in => path, example => <<"admin">>})}],
|
||||||
responses => #{
|
responses => #{
|
||||||
|
@ -156,7 +156,7 @@ schema("/users/:username/change_pwd") ->
|
||||||
'operationId' => change_pwd,
|
'operationId' => change_pwd,
|
||||||
put => #{
|
put => #{
|
||||||
tags => [<<"dashboard">>],
|
tags => [<<"dashboard">>],
|
||||||
description => <<"Update dashboard users password">>,
|
desc => <<"Update dashboard users password">>,
|
||||||
parameters => [{username, mk(binary(),
|
parameters => [{username, mk(binary(),
|
||||||
#{in => path, required => true, example => <<"admin">>})}],
|
#{in => path, required => true, example => <<"admin">>})}],
|
||||||
'requestBody' => [
|
'requestBody' => [
|
||||||
|
@ -177,14 +177,14 @@ fields(user) ->
|
||||||
[
|
[
|
||||||
{description,
|
{description,
|
||||||
mk(binary(),
|
mk(binary(),
|
||||||
#{description => <<"User description">>, example => "administrator"})},
|
#{desc => <<"User description">>, example => "administrator"})},
|
||||||
{username,
|
{username,
|
||||||
mk(binary(),
|
mk(binary(),
|
||||||
#{description => <<"username">>, example => "emqx"})}
|
#{desc => <<"username">>, example => "emqx"})}
|
||||||
];
|
];
|
||||||
fields(user_password) ->
|
fields(user_password) ->
|
||||||
fields(user) ++
|
fields(user) ++
|
||||||
[{password, mk(binary(), #{description => "Password", example => <<"public">>})}].
|
[{password, mk(binary(), #{desc => "Password", example => <<"public">>})}].
|
||||||
|
|
||||||
login(post, #{body := Params}) ->
|
login(post, #{body := Params}) ->
|
||||||
Username = maps:get(<<"username">>, Params),
|
Username = maps:get(<<"username">>, Params),
|
||||||
|
|
|
@ -35,7 +35,7 @@ schema("/monitor") ->
|
||||||
'operationId' => monitor,
|
'operationId' => monitor,
|
||||||
get => #{
|
get => #{
|
||||||
tags => [dashboard],
|
tags => [dashboard],
|
||||||
description => <<"List monitor data.">>,
|
desc => <<"List monitor data.">>,
|
||||||
parameters => [parameter_latest()],
|
parameters => [parameter_latest()],
|
||||||
responses => #{
|
responses => #{
|
||||||
200 => hoconsc:mk(hoconsc:array(hoconsc:ref(sampler)), #{}),
|
200 => hoconsc:mk(hoconsc:array(hoconsc:ref(sampler)), #{}),
|
||||||
|
@ -49,7 +49,7 @@ schema("/monitor/nodes/:node") ->
|
||||||
'operationId' => monitor,
|
'operationId' => monitor,
|
||||||
get => #{
|
get => #{
|
||||||
tags => [dashboard],
|
tags => [dashboard],
|
||||||
description => <<"List the monitor data on the node.">>,
|
desc => <<"List the monitor data on the node.">>,
|
||||||
parameters => [parameter_node(), parameter_latest()],
|
parameters => [parameter_node(), parameter_latest()],
|
||||||
responses => #{
|
responses => #{
|
||||||
200 => hoconsc:mk(hoconsc:array(hoconsc:ref(sampler)), #{}),
|
200 => hoconsc:mk(hoconsc:array(hoconsc:ref(sampler)), #{}),
|
||||||
|
@ -63,7 +63,7 @@ schema("/monitor_current") ->
|
||||||
'operationId' => monitor_current,
|
'operationId' => monitor_current,
|
||||||
get => #{
|
get => #{
|
||||||
tags => [dashboard],
|
tags => [dashboard],
|
||||||
description => <<"Current status. Gauge and rate.">>,
|
desc => <<"Current status. Gauge and rate.">>,
|
||||||
responses => #{
|
responses => #{
|
||||||
200 => hoconsc:mk(hoconsc:ref(sampler_current), #{})
|
200 => hoconsc:mk(hoconsc:ref(sampler_current), #{})
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ schema("/monitor_current/nodes/:node") ->
|
||||||
'operationId' => monitor_current,
|
'operationId' => monitor_current,
|
||||||
get => #{
|
get => #{
|
||||||
tags => [dashboard],
|
tags => [dashboard],
|
||||||
description => <<"Node current status. Gauge and rate.">>,
|
desc => <<"Node current status. Gauge and rate.">>,
|
||||||
parameters => [parameter_node()],
|
parameters => [parameter_node()],
|
||||||
responses => #{
|
responses => #{
|
||||||
200 => hoconsc:mk(hoconsc:ref(sampler_current), #{}),
|
200 => hoconsc:mk(hoconsc:ref(sampler_current), #{}),
|
||||||
|
@ -89,7 +89,7 @@ parameter_latest() ->
|
||||||
in => query,
|
in => query,
|
||||||
required => false,
|
required => false,
|
||||||
example => 5 * 60,
|
example => 5 * 60,
|
||||||
description => <<"The latest N seconds data. Like 300 for 5 min.">>
|
desc => <<"The latest N seconds data. Like 300 for 5 min.">>
|
||||||
},
|
},
|
||||||
{latest, hoconsc:mk(range(1, inf), Info)}.
|
{latest, hoconsc:mk(range(1, inf), Info)}.
|
||||||
|
|
||||||
|
@ -98,19 +98,19 @@ parameter_node() ->
|
||||||
in => path,
|
in => path,
|
||||||
required => true,
|
required => true,
|
||||||
example => node(),
|
example => node(),
|
||||||
description => <<"EMQX node name.">>
|
desc => <<"EMQX node name.">>
|
||||||
},
|
},
|
||||||
{node, hoconsc:mk(binary(), Info)}.
|
{node, hoconsc:mk(binary(), Info)}.
|
||||||
|
|
||||||
|
|
||||||
fields(sampler) ->
|
fields(sampler) ->
|
||||||
Samplers =
|
Samplers =
|
||||||
[{SamplerName, hoconsc:mk(integer(), #{description => swagger_desc(SamplerName)})}
|
[{SamplerName, hoconsc:mk(integer(), #{desc => swagger_desc(SamplerName)})}
|
||||||
|| SamplerName <- ?SAMPLER_LIST],
|
|| SamplerName <- ?SAMPLER_LIST],
|
||||||
[{time_stamp, hoconsc:mk(integer(), #{description => <<"Timestamp">>})} | Samplers];
|
[{time_stamp, hoconsc:mk(integer(), #{desc => <<"Timestamp">>})} | Samplers];
|
||||||
|
|
||||||
fields(sampler_current) ->
|
fields(sampler_current) ->
|
||||||
[{SamplerName, hoconsc:mk(integer(), #{description => swagger_desc(SamplerName)})}
|
[{SamplerName, hoconsc:mk(integer(), #{desc => swagger_desc(SamplerName)})}
|
||||||
|| SamplerName <- maps:values(?DELTA_SAMPLER_RATE_MAP) ++ ?GAUGE_SAMPLER_LIST].
|
|| SamplerName <- maps:values(?DELTA_SAMPLER_RATE_MAP) ++ ?GAUGE_SAMPLER_LIST].
|
||||||
|
|
||||||
%% -------------------------------------------------------------------------------------------------
|
%% -------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -95,12 +95,12 @@ namespace() -> "public".
|
||||||
-spec(fields(hocon_schema:name()) -> hocon_schema:fields()).
|
-spec(fields(hocon_schema:name()) -> hocon_schema:fields()).
|
||||||
fields(page) ->
|
fields(page) ->
|
||||||
Desc = <<"Page number of the results to fetch.">>,
|
Desc = <<"Page number of the results to fetch.">>,
|
||||||
Meta = #{in => query, description => Desc, default => 1, example => 1},
|
Meta = #{in => query, desc => Desc, default => 1, example => 1},
|
||||||
[{page, hoconsc:mk(integer(), Meta)}];
|
[{page, hoconsc:mk(integer(), Meta)}];
|
||||||
fields(limit) ->
|
fields(limit) ->
|
||||||
Desc = iolist_to_binary([<<"Results per page(max ">>,
|
Desc = iolist_to_binary([<<"Results per page(max ">>,
|
||||||
integer_to_binary(?MAX_ROW_LIMIT), <<")">>]),
|
integer_to_binary(?MAX_ROW_LIMIT), <<")">>]),
|
||||||
Meta = #{in => query, description => Desc, default => ?DEFAULT_ROW, example => 50},
|
Meta = #{in => query, desc => Desc, default => ?DEFAULT_ROW, example => 50},
|
||||||
[{limit, hoconsc:mk(range(1, ?MAX_ROW_LIMIT), Meta)}].
|
[{limit, hoconsc:mk(range(1, ?MAX_ROW_LIMIT), Meta)}].
|
||||||
|
|
||||||
-spec(schema_with_example(hocon_schema:type(), term()) -> hocon_schema:field_schema_map()).
|
-spec(schema_with_example(hocon_schema:type(), term()) -> hocon_schema:field_schema_map()).
|
||||||
|
@ -120,7 +120,7 @@ error_codes(Codes = [_ | _], MsgExample) ->
|
||||||
[
|
[
|
||||||
{code, hoconsc:mk(hoconsc:enum(Codes))},
|
{code, hoconsc:mk(hoconsc:enum(Codes))},
|
||||||
{message, hoconsc:mk(string(), #{
|
{message, hoconsc:mk(string(), #{
|
||||||
description => <<"Details description of the error.">>,
|
desc => <<"Details description of the error.">>,
|
||||||
example => MsgExample
|
example => MsgExample
|
||||||
})}
|
})}
|
||||||
].
|
].
|
||||||
|
@ -247,7 +247,7 @@ meta_to_spec(Meta, Module, Options) ->
|
||||||
{RequestBody, Refs2} = request_body(maps:get('requestBody', Meta, []), Module),
|
{RequestBody, Refs2} = request_body(maps:get('requestBody', Meta, []), Module),
|
||||||
{Responses, Refs3} = responses(maps:get(responses, Meta, #{}), Module, Options),
|
{Responses, Refs3} = responses(maps:get(responses, Meta, #{}), Module, Options),
|
||||||
{
|
{
|
||||||
to_spec(Meta, Params, RequestBody, Responses),
|
generate_method_desc(to_spec(Meta, Params, RequestBody, Responses)),
|
||||||
lists:usort(Refs1 ++ Refs2 ++ Refs3)
|
lists:usort(Refs1 ++ Refs2 ++ Refs3)
|
||||||
}.
|
}.
|
||||||
|
|
||||||
|
@ -258,6 +258,14 @@ to_spec(Meta, Params, RequestBody, Responses) ->
|
||||||
Spec = to_spec(Meta, Params, [], Responses),
|
Spec = to_spec(Meta, Params, [], Responses),
|
||||||
maps:put('requestBody', RequestBody, Spec).
|
maps:put('requestBody', RequestBody, Spec).
|
||||||
|
|
||||||
|
generate_method_desc(Spec0 = #{desc := Desc}) ->
|
||||||
|
Spec = maps:remove(desc, Spec0),
|
||||||
|
Spec#{description => to_bin(Desc)};
|
||||||
|
generate_method_desc(Spec = #{description := Desc}) ->
|
||||||
|
Spec#{description => to_bin(Desc)};
|
||||||
|
generate_method_desc(Spec) ->
|
||||||
|
Spec.
|
||||||
|
|
||||||
parameters(Params, Module) ->
|
parameters(Params, Module) ->
|
||||||
{SpecList, AllRefs} =
|
{SpecList, AllRefs} =
|
||||||
lists:foldl(fun(Param, {Acc, RefsAcc}) ->
|
lists:foldl(fun(Param, {Acc, RefsAcc}) ->
|
||||||
|
|
|
@ -273,7 +273,7 @@ schema("/test/in/:filter") ->
|
||||||
{filter,
|
{filter,
|
||||||
mk(hoconsc:enum([assigned, created, mentioned, all]),
|
mk(hoconsc:enum([assigned, created, mentioned, all]),
|
||||||
#{in => path,
|
#{in => path,
|
||||||
description => <<"Indicates which sorts of issues to return">>,
|
desc => <<"Indicates which sorts of issues to return">>,
|
||||||
example => "all"
|
example => "all"
|
||||||
})}
|
})}
|
||||||
],
|
],
|
||||||
|
@ -288,9 +288,9 @@ schema("/test/in/query") ->
|
||||||
{per_page,
|
{per_page,
|
||||||
mk(range(1, 100),
|
mk(range(1, 100),
|
||||||
#{in => query,
|
#{in => query,
|
||||||
description => <<"results per page (max 100)">>,
|
desc => <<"results per page (max 100)">>,
|
||||||
example => 1})},
|
example => 1})},
|
||||||
{qos, mk(emqx_schema:qos(), #{in => query, description => <<"QOS">>})}
|
{qos, mk(emqx_schema:qos(), #{in => query, desc => <<"QOS">>})}
|
||||||
],
|
],
|
||||||
responses => #{200 => <<"ok">>}
|
responses => #{200 => <<"ok">>}
|
||||||
}
|
}
|
||||||
|
@ -327,17 +327,17 @@ schema("/test/in/mix/:state") ->
|
||||||
operationId => test,
|
operationId => test,
|
||||||
post => #{
|
post => #{
|
||||||
tags => [tags, good],
|
tags => [tags, good],
|
||||||
description => <<"good description">>,
|
desc => <<"good description">>,
|
||||||
summary => <<"good summary">>,
|
summary => <<"good summary">>,
|
||||||
security => [],
|
security => [],
|
||||||
deprecated => true,
|
deprecated => true,
|
||||||
parameters => [
|
parameters => [
|
||||||
{filter, hoconsc:mk(hoconsc:enum([assigned, created, mentioned, all]),
|
{filter, hoconsc:mk(hoconsc:enum([assigned, created, mentioned, all]),
|
||||||
#{in => query, description => <<"Indicates which sorts of issues to return">>,
|
#{in => query, desc => <<"Indicates which sorts of issues to return">>,
|
||||||
example => "all"})},
|
example => "all"})},
|
||||||
{state, mk(emqx_schema:duration_s(),
|
{state, mk(emqx_schema:duration_s(),
|
||||||
#{in => path, required => true, example => "12m",
|
#{in => path, required => true, example => "12m",
|
||||||
description => <<"Indicates the state of the issues to return.">>})},
|
desc => <<"Indicates the state of the issues to return.">>})},
|
||||||
{per_page, mk(range(1, 50),
|
{per_page, mk(range(1, 50),
|
||||||
#{in => query, required => false, example => 10, default => 5})},
|
#{in => query, required => false, example => 10, default => 5})},
|
||||||
{is_admin, mk(boolean(), #{in => query})},
|
{is_admin, mk(boolean(), #{in => query})},
|
||||||
|
@ -373,7 +373,7 @@ fields(page) ->
|
||||||
[
|
[
|
||||||
{per_page,
|
{per_page,
|
||||||
mk(range(1, 100),
|
mk(range(1, 100),
|
||||||
#{in => query, description => <<"results per page (max 100)">>, example => 1})}
|
#{in => query, desc => <<"results per page (max 100)">>, example => 1})}
|
||||||
].
|
].
|
||||||
to_schema(Params) ->
|
to_schema(Params) ->
|
||||||
#{
|
#{
|
||||||
|
|
|
@ -52,11 +52,11 @@ schema(("/exhooks")) ->
|
||||||
#{
|
#{
|
||||||
'operationId' => exhooks,
|
'operationId' => exhooks,
|
||||||
get => #{tags => ?TAGS,
|
get => #{tags => ?TAGS,
|
||||||
description => <<"List all servers">>,
|
desc => <<"List all servers">>,
|
||||||
responses => #{200 => mk(array(ref(detail_server_info)), #{})}
|
responses => #{200 => mk(array(ref(detail_server_info)), #{})}
|
||||||
},
|
},
|
||||||
post => #{tags => ?TAGS,
|
post => #{tags => ?TAGS,
|
||||||
description => <<"Add a servers">>,
|
desc => <<"Add a servers">>,
|
||||||
'requestBody' => server_conf_schema(),
|
'requestBody' => server_conf_schema(),
|
||||||
responses => #{201 => mk(ref(detail_server_info), #{}),
|
responses => #{201 => mk(ref(detail_server_info), #{}),
|
||||||
500 => error_codes([?BAD_RPC], <<"Bad RPC">>)
|
500 => error_codes([?BAD_RPC], <<"Bad RPC">>)
|
||||||
|
@ -67,14 +67,14 @@ schema(("/exhooks")) ->
|
||||||
schema("/exhooks/:name") ->
|
schema("/exhooks/:name") ->
|
||||||
#{'operationId' => action_with_name,
|
#{'operationId' => action_with_name,
|
||||||
get => #{tags => ?TAGS,
|
get => #{tags => ?TAGS,
|
||||||
description => <<"Get the detail information of server">>,
|
desc => <<"Get the detail information of server">>,
|
||||||
parameters => params_server_name_in_path(),
|
parameters => params_server_name_in_path(),
|
||||||
responses => #{200 => mk(ref(detail_server_info), #{}),
|
responses => #{200 => mk(ref(detail_server_info), #{}),
|
||||||
400 => error_codes([?BAD_REQUEST], <<"Bad Request">>)
|
400 => error_codes([?BAD_REQUEST], <<"Bad Request">>)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
put => #{tags => ?TAGS,
|
put => #{tags => ?TAGS,
|
||||||
description => <<"Update the server">>,
|
desc => <<"Update the server">>,
|
||||||
parameters => params_server_name_in_path(),
|
parameters => params_server_name_in_path(),
|
||||||
'requestBody' => server_conf_schema(),
|
'requestBody' => server_conf_schema(),
|
||||||
responses => #{200 => <<>>,
|
responses => #{200 => <<>>,
|
||||||
|
@ -83,7 +83,7 @@ schema("/exhooks/:name") ->
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
delete => #{tags => ?TAGS,
|
delete => #{tags => ?TAGS,
|
||||||
description => <<"Delete the server">>,
|
desc => <<"Delete the server">>,
|
||||||
parameters => params_server_name_in_path(),
|
parameters => params_server_name_in_path(),
|
||||||
responses => #{204 => <<>>,
|
responses => #{204 => <<>>,
|
||||||
500 => error_codes([?BAD_RPC], <<"Bad RPC">>)
|
500 => error_codes([?BAD_RPC], <<"Bad RPC">>)
|
||||||
|
@ -94,7 +94,7 @@ schema("/exhooks/:name") ->
|
||||||
schema("/exhooks/:name/hooks") ->
|
schema("/exhooks/:name/hooks") ->
|
||||||
#{'operationId' => server_hooks,
|
#{'operationId' => server_hooks,
|
||||||
get => #{tags => ?TAGS,
|
get => #{tags => ?TAGS,
|
||||||
description => <<"Get the hooks information of server">>,
|
desc => <<"Get the hooks information of server">>,
|
||||||
parameters => params_server_name_in_path(),
|
parameters => params_server_name_in_path(),
|
||||||
responses => #{200 => mk(array(ref(list_hook_info)), #{}),
|
responses => #{200 => mk(array(ref(list_hook_info)), #{}),
|
||||||
400 => error_codes([?BAD_REQUEST], <<"Bad Request">>)
|
400 => error_codes([?BAD_REQUEST], <<"Bad Request">>)
|
||||||
|
@ -105,7 +105,7 @@ schema("/exhooks/:name/hooks") ->
|
||||||
schema("/exhooks/:name/move") ->
|
schema("/exhooks/:name/move") ->
|
||||||
#{'operationId' => move,
|
#{'operationId' => move,
|
||||||
post => #{tags => ?TAGS,
|
post => #{tags => ?TAGS,
|
||||||
description =>
|
desc =>
|
||||||
<<"Move the server.\n",
|
<<"Move the server.\n",
|
||||||
"NOTE: The position should be \"front|rear|before:{name}|after:{name}\"\n">>,
|
"NOTE: The position should be \"front|rear|before:{name}|after:{name}\"\n">>,
|
||||||
parameters => params_server_name_in_path(),
|
parameters => params_server_name_in_path(),
|
||||||
|
@ -120,7 +120,7 @@ schema("/exhooks/:name/move") ->
|
||||||
}.
|
}.
|
||||||
|
|
||||||
fields(move_req) ->
|
fields(move_req) ->
|
||||||
[{position, mk(string(), #{ description => <<"The target position to be moved.">>
|
[{position, mk(string(), #{ desc => <<"The target position to be moved.">>
|
||||||
, example => <<"front">>})}];
|
, example => <<"front">>})}];
|
||||||
|
|
||||||
fields(detail_server_info) ->
|
fields(detail_server_info) ->
|
||||||
|
@ -131,9 +131,9 @@ fields(detail_server_info) ->
|
||||||
] ++ emqx_exhook_schema:server_config();
|
] ++ emqx_exhook_schema:server_config();
|
||||||
|
|
||||||
fields(list_hook_info) ->
|
fields(list_hook_info) ->
|
||||||
[ {name, mk(binary(), #{description => <<"The hook's name">>})}
|
[ {name, mk(binary(), #{desc => <<"The hook's name">>})}
|
||||||
, {params, mk(map(name, binary()),
|
, {params, mk(map(name, binary()),
|
||||||
#{description => <<"The parameters used when the hook is registered">>})}
|
#{desc => <<"The parameters used when the hook is registered">>})}
|
||||||
, {metrics, mk(ref(metrics), #{})}
|
, {metrics, mk(ref(metrics), #{})}
|
||||||
, {node_metrics, mk(array(ref(node_metrics)), #{})}
|
, {node_metrics, mk(array(ref(node_metrics)), #{})}
|
||||||
];
|
];
|
||||||
|
@ -149,9 +149,9 @@ fields(node_status) ->
|
||||||
];
|
];
|
||||||
|
|
||||||
fields(hook_info) ->
|
fields(hook_info) ->
|
||||||
[ {name, mk(binary(), #{description => <<"The hook's name">>})}
|
[ {name, mk(binary(), #{desc => <<"The hook's name">>})}
|
||||||
, {params, mk(map(name, binary()),
|
, {params, mk(map(name, binary()),
|
||||||
#{description => <<"The parameters used when the hook is registered">>})}
|
#{desc => <<"The parameters used when the hook is registered">>})}
|
||||||
];
|
];
|
||||||
|
|
||||||
fields(metrics) ->
|
fields(metrics) ->
|
||||||
|
|
|
@ -46,7 +46,7 @@ paths() ->
|
||||||
schema(?PREFIX ++ "/request") ->
|
schema(?PREFIX ++ "/request") ->
|
||||||
#{operationId => request,
|
#{operationId => request,
|
||||||
post => #{ tags => [<<"gateway|coap">>]
|
post => #{ tags => [<<"gateway|coap">>]
|
||||||
, description => <<"Send a CoAP request message to the client">>
|
, desc => <<"Send a CoAP request message to the client">>
|
||||||
, parameters => request_parameters()
|
, parameters => request_parameters()
|
||||||
, requestBody => request_body()
|
, requestBody => request_body()
|
||||||
, responses => #{200 => coap_message(),
|
, responses => #{200 => coap_message(),
|
||||||
|
@ -87,19 +87,19 @@ request_parameters() ->
|
||||||
[{clientid, mk(binary(), #{in => path, required => true})}].
|
[{clientid, mk(binary(), #{in => path, required => true})}].
|
||||||
|
|
||||||
request_body() ->
|
request_body() ->
|
||||||
[ {token, mk(binary(), #{description => "message token, can be empty"})}
|
[ {token, mk(binary(), #{desc => "message token, can be empty"})}
|
||||||
, {method, mk(enum([get, put, post, delete]), #{description => "request method type"})}
|
, {method, mk(enum([get, put, post, delete]), #{desc => "request method type"})}
|
||||||
, {timeout, mk(emqx_schema:duration_ms(), #{description => "timespan for response"})}
|
, {timeout, mk(emqx_schema:duration_ms(), #{desc => "timespan for response"})}
|
||||||
, {content_type, mk(enum(['text/plain', 'application/json', 'application/octet-stream']),
|
, {content_type, mk(enum(['text/plain', 'application/json', 'application/octet-stream']),
|
||||||
#{description => "payload type"})}
|
#{desc => "payload type"})}
|
||||||
, {payload, mk(binary(), #{description => "the content of the payload"})}
|
, {payload, mk(binary(), #{desc => "the content of the payload"})}
|
||||||
].
|
].
|
||||||
|
|
||||||
coap_message() ->
|
coap_message() ->
|
||||||
[ {id, mk(integer(), #{description => "message id"})}
|
[ {id, mk(integer(), #{desc => "message id"})}
|
||||||
, {token, mk(string(), #{description => "message token, can be empty"})}
|
, {token, mk(string(), #{desc => "message token, can be empty"})}
|
||||||
, {method, mk(string(), #{description => "response code"})}
|
, {method, mk(string(), #{desc => "response code"})}
|
||||||
, {payload, mk(string(), #{description => "payload"})}
|
, {payload, mk(string(), #{desc => "payload"})}
|
||||||
].
|
].
|
||||||
|
|
||||||
format_to_response(ContentType, #coap_message{id = Id,
|
format_to_response(ContentType, #coap_message{id = Id,
|
||||||
|
|
|
@ -44,7 +44,6 @@
|
||||||
%% http handlers
|
%% http handlers
|
||||||
-export([ gateway/2
|
-export([ gateway/2
|
||||||
, gateway_insta/2
|
, gateway_insta/2
|
||||||
, gateway_insta_stats/2
|
|
||||||
]).
|
]).
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
@ -57,7 +56,6 @@ api_spec() ->
|
||||||
paths() ->
|
paths() ->
|
||||||
[ "/gateway"
|
[ "/gateway"
|
||||||
, "/gateway/:name"
|
, "/gateway/:name"
|
||||||
, "/gateway/:name/stats"
|
|
||||||
].
|
].
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
@ -140,9 +138,6 @@ gateway_insta(put, #{body := GwConf0,
|
||||||
end
|
end
|
||||||
end).
|
end).
|
||||||
|
|
||||||
gateway_insta_stats(get, _Req) ->
|
|
||||||
return_http_error(409, "Implement it later (maybe 5.1)").
|
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Swagger defines
|
%% Swagger defines
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
@ -150,7 +145,7 @@ gateway_insta_stats(get, _Req) ->
|
||||||
schema("/gateway") ->
|
schema("/gateway") ->
|
||||||
#{ 'operationId' => gateway,
|
#{ 'operationId' => gateway,
|
||||||
get =>
|
get =>
|
||||||
#{ description => <<"Get gateway list">>
|
#{ desc => <<"Get gateway list">>
|
||||||
, parameters => params_gateway_status_in_qs()
|
, parameters => params_gateway_status_in_qs()
|
||||||
, responses =>
|
, responses =>
|
||||||
?STANDARD_RESP(
|
?STANDARD_RESP(
|
||||||
|
@ -159,7 +154,7 @@ schema("/gateway") ->
|
||||||
examples_gateway_overview())})
|
examples_gateway_overview())})
|
||||||
},
|
},
|
||||||
post =>
|
post =>
|
||||||
#{ description => <<"Load a gateway">>
|
#{ desc => <<"Load a gateway">>
|
||||||
%% TODO: distinguish create & response swagger schema
|
%% TODO: distinguish create & response swagger schema
|
||||||
, 'requestBody' => schema_gateways_conf()
|
, 'requestBody' => schema_gateways_conf()
|
||||||
, responses =>
|
, responses =>
|
||||||
|
@ -169,39 +164,24 @@ schema("/gateway") ->
|
||||||
schema("/gateway/:name") ->
|
schema("/gateway/:name") ->
|
||||||
#{ 'operationId' => gateway_insta,
|
#{ 'operationId' => gateway_insta,
|
||||||
get =>
|
get =>
|
||||||
#{ description => <<"Get the gateway configurations">>
|
#{ desc => <<"Get the gateway configurations">>
|
||||||
, parameters => params_gateway_name_in_path()
|
, parameters => params_gateway_name_in_path()
|
||||||
, responses =>
|
, responses =>
|
||||||
?STANDARD_RESP(#{200 => schema_gateways_conf()})
|
?STANDARD_RESP(#{200 => schema_gateways_conf()})
|
||||||
},
|
},
|
||||||
delete =>
|
delete =>
|
||||||
#{ description => <<"Delete/Unload the gateway">>
|
#{ desc => <<"Delete/Unload the gateway">>
|
||||||
, parameters => params_gateway_name_in_path()
|
, parameters => params_gateway_name_in_path()
|
||||||
, responses =>
|
, responses =>
|
||||||
?STANDARD_RESP(#{204 => <<"Deleted">>})
|
?STANDARD_RESP(#{204 => <<"Deleted">>})
|
||||||
},
|
},
|
||||||
put =>
|
put =>
|
||||||
#{ description => <<"Update the gateway configurations/status">>
|
#{ desc => <<"Update the gateway configurations/status">>
|
||||||
, parameters => params_gateway_name_in_path()
|
, parameters => params_gateway_name_in_path()
|
||||||
, 'requestBody' => schema_update_gateways_conf()
|
, 'requestBody' => schema_update_gateways_conf()
|
||||||
, responses =>
|
, responses =>
|
||||||
?STANDARD_RESP(#{200 => schema_gateways_conf()})
|
?STANDARD_RESP(#{200 => schema_gateways_conf()})
|
||||||
}
|
}
|
||||||
};
|
|
||||||
schema("/gateway/:name/stats") ->
|
|
||||||
#{ 'operationId' => gateway_insta_stats,
|
|
||||||
get =>
|
|
||||||
#{ description => <<"Get gateway Statistic">>
|
|
||||||
, parameters => params_gateway_name_in_path()
|
|
||||||
, responses =>
|
|
||||||
?STANDARD_RESP(
|
|
||||||
#{200 => emqx_dashboard_swagger:schema_with_examples(
|
|
||||||
ref(gateway_stats),
|
|
||||||
examples_gateway_stats()),
|
|
||||||
409 => emqx_dashboard_swagger:error_codes(
|
|
||||||
['NOT_SUPPORT'], <<"Resource not support">>)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}.
|
}.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
@ -211,7 +191,7 @@ params_gateway_name_in_path() ->
|
||||||
[{name,
|
[{name,
|
||||||
mk(binary(),
|
mk(binary(),
|
||||||
#{ in => path
|
#{ in => path
|
||||||
, description => <<"Gateway Name">>
|
, desc => <<"Gateway Name">>
|
||||||
, example => <<"">>
|
, example => <<"">>
|
||||||
})}
|
})}
|
||||||
].
|
].
|
||||||
|
@ -222,7 +202,7 @@ params_gateway_status_in_qs() ->
|
||||||
mk(binary(),
|
mk(binary(),
|
||||||
#{ in => query
|
#{ in => query
|
||||||
, required => false
|
, required => false
|
||||||
, description => <<"Gateway Status">>
|
, desc => <<"Gateway Status">>
|
||||||
, example => <<"">>
|
, example => <<"">>
|
||||||
})}
|
})}
|
||||||
].
|
].
|
||||||
|
@ -238,50 +218,50 @@ roots() ->
|
||||||
fields(gateway_overview) ->
|
fields(gateway_overview) ->
|
||||||
[ {name,
|
[ {name,
|
||||||
mk(binary(),
|
mk(binary(),
|
||||||
#{ description => <<"Gateway Name">>})}
|
#{ desc => <<"Gateway Name">>})}
|
||||||
, {status,
|
, {status,
|
||||||
mk(hoconsc:enum([running, stopped, unloaded]),
|
mk(hoconsc:enum([running, stopped, unloaded]),
|
||||||
#{ description => <<"The Gateway status">>})}
|
#{ desc => <<"The Gateway status">>})}
|
||||||
, {created_at,
|
, {created_at,
|
||||||
mk(binary(),
|
mk(binary(),
|
||||||
#{description => <<"The Gateway created datetime">>})}
|
#{desc => <<"The Gateway created datetime">>})}
|
||||||
, {started_at,
|
, {started_at,
|
||||||
mk(binary(),
|
mk(binary(),
|
||||||
#{ required => false
|
#{ required => false
|
||||||
, description => <<"The Gateway started datetime">>})}
|
, desc => <<"The Gateway started datetime">>})}
|
||||||
, {stopped_at,
|
, {stopped_at,
|
||||||
mk(binary(),
|
mk(binary(),
|
||||||
#{ required => false
|
#{ required => false
|
||||||
, description => <<"The Gateway stopped datetime">>})}
|
, desc => <<"The Gateway stopped datetime">>})}
|
||||||
, {max_connections,
|
, {max_connections,
|
||||||
mk(integer(),
|
mk(integer(),
|
||||||
#{ description => <<"The Gateway allowed maximum connections/clients">>})}
|
#{ desc => <<"The Gateway allowed maximum connections/clients">>})}
|
||||||
, {current_connections,
|
, {current_connections,
|
||||||
mk(integer(),
|
mk(integer(),
|
||||||
#{ description => <<"The Gateway current connected connections/clients">>
|
#{ desc => <<"The Gateway current connected connections/clients">>
|
||||||
})}
|
})}
|
||||||
, {listeners,
|
, {listeners,
|
||||||
mk(hoconsc:array(ref(gateway_listener_overview)),
|
mk(hoconsc:array(ref(gateway_listener_overview)),
|
||||||
#{ required => {false, recursively}
|
#{ required => {false, recursively}
|
||||||
, description => <<"The Gateway listeners overview">>})}
|
, desc => <<"The Gateway listeners overview">>})}
|
||||||
];
|
];
|
||||||
fields(gateway_listener_overview) ->
|
fields(gateway_listener_overview) ->
|
||||||
[ {id,
|
[ {id,
|
||||||
mk(binary(),
|
mk(binary(),
|
||||||
#{ description => <<"Listener ID">>})}
|
#{ desc => <<"Listener ID">>})}
|
||||||
, {running,
|
, {running,
|
||||||
mk(boolean(),
|
mk(boolean(),
|
||||||
#{ description => <<"Listener Running status">>})}
|
#{ desc => <<"Listener Running status">>})}
|
||||||
, {type,
|
, {type,
|
||||||
mk(hoconsc:enum([tcp, ssl, udp, dtls]),
|
mk(hoconsc:enum([tcp, ssl, udp, dtls]),
|
||||||
#{ description => <<"Listener Type">>})}
|
#{ desc => <<"Listener Type">>})}
|
||||||
];
|
];
|
||||||
|
|
||||||
fields(Gw) when Gw == stomp; Gw == mqttsn;
|
fields(Gw) when Gw == stomp; Gw == mqttsn;
|
||||||
Gw == coap; Gw == lwm2m;
|
Gw == coap; Gw == lwm2m;
|
||||||
Gw == exproto ->
|
Gw == exproto ->
|
||||||
[{name,
|
[{name,
|
||||||
mk(hoconsc:union([Gw]), #{ description => <<"Gateway Name">>})}
|
mk(hoconsc:union([Gw]), #{ desc => <<"Gateway Name">>})}
|
||||||
] ++ convert_listener_struct(emqx_gateway_schema:fields(Gw));
|
] ++ convert_listener_struct(emqx_gateway_schema:fields(Gw));
|
||||||
|
|
||||||
fields(Gw) when Gw == update_stomp; Gw == update_mqttsn;
|
fields(Gw) when Gw == update_stomp; Gw == update_mqttsn;
|
||||||
|
@ -298,17 +278,17 @@ fields(Listener) when Listener == tcp_listener;
|
||||||
[ {id,
|
[ {id,
|
||||||
mk(binary(),
|
mk(binary(),
|
||||||
#{ required => false
|
#{ required => false
|
||||||
, description => <<"Listener ID">>})}
|
, desc => <<"Listener ID">>})}
|
||||||
, {type,
|
, {type,
|
||||||
mk(hoconsc:union([tcp, ssl, udp, dtls]),
|
mk(hoconsc:union([tcp, ssl, udp, dtls]),
|
||||||
#{ description => <<"Listener type">>})}
|
#{ desc => <<"Listener type">>})}
|
||||||
, {name,
|
, {name,
|
||||||
mk(binary(),
|
mk(binary(),
|
||||||
#{ description => <<"Listener Name">>})}
|
#{ desc => <<"Listener Name">>})}
|
||||||
, {running,
|
, {running,
|
||||||
mk(boolean(),
|
mk(boolean(),
|
||||||
#{ required => false
|
#{ required => false
|
||||||
, description => <<"Listener running status">>})}
|
, desc => <<"Listener running status">>})}
|
||||||
] ++ emqx_gateway_schema:fields(Listener);
|
] ++ emqx_gateway_schema:fields(Listener);
|
||||||
|
|
||||||
fields(gateway_stats) ->
|
fields(gateway_stats) ->
|
||||||
|
@ -337,7 +317,7 @@ convert_listener_struct(Schema) ->
|
||||||
#{type := Type}}, Schema1} = lists:keytake(listeners, 1, Schema),
|
#{type := Type}}, Schema1} = lists:keytake(listeners, 1, Schema),
|
||||||
ListenerSchema = hoconsc:mk(listeners_schema(Type),
|
ListenerSchema = hoconsc:mk(listeners_schema(Type),
|
||||||
#{ required => {false, recursively}
|
#{ required => {false, recursively}
|
||||||
, description => <<"The gateway listeners">>
|
, desc => <<"The gateway listeners">>
|
||||||
}),
|
}),
|
||||||
lists:keystore(listeners, 1, Schema1, {listeners, ListenerSchema}).
|
lists:keystore(listeners, 1, Schema1, {listeners, ListenerSchema}).
|
||||||
|
|
||||||
|
@ -625,6 +605,3 @@ examples_update_gateway_confs() ->
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.
|
}.
|
||||||
|
|
||||||
examples_gateway_stats() ->
|
|
||||||
#{}.
|
|
||||||
|
|
|
@ -159,7 +159,7 @@ parse_qstring(Qs) ->
|
||||||
schema("/gateway/:name/authentication") ->
|
schema("/gateway/:name/authentication") ->
|
||||||
#{ 'operationId' => authn,
|
#{ 'operationId' => authn,
|
||||||
get =>
|
get =>
|
||||||
#{ description => <<"Get the gateway authentication">>
|
#{ desc => <<"Get the gateway authentication">>
|
||||||
, parameters => params_gateway_name_in_path()
|
, parameters => params_gateway_name_in_path()
|
||||||
, responses =>
|
, responses =>
|
||||||
?STANDARD_RESP(
|
?STANDARD_RESP(
|
||||||
|
@ -168,21 +168,21 @@ schema("/gateway/:name/authentication") ->
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
put =>
|
put =>
|
||||||
#{ description => <<"Update authentication for the gateway">>
|
#{ desc => <<"Update authentication for the gateway">>
|
||||||
, parameters => params_gateway_name_in_path()
|
, parameters => params_gateway_name_in_path()
|
||||||
, 'requestBody' => schema_authn()
|
, 'requestBody' => schema_authn()
|
||||||
, responses =>
|
, responses =>
|
||||||
?STANDARD_RESP(#{200 => schema_authn()})
|
?STANDARD_RESP(#{200 => schema_authn()})
|
||||||
},
|
},
|
||||||
post =>
|
post =>
|
||||||
#{ description => <<"Add authentication for the gateway">>
|
#{ desc => <<"Add authentication for the gateway">>
|
||||||
, parameters => params_gateway_name_in_path()
|
, parameters => params_gateway_name_in_path()
|
||||||
, 'requestBody' => schema_authn()
|
, 'requestBody' => schema_authn()
|
||||||
, responses =>
|
, responses =>
|
||||||
?STANDARD_RESP(#{201 => schema_authn()})
|
?STANDARD_RESP(#{201 => schema_authn()})
|
||||||
},
|
},
|
||||||
delete =>
|
delete =>
|
||||||
#{ description => <<"Remove the gateway authentication">>
|
#{ desc => <<"Remove the gateway authentication">>
|
||||||
, parameters => params_gateway_name_in_path()
|
, parameters => params_gateway_name_in_path()
|
||||||
, responses =>
|
, responses =>
|
||||||
?STANDARD_RESP(#{204 => <<"Deleted">>})
|
?STANDARD_RESP(#{204 => <<"Deleted">>})
|
||||||
|
@ -191,7 +191,7 @@ schema("/gateway/:name/authentication") ->
|
||||||
schema("/gateway/:name/authentication/users") ->
|
schema("/gateway/:name/authentication/users") ->
|
||||||
#{ 'operationId' => users
|
#{ 'operationId' => users
|
||||||
, get =>
|
, get =>
|
||||||
#{ description => <<"Get the users for the authentication">>
|
#{ desc => <<"Get the users for the authentication">>
|
||||||
, parameters => params_gateway_name_in_path() ++
|
, parameters => params_gateway_name_in_path() ++
|
||||||
params_paging_in_qs() ++
|
params_paging_in_qs() ++
|
||||||
params_fuzzy_in_qs()
|
params_fuzzy_in_qs()
|
||||||
|
@ -203,7 +203,7 @@ schema("/gateway/:name/authentication/users") ->
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
post =>
|
post =>
|
||||||
#{ description => <<"Add user for the authentication">>
|
#{ desc => <<"Add user for the authentication">>
|
||||||
, parameters => params_gateway_name_in_path()
|
, parameters => params_gateway_name_in_path()
|
||||||
, 'requestBody' => emqx_dashboard_swagger:schema_with_examples(
|
, 'requestBody' => emqx_dashboard_swagger:schema_with_examples(
|
||||||
ref(emqx_authn_api, request_user_create),
|
ref(emqx_authn_api, request_user_create),
|
||||||
|
@ -219,7 +219,7 @@ schema("/gateway/:name/authentication/users") ->
|
||||||
schema("/gateway/:name/authentication/users/:uid") ->
|
schema("/gateway/:name/authentication/users/:uid") ->
|
||||||
#{ 'operationId' => users_insta
|
#{ 'operationId' => users_insta
|
||||||
, get =>
|
, get =>
|
||||||
#{ description => <<"Get user info from the gateway "
|
#{ desc => <<"Get user info from the gateway "
|
||||||
"authentication">>
|
"authentication">>
|
||||||
, parameters => params_gateway_name_in_path() ++
|
, parameters => params_gateway_name_in_path() ++
|
||||||
params_userid_in_path()
|
params_userid_in_path()
|
||||||
|
@ -231,7 +231,7 @@ schema("/gateway/:name/authentication/users/:uid") ->
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
put =>
|
put =>
|
||||||
#{ description => <<"Update the user info for the gateway "
|
#{ desc => <<"Update the user info for the gateway "
|
||||||
"authentication">>
|
"authentication">>
|
||||||
, parameters => params_gateway_name_in_path() ++
|
, parameters => params_gateway_name_in_path() ++
|
||||||
params_userid_in_path()
|
params_userid_in_path()
|
||||||
|
@ -246,7 +246,7 @@ schema("/gateway/:name/authentication/users/:uid") ->
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
delete =>
|
delete =>
|
||||||
#{ description => <<"Delete the user for the gateway "
|
#{ desc => <<"Delete the user for the gateway "
|
||||||
"authentication">>
|
"authentication">>
|
||||||
, parameters => params_gateway_name_in_path() ++
|
, parameters => params_gateway_name_in_path() ++
|
||||||
params_userid_in_path()
|
params_userid_in_path()
|
||||||
|
@ -257,7 +257,7 @@ schema("/gateway/:name/authentication/users/:uid") ->
|
||||||
schema("/gateway/:name/authentication/import_users") ->
|
schema("/gateway/:name/authentication/import_users") ->
|
||||||
#{ 'operationId' => import_users
|
#{ 'operationId' => import_users
|
||||||
, post =>
|
, post =>
|
||||||
#{ description => <<"Import users into the gateway authentication">>
|
#{ desc => <<"Import users into the gateway authentication">>
|
||||||
, parameters => params_gateway_name_in_path()
|
, parameters => params_gateway_name_in_path()
|
||||||
, 'requestBody' => emqx_dashboard_swagger:schema_with_examples(
|
, 'requestBody' => emqx_dashboard_swagger:schema_with_examples(
|
||||||
ref(emqx_authn_api, request_import_users),
|
ref(emqx_authn_api, request_import_users),
|
||||||
|
@ -275,7 +275,7 @@ params_gateway_name_in_path() ->
|
||||||
[{name,
|
[{name,
|
||||||
mk(binary(),
|
mk(binary(),
|
||||||
#{ in => path
|
#{ in => path
|
||||||
, description => <<"Gateway Name">>
|
, desc => <<"Gateway Name">>
|
||||||
, example => <<"">>
|
, example => <<"">>
|
||||||
})}
|
})}
|
||||||
].
|
].
|
||||||
|
@ -283,7 +283,7 @@ params_gateway_name_in_path() ->
|
||||||
params_userid_in_path() ->
|
params_userid_in_path() ->
|
||||||
[{uid, mk(binary(),
|
[{uid, mk(binary(),
|
||||||
#{ in => path
|
#{ in => path
|
||||||
, description => <<"User ID">>
|
, desc => <<"User ID">>
|
||||||
, example => <<"">>
|
, example => <<"">>
|
||||||
})}
|
})}
|
||||||
].
|
].
|
||||||
|
@ -292,13 +292,13 @@ params_paging_in_qs() ->
|
||||||
[{page, mk(integer(),
|
[{page, mk(integer(),
|
||||||
#{ in => query
|
#{ in => query
|
||||||
, required => false
|
, required => false
|
||||||
, description => <<"Page Index">>
|
, desc => <<"Page Index">>
|
||||||
, example => 1
|
, example => 1
|
||||||
})},
|
})},
|
||||||
{limit, mk(integer(),
|
{limit, mk(integer(),
|
||||||
#{ in => query
|
#{ in => query
|
||||||
, required => false
|
, required => false
|
||||||
, description => <<"Page Limit">>
|
, desc => <<"Page Limit">>
|
||||||
, example => 100
|
, example => 100
|
||||||
})}
|
})}
|
||||||
].
|
].
|
||||||
|
@ -308,14 +308,14 @@ params_fuzzy_in_qs() ->
|
||||||
mk(binary(),
|
mk(binary(),
|
||||||
#{ in => query
|
#{ in => query
|
||||||
, required => false
|
, required => false
|
||||||
, description => <<"Fuzzy search by username">>
|
, desc => <<"Fuzzy search by username">>
|
||||||
, example => <<"username">>
|
, example => <<"username">>
|
||||||
})},
|
})},
|
||||||
{like_clientid,
|
{like_clientid,
|
||||||
mk(binary(),
|
mk(binary(),
|
||||||
#{ in => query
|
#{ in => query
|
||||||
, required => false
|
, required => false
|
||||||
, description => <<"Fuzzy search by clientid">>
|
, desc => <<"Fuzzy search by clientid">>
|
||||||
, example => <<"clientid">>
|
, example => <<"clientid">>
|
||||||
})}
|
})}
|
||||||
].
|
].
|
||||||
|
|
|
@ -403,7 +403,7 @@ conn_state_to_connected(_) -> false.
|
||||||
schema("/gateway/:name/clients") ->
|
schema("/gateway/:name/clients") ->
|
||||||
#{ 'operationId' => clients
|
#{ 'operationId' => clients
|
||||||
, get =>
|
, get =>
|
||||||
#{ description => <<"Get the gateway client list">>
|
#{ desc => <<"Get the gateway client list">>
|
||||||
, parameters => params_client_query()
|
, parameters => params_client_query()
|
||||||
, responses =>
|
, responses =>
|
||||||
?STANDARD_RESP(#{200 => schema_client_list()})
|
?STANDARD_RESP(#{200 => schema_client_list()})
|
||||||
|
@ -412,13 +412,13 @@ schema("/gateway/:name/clients") ->
|
||||||
schema("/gateway/:name/clients/:clientid") ->
|
schema("/gateway/:name/clients/:clientid") ->
|
||||||
#{ 'operationId' => clients_insta
|
#{ 'operationId' => clients_insta
|
||||||
, get =>
|
, get =>
|
||||||
#{ description => <<"Get the gateway client information">>
|
#{ desc => <<"Get the gateway client information">>
|
||||||
, parameters => params_client_insta()
|
, parameters => params_client_insta()
|
||||||
, responses =>
|
, responses =>
|
||||||
?STANDARD_RESP(#{200 => schema_client()})
|
?STANDARD_RESP(#{200 => schema_client()})
|
||||||
}
|
}
|
||||||
, delete =>
|
, delete =>
|
||||||
#{ description => <<"Kick out the gateway client">>
|
#{ desc => <<"Kick out the gateway client">>
|
||||||
, parameters => params_client_insta()
|
, parameters => params_client_insta()
|
||||||
, responses =>
|
, responses =>
|
||||||
?STANDARD_RESP(#{204 => <<"Kicked">>})
|
?STANDARD_RESP(#{204 => <<"Kicked">>})
|
||||||
|
@ -427,7 +427,7 @@ schema("/gateway/:name/clients/:clientid") ->
|
||||||
schema("/gateway/:name/clients/:clientid/subscriptions") ->
|
schema("/gateway/:name/clients/:clientid/subscriptions") ->
|
||||||
#{ 'operationId' => subscriptions
|
#{ 'operationId' => subscriptions
|
||||||
, get =>
|
, get =>
|
||||||
#{ description => <<"Get the gateway client subscriptions">>
|
#{ desc => <<"Get the gateway client subscriptions">>
|
||||||
, parameters => params_client_insta()
|
, parameters => params_client_insta()
|
||||||
, responses =>
|
, responses =>
|
||||||
?STANDARD_RESP(
|
?STANDARD_RESP(
|
||||||
|
@ -436,7 +436,7 @@ schema("/gateway/:name/clients/:clientid/subscriptions") ->
|
||||||
examples_subsctiption_list())})
|
examples_subsctiption_list())})
|
||||||
}
|
}
|
||||||
, post =>
|
, post =>
|
||||||
#{ description => <<"Create a subscription membership">>
|
#{ desc => <<"Create a subscription membership">>
|
||||||
, parameters => params_client_insta()
|
, parameters => params_client_insta()
|
||||||
, 'requestBody' => emqx_dashboard_swagger:schema_with_examples(
|
, 'requestBody' => emqx_dashboard_swagger:schema_with_examples(
|
||||||
ref(subscription),
|
ref(subscription),
|
||||||
|
@ -451,7 +451,7 @@ schema("/gateway/:name/clients/:clientid/subscriptions") ->
|
||||||
schema("/gateway/:name/clients/:clientid/subscriptions/:topic") ->
|
schema("/gateway/:name/clients/:clientid/subscriptions/:topic") ->
|
||||||
#{ 'operationId' => subscriptions
|
#{ 'operationId' => subscriptions
|
||||||
, delete =>
|
, delete =>
|
||||||
#{ description => <<"Delete a subscriptions membership">>
|
#{ desc => <<"Delete a subscriptions membership">>
|
||||||
, parameters => params_topic_name_in_path() ++ params_client_insta()
|
, parameters => params_topic_name_in_path() ++ params_client_insta()
|
||||||
, responses =>
|
, responses =>
|
||||||
?STANDARD_RESP(#{204 => <<"Unsubscribed">>})
|
?STANDARD_RESP(#{204 => <<"Unsubscribed">>})
|
||||||
|
@ -471,60 +471,60 @@ params_client_searching_in_qs() ->
|
||||||
M = #{in => query, required => false, example => <<"">>},
|
M = #{in => query, required => false, example => <<"">>},
|
||||||
[ {node,
|
[ {node,
|
||||||
mk(binary(),
|
mk(binary(),
|
||||||
M#{description => <<"Match the client's node name">>})}
|
M#{desc => <<"Match the client's node name">>})}
|
||||||
, {clientid,
|
, {clientid,
|
||||||
mk(binary(),
|
mk(binary(),
|
||||||
M#{description => <<"Match the client's ID">>})}
|
M#{desc => <<"Match the client's ID">>})}
|
||||||
, {username,
|
, {username,
|
||||||
mk(binary(),
|
mk(binary(),
|
||||||
M#{description => <<"Match the client's Username">>})}
|
M#{desc => <<"Match the client's Username">>})}
|
||||||
, {ip_address,
|
, {ip_address,
|
||||||
mk(binary(),
|
mk(binary(),
|
||||||
M#{description => <<"Match the client's ip address">>})}
|
M#{desc => <<"Match the client's ip address">>})}
|
||||||
, {conn_state,
|
, {conn_state,
|
||||||
mk(binary(),
|
mk(binary(),
|
||||||
M#{description => <<"Match the client's connection state">>})}
|
M#{desc => <<"Match the client's connection state">>})}
|
||||||
, {proto_ver,
|
, {proto_ver,
|
||||||
mk(binary(),
|
mk(binary(),
|
||||||
M#{description => <<"Match the client's protocol version">>})}
|
M#{desc => <<"Match the client's protocol version">>})}
|
||||||
, {clean_start,
|
, {clean_start,
|
||||||
mk(boolean(),
|
mk(boolean(),
|
||||||
M#{description => <<"Match the client's clean start flag">>})}
|
M#{desc => <<"Match the client's clean start flag">>})}
|
||||||
, {like_clientid,
|
, {like_clientid,
|
||||||
mk(binary(),
|
mk(binary(),
|
||||||
M#{description => <<"Use sub-string to match client's ID">>})}
|
M#{desc => <<"Use sub-string to match client's ID">>})}
|
||||||
, {like_username,
|
, {like_username,
|
||||||
mk(binary(),
|
mk(binary(),
|
||||||
M#{description => <<"Use sub-string to match client's username">>})}
|
M#{desc => <<"Use sub-string to match client's username">>})}
|
||||||
, {gte_created_at,
|
, {gte_created_at,
|
||||||
mk(emqx_datetime:epoch_millisecond(),
|
mk(emqx_datetime:epoch_millisecond(),
|
||||||
M#{description => <<"Match the session created datetime greater than "
|
M#{desc => <<"Match the session created datetime greater than "
|
||||||
"a certain value">>})}
|
"a certain value">>})}
|
||||||
, {lte_created_at,
|
, {lte_created_at,
|
||||||
mk(emqx_datetime:epoch_millisecond(),
|
mk(emqx_datetime:epoch_millisecond(),
|
||||||
M#{description => <<"Match the session created datetime less than "
|
M#{desc => <<"Match the session created datetime less than "
|
||||||
"a certain value">>})}
|
"a certain value">>})}
|
||||||
, {gte_connected_at,
|
, {gte_connected_at,
|
||||||
mk(emqx_datetime:epoch_millisecond(),
|
mk(emqx_datetime:epoch_millisecond(),
|
||||||
M#{description => <<"Match the client socket connected datetime greater "
|
M#{desc => <<"Match the client socket connected datetime greater "
|
||||||
"than a certain value">>})}
|
"than a certain value">>})}
|
||||||
, {lte_connected_at,
|
, {lte_connected_at,
|
||||||
mk(emqx_datetime:epoch_millisecond(),
|
mk(emqx_datetime:epoch_millisecond(),
|
||||||
M#{description => <<"Match the client socket connected datatime less than "
|
M#{desc => <<"Match the client socket connected datatime less than "
|
||||||
"a certain value">>})}
|
"a certain value">>})}
|
||||||
, {endpoint_name,
|
, {endpoint_name,
|
||||||
mk(binary(),
|
mk(binary(),
|
||||||
M#{description => <<"Match the lwm2m client's endpoint name">>})}
|
M#{desc => <<"Match the lwm2m client's endpoint name">>})}
|
||||||
, {like_endpoint_name,
|
, {like_endpoint_name,
|
||||||
mk(binary(),
|
mk(binary(),
|
||||||
M#{description => <<"Use sub-string to match lwm2m client's endpoint name">>})}
|
M#{desc => <<"Use sub-string to match lwm2m client's endpoint name">>})}
|
||||||
, {gte_lifetime,
|
, {gte_lifetime,
|
||||||
mk(binary(),
|
mk(binary(),
|
||||||
M#{description => <<"Match the lwm2m client registered lifetime greater "
|
M#{desc => <<"Match the lwm2m client registered lifetime greater "
|
||||||
"than a certain value">>})}
|
"than a certain value">>})}
|
||||||
, {lte_lifetime,
|
, {lte_lifetime,
|
||||||
mk(binary(),
|
mk(binary(),
|
||||||
M#{description => <<"Match the lwm2m client registered lifetime less than "
|
M#{desc => <<"Match the lwm2m client registered lifetime less than "
|
||||||
"a certain value">>})}
|
"a certain value">>})}
|
||||||
].
|
].
|
||||||
|
|
||||||
|
@ -533,13 +533,13 @@ params_paging() ->
|
||||||
mk(integer(),
|
mk(integer(),
|
||||||
#{ in => query
|
#{ in => query
|
||||||
, required => false
|
, required => false
|
||||||
, description => <<"Page Index">>
|
, desc => <<"Page Index">>
|
||||||
, example => 1
|
, example => 1
|
||||||
})}
|
})}
|
||||||
, {limit,
|
, {limit,
|
||||||
mk(integer(),
|
mk(integer(),
|
||||||
#{ in => query
|
#{ in => query
|
||||||
, description => <<"Page Limit">>
|
, desc => <<"Page Limit">>
|
||||||
, required => false
|
, required => false
|
||||||
, example => 100
|
, example => 100
|
||||||
})}
|
})}
|
||||||
|
@ -549,7 +549,7 @@ params_gateway_name_in_path() ->
|
||||||
[{name,
|
[{name,
|
||||||
mk(binary(),
|
mk(binary(),
|
||||||
#{ in => path
|
#{ in => path
|
||||||
, description => <<"Gateway Name">>
|
, desc => <<"Gateway Name">>
|
||||||
})}
|
})}
|
||||||
].
|
].
|
||||||
|
|
||||||
|
@ -557,7 +557,7 @@ params_clientid_in_path() ->
|
||||||
[{clientid,
|
[{clientid,
|
||||||
mk(binary(),
|
mk(binary(),
|
||||||
#{ in => path
|
#{ in => path
|
||||||
, description => <<"Client ID">>
|
, desc => <<"Client ID">>
|
||||||
})}
|
})}
|
||||||
].
|
].
|
||||||
|
|
||||||
|
@ -565,7 +565,7 @@ params_topic_name_in_path() ->
|
||||||
[{topic,
|
[{topic,
|
||||||
mk(binary(),
|
mk(binary(),
|
||||||
#{ in => path
|
#{ in => path
|
||||||
, description => <<"Topic Filter/Name">>
|
, desc => <<"Topic Filter/Name">>
|
||||||
})}
|
})}
|
||||||
].
|
].
|
||||||
|
|
||||||
|
@ -612,10 +612,10 @@ fields(coap_client) ->
|
||||||
fields(lwm2m_client) ->
|
fields(lwm2m_client) ->
|
||||||
[ {endpoint_name,
|
[ {endpoint_name,
|
||||||
mk(binary(),
|
mk(binary(),
|
||||||
#{ description => <<"The LwM2M client endpoint name">>})}
|
#{ desc => <<"The LwM2M client endpoint name">>})}
|
||||||
, {lifetime,
|
, {lifetime,
|
||||||
mk(integer(),
|
mk(integer(),
|
||||||
#{ description => <<"Life time">>})}
|
#{ desc => <<"Life time">>})}
|
||||||
] ++ common_client_props();
|
] ++ common_client_props();
|
||||||
fields(exproto_client) ->
|
fields(exproto_client) ->
|
||||||
common_client_props();
|
common_client_props();
|
||||||
|
@ -623,153 +623,153 @@ fields(exproto_client) ->
|
||||||
fields(subscription) ->
|
fields(subscription) ->
|
||||||
[ {topic,
|
[ {topic,
|
||||||
mk(binary(),
|
mk(binary(),
|
||||||
#{ description => <<"Topic Fillter">>})}
|
#{ desc => <<"Topic Fillter">>})}
|
||||||
, {qos,
|
, {qos,
|
||||||
mk(integer(),
|
mk(integer(),
|
||||||
#{ description => <<"QoS level, enum: 0, 1, 2">>})}
|
#{ desc => <<"QoS level, enum: 0, 1, 2">>})}
|
||||||
, {nl,
|
, {nl,
|
||||||
mk(integer(), %% FIXME: why not boolean?
|
mk(integer(), %% FIXME: why not boolean?
|
||||||
#{ description => <<"No Local option, enum: 0, 1">>})}
|
#{ desc => <<"No Local option, enum: 0, 1">>})}
|
||||||
, {rap,
|
, {rap,
|
||||||
mk(integer(),
|
mk(integer(),
|
||||||
#{ description => <<"Retain as Published option, enum: 0, 1">>})}
|
#{ desc => <<"Retain as Published option, enum: 0, 1">>})}
|
||||||
, {rh,
|
, {rh,
|
||||||
mk(integer(),
|
mk(integer(),
|
||||||
#{ description => <<"Retain Handling option, enum: 0, 1, 2">>})}
|
#{ desc => <<"Retain Handling option, enum: 0, 1, 2">>})}
|
||||||
, {sub_props,
|
, {sub_props,
|
||||||
mk(ref(extra_sub_props),
|
mk(ref(extra_sub_props),
|
||||||
#{description => <<"Subscription properties">>})}
|
#{desc => <<"Subscription properties">>})}
|
||||||
];
|
];
|
||||||
fields(extra_sub_props) ->
|
fields(extra_sub_props) ->
|
||||||
[ {subid,
|
[ {subid,
|
||||||
mk(binary(),
|
mk(binary(),
|
||||||
#{ description => <<"Only stomp protocol, a unique identity for "
|
#{ desc => <<"Only stomp protocol, a unique identity for "
|
||||||
"the subscription. range: 1-65535.">>})}
|
"the subscription. range: 1-65535.">>})}
|
||||||
].
|
].
|
||||||
|
|
||||||
common_client_props() ->
|
common_client_props() ->
|
||||||
[ {node,
|
[ {node,
|
||||||
mk(binary(),
|
mk(binary(),
|
||||||
#{ description => <<"Name of the node to which the client is "
|
#{ desc => <<"Name of the node to which the client is "
|
||||||
"connected">>})}
|
"connected">>})}
|
||||||
, {clientid,
|
, {clientid,
|
||||||
mk(binary(),
|
mk(binary(),
|
||||||
#{ description => <<"Client identifier">>})}
|
#{ desc => <<"Client identifier">>})}
|
||||||
, {username,
|
, {username,
|
||||||
mk(binary(),
|
mk(binary(),
|
||||||
#{ description => <<"Username of client when connecting">>})}
|
#{ desc => <<"Username of client when connecting">>})}
|
||||||
, {proto_name,
|
, {proto_name,
|
||||||
mk(binary(),
|
mk(binary(),
|
||||||
#{ description => <<"Client protocol name">>})}
|
#{ desc => <<"Client protocol name">>})}
|
||||||
, {proto_ver,
|
, {proto_ver,
|
||||||
mk(binary(),
|
mk(binary(),
|
||||||
#{ description => <<"Protocol version used by the client">>})}
|
#{ desc => <<"Protocol version used by the client">>})}
|
||||||
, {ip_address,
|
, {ip_address,
|
||||||
mk(binary(),
|
mk(binary(),
|
||||||
#{ description => <<"Client's IP address">>})}
|
#{ desc => <<"Client's IP address">>})}
|
||||||
, {port,
|
, {port,
|
||||||
mk(integer(),
|
mk(integer(),
|
||||||
#{ description => <<"Client's port">>})}
|
#{ desc => <<"Client's port">>})}
|
||||||
, {is_bridge,
|
, {is_bridge,
|
||||||
mk(boolean(),
|
mk(boolean(),
|
||||||
#{ description => <<"Indicates whether the client is connected via "
|
#{ desc => <<"Indicates whether the client is connected via "
|
||||||
"bridge">>})}
|
"bridge">>})}
|
||||||
, {connected_at,
|
, {connected_at,
|
||||||
mk(emqx_datetime:epoch_millisecond(),
|
mk(emqx_datetime:epoch_millisecond(),
|
||||||
#{ description => <<"Client connection time">>})}
|
#{ desc => <<"Client connection time">>})}
|
||||||
, {disconnected_at,
|
, {disconnected_at,
|
||||||
mk(emqx_datetime:epoch_millisecond(),
|
mk(emqx_datetime:epoch_millisecond(),
|
||||||
#{ description => <<"Client offline time, This field is only valid and "
|
#{ desc => <<"Client offline time, This field is only valid and "
|
||||||
"returned when connected is false">>})}
|
"returned when connected is false">>})}
|
||||||
, {connected,
|
, {connected,
|
||||||
mk(boolean(),
|
mk(boolean(),
|
||||||
#{ description => <<"Whether the client is connected">>})}
|
#{ desc => <<"Whether the client is connected">>})}
|
||||||
%% FIXME: the will_msg attribute is not a general attribute
|
%% FIXME: the will_msg attribute is not a general attribute
|
||||||
%% for every protocol. But it should be returned to frontend if someone
|
%% for every protocol. But it should be returned to frontend if someone
|
||||||
%% want it
|
%% want it
|
||||||
%%
|
%%
|
||||||
%, {will_msg,
|
%, {will_msg,
|
||||||
% mk(binary(),
|
% mk(binary(),
|
||||||
% #{ description => <<"Client will message">>})}
|
% #{ desc => <<"Client will message">>})}
|
||||||
, {keepalive,
|
, {keepalive,
|
||||||
mk(integer(),
|
mk(integer(),
|
||||||
#{ description => <<"keepalive time, with the unit of second">>})}
|
#{ desc => <<"keepalive time, with the unit of second">>})}
|
||||||
, {clean_start,
|
, {clean_start,
|
||||||
mk(boolean(),
|
mk(boolean(),
|
||||||
#{ description => <<"Indicate whether the client is using a brand "
|
#{ desc => <<"Indicate whether the client is using a brand "
|
||||||
"new session">>})}
|
"new session">>})}
|
||||||
, {expiry_interval,
|
, {expiry_interval,
|
||||||
mk(integer(),
|
mk(integer(),
|
||||||
#{ description => <<"Session expiration interval, with the unit of "
|
#{ desc => <<"Session expiration interval, with the unit of "
|
||||||
"second">>})}
|
"second">>})}
|
||||||
, {created_at,
|
, {created_at,
|
||||||
mk(emqx_datetime:epoch_millisecond(),
|
mk(emqx_datetime:epoch_millisecond(),
|
||||||
#{ description => <<"Session creation time">>})}
|
#{ desc => <<"Session creation time">>})}
|
||||||
, {subscriptions_cnt,
|
, {subscriptions_cnt,
|
||||||
mk(integer(),
|
mk(integer(),
|
||||||
#{ description => <<"Number of subscriptions established by this "
|
#{ desc => <<"Number of subscriptions established by this "
|
||||||
"client">>})}
|
"client">>})}
|
||||||
, {subscriptions_max,
|
, {subscriptions_max,
|
||||||
mk(integer(),
|
mk(integer(),
|
||||||
#{ description => <<"Maximum number of subscriptions allowed by this "
|
#{ desc => <<"Maximum number of subscriptions allowed by this "
|
||||||
"client">>})}
|
"client">>})}
|
||||||
, {inflight_cnt,
|
, {inflight_cnt,
|
||||||
mk(integer(),
|
mk(integer(),
|
||||||
#{ description => <<"Current length of inflight">>})}
|
#{ desc => <<"Current length of inflight">>})}
|
||||||
, {inflight_max,
|
, {inflight_max,
|
||||||
mk(integer(),
|
mk(integer(),
|
||||||
#{ description => <<"Maximum length of inflight">>})}
|
#{ desc => <<"Maximum length of inflight">>})}
|
||||||
, {mqueue_len,
|
, {mqueue_len,
|
||||||
mk(integer(),
|
mk(integer(),
|
||||||
#{ description => <<"Current length of message queue">>})}
|
#{ desc => <<"Current length of message queue">>})}
|
||||||
, {mqueue_max,
|
, {mqueue_max,
|
||||||
mk(integer(),
|
mk(integer(),
|
||||||
#{ description => <<"Maximum length of message queue">>})}
|
#{ desc => <<"Maximum length of message queue">>})}
|
||||||
, {mqueue_dropped,
|
, {mqueue_dropped,
|
||||||
mk(integer(),
|
mk(integer(),
|
||||||
#{ description => <<"Number of messages dropped by the message queue "
|
#{ desc => <<"Number of messages dropped by the message queue "
|
||||||
"due to exceeding the length">>})}
|
"due to exceeding the length">>})}
|
||||||
, {awaiting_rel_cnt,
|
, {awaiting_rel_cnt,
|
||||||
mk(integer(),
|
mk(integer(),
|
||||||
%% FIXME: PUBREC ??
|
%% FIXME: PUBREC ??
|
||||||
#{ description => <<"Number of awaiting acknowledge packet">>})}
|
#{ desc => <<"Number of awaiting acknowledge packet">>})}
|
||||||
, {awaiting_rel_max,
|
, {awaiting_rel_max,
|
||||||
mk(integer(),
|
mk(integer(),
|
||||||
#{ description => <<"Maximum allowed number of awaiting PUBREC "
|
#{ desc => <<"Maximum allowed number of awaiting PUBREC "
|
||||||
"packet">>})}
|
"packet">>})}
|
||||||
, {recv_oct,
|
, {recv_oct,
|
||||||
mk(integer(),
|
mk(integer(),
|
||||||
#{ description => <<"Number of bytes received">>})}
|
#{ desc => <<"Number of bytes received">>})}
|
||||||
, {recv_cnt,
|
, {recv_cnt,
|
||||||
mk(integer(),
|
mk(integer(),
|
||||||
#{ description => <<"Number of socket packets received">>})}
|
#{ desc => <<"Number of socket packets received">>})}
|
||||||
, {recv_pkt,
|
, {recv_pkt,
|
||||||
mk(integer(),
|
mk(integer(),
|
||||||
#{ description => <<"Number of protocol packets received">>})}
|
#{ desc => <<"Number of protocol packets received">>})}
|
||||||
, {recv_msg,
|
, {recv_msg,
|
||||||
mk(integer(),
|
mk(integer(),
|
||||||
#{ description => <<"Number of message packets received">>})}
|
#{ desc => <<"Number of message packets received">>})}
|
||||||
, {send_oct,
|
, {send_oct,
|
||||||
mk(integer(),
|
mk(integer(),
|
||||||
#{ description => <<"Number of bytes sent">>})}
|
#{ desc => <<"Number of bytes sent">>})}
|
||||||
, {send_cnt,
|
, {send_cnt,
|
||||||
mk(integer(),
|
mk(integer(),
|
||||||
#{ description => <<"Number of socket packets sent">>})}
|
#{ desc => <<"Number of socket packets sent">>})}
|
||||||
, {send_pkt,
|
, {send_pkt,
|
||||||
mk(integer(),
|
mk(integer(),
|
||||||
#{ description => <<"Number of protocol packets sent">>})}
|
#{ desc => <<"Number of protocol packets sent">>})}
|
||||||
, {send_msg,
|
, {send_msg,
|
||||||
mk(integer(),
|
mk(integer(),
|
||||||
#{ description => <<"Number of message packets sent">>})}
|
#{ desc => <<"Number of message packets sent">>})}
|
||||||
, {mailbox_len,
|
, {mailbox_len,
|
||||||
mk(integer(),
|
mk(integer(),
|
||||||
#{ description => <<"Process mailbox size">>})}
|
#{ desc => <<"Process mailbox size">>})}
|
||||||
, {heap_size,
|
, {heap_size,
|
||||||
mk(integer(),
|
mk(integer(),
|
||||||
#{ description => <<"Process heap size with the unit of byte">>})}
|
#{ desc => <<"Process heap size with the unit of byte">>})}
|
||||||
, {reductions,
|
, {reductions,
|
||||||
mk(integer(),
|
mk(integer(),
|
||||||
#{ description => <<"Erlang reduction">>})}
|
#{ desc => <<"Erlang reduction">>})}
|
||||||
].
|
].
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
|
@ -221,7 +221,7 @@ page_pramas(Qs) ->
|
||||||
schema("/gateway/:name/listeners") ->
|
schema("/gateway/:name/listeners") ->
|
||||||
#{ 'operationId' => listeners,
|
#{ 'operationId' => listeners,
|
||||||
get =>
|
get =>
|
||||||
#{ description => <<"Get the gateway listeners">>
|
#{ desc => <<"Get the gateway listeners">>
|
||||||
, parameters => params_gateway_name_in_path()
|
, parameters => params_gateway_name_in_path()
|
||||||
, responses =>
|
, responses =>
|
||||||
?STANDARD_RESP(
|
?STANDARD_RESP(
|
||||||
|
@ -231,7 +231,7 @@ schema("/gateway/:name/listeners") ->
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
post =>
|
post =>
|
||||||
#{ description => <<"Create the gateway listener">>
|
#{ desc => <<"Create the gateway listener">>
|
||||||
, parameters => params_gateway_name_in_path()
|
, parameters => params_gateway_name_in_path()
|
||||||
%% XXX: How to distinguish the different listener supported by
|
%% XXX: How to distinguish the different listener supported by
|
||||||
%% different types of gateways?
|
%% different types of gateways?
|
||||||
|
@ -249,7 +249,7 @@ schema("/gateway/:name/listeners") ->
|
||||||
schema("/gateway/:name/listeners/:id") ->
|
schema("/gateway/:name/listeners/:id") ->
|
||||||
#{ 'operationId' => listeners_insta,
|
#{ 'operationId' => listeners_insta,
|
||||||
get =>
|
get =>
|
||||||
#{ description => <<"Get the gateway listener configurations">>
|
#{ desc => <<"Get the gateway listener configurations">>
|
||||||
, parameters => params_gateway_name_in_path()
|
, parameters => params_gateway_name_in_path()
|
||||||
++ params_listener_id_in_path()
|
++ params_listener_id_in_path()
|
||||||
, responses =>
|
, responses =>
|
||||||
|
@ -260,14 +260,14 @@ schema("/gateway/:name/listeners/:id") ->
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
delete =>
|
delete =>
|
||||||
#{ description => <<"Delete the gateway listener">>
|
#{ desc => <<"Delete the gateway listener">>
|
||||||
, parameters => params_gateway_name_in_path()
|
, parameters => params_gateway_name_in_path()
|
||||||
++ params_listener_id_in_path()
|
++ params_listener_id_in_path()
|
||||||
, responses =>
|
, responses =>
|
||||||
?STANDARD_RESP(#{204 => <<"Deleted">>})
|
?STANDARD_RESP(#{204 => <<"Deleted">>})
|
||||||
},
|
},
|
||||||
put =>
|
put =>
|
||||||
#{ description => <<"Update the gateway listener">>
|
#{ desc => <<"Update the gateway listener">>
|
||||||
, parameters => params_gateway_name_in_path()
|
, parameters => params_gateway_name_in_path()
|
||||||
++ params_listener_id_in_path()
|
++ params_listener_id_in_path()
|
||||||
, 'requestBody' => emqx_dashboard_swagger:schema_with_examples(
|
, 'requestBody' => emqx_dashboard_swagger:schema_with_examples(
|
||||||
|
@ -284,7 +284,7 @@ schema("/gateway/:name/listeners/:id") ->
|
||||||
schema("/gateway/:name/listeners/:id/authentication") ->
|
schema("/gateway/:name/listeners/:id/authentication") ->
|
||||||
#{ 'operationId' => listeners_insta_authn,
|
#{ 'operationId' => listeners_insta_authn,
|
||||||
get =>
|
get =>
|
||||||
#{ description => <<"Get the listener's authentication info">>
|
#{ desc => <<"Get the listener's authentication info">>
|
||||||
, parameters => params_gateway_name_in_path()
|
, parameters => params_gateway_name_in_path()
|
||||||
++ params_listener_id_in_path()
|
++ params_listener_id_in_path()
|
||||||
, responses =>
|
, responses =>
|
||||||
|
@ -294,7 +294,7 @@ schema("/gateway/:name/listeners/:id/authentication") ->
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
post =>
|
post =>
|
||||||
#{ description => <<"Add authentication for the listener">>
|
#{ desc => <<"Add authentication for the listener">>
|
||||||
, parameters => params_gateway_name_in_path()
|
, parameters => params_gateway_name_in_path()
|
||||||
++ params_listener_id_in_path()
|
++ params_listener_id_in_path()
|
||||||
, 'requestBody' => schema_authn()
|
, 'requestBody' => schema_authn()
|
||||||
|
@ -302,7 +302,7 @@ schema("/gateway/:name/listeners/:id/authentication") ->
|
||||||
?STANDARD_RESP(#{201 => schema_authn()})
|
?STANDARD_RESP(#{201 => schema_authn()})
|
||||||
},
|
},
|
||||||
put =>
|
put =>
|
||||||
#{ description => <<"Update authentication for the listener">>
|
#{ desc => <<"Update authentication for the listener">>
|
||||||
, parameters => params_gateway_name_in_path()
|
, parameters => params_gateway_name_in_path()
|
||||||
++ params_listener_id_in_path()
|
++ params_listener_id_in_path()
|
||||||
, 'requestBody' => schema_authn()
|
, 'requestBody' => schema_authn()
|
||||||
|
@ -310,7 +310,7 @@ schema("/gateway/:name/listeners/:id/authentication") ->
|
||||||
?STANDARD_RESP(#{200 => schema_authn()})
|
?STANDARD_RESP(#{200 => schema_authn()})
|
||||||
},
|
},
|
||||||
delete =>
|
delete =>
|
||||||
#{ description => <<"Remove authentication for the listener">>
|
#{ desc => <<"Remove authentication for the listener">>
|
||||||
, parameters => params_gateway_name_in_path()
|
, parameters => params_gateway_name_in_path()
|
||||||
++ params_listener_id_in_path()
|
++ params_listener_id_in_path()
|
||||||
, responses =>
|
, responses =>
|
||||||
|
@ -320,7 +320,7 @@ schema("/gateway/:name/listeners/:id/authentication") ->
|
||||||
schema("/gateway/:name/listeners/:id/authentication/users") ->
|
schema("/gateway/:name/listeners/:id/authentication/users") ->
|
||||||
#{ 'operationId' => users
|
#{ 'operationId' => users
|
||||||
, get =>
|
, get =>
|
||||||
#{ description => <<"Get the users for the authentication">>
|
#{ desc => <<"Get the users for the authentication">>
|
||||||
, parameters => params_gateway_name_in_path() ++
|
, parameters => params_gateway_name_in_path() ++
|
||||||
params_listener_id_in_path() ++
|
params_listener_id_in_path() ++
|
||||||
params_paging_in_qs()
|
params_paging_in_qs()
|
||||||
|
@ -332,7 +332,7 @@ schema("/gateway/:name/listeners/:id/authentication/users") ->
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
post =>
|
post =>
|
||||||
#{ description => <<"Add user for the authentication">>
|
#{ desc => <<"Add user for the authentication">>
|
||||||
, parameters => params_gateway_name_in_path() ++
|
, parameters => params_gateway_name_in_path() ++
|
||||||
params_listener_id_in_path()
|
params_listener_id_in_path()
|
||||||
, 'requestBody' => emqx_dashboard_swagger:schema_with_examples(
|
, 'requestBody' => emqx_dashboard_swagger:schema_with_examples(
|
||||||
|
@ -349,7 +349,7 @@ schema("/gateway/:name/listeners/:id/authentication/users") ->
|
||||||
schema("/gateway/:name/listeners/:id/authentication/users/:uid") ->
|
schema("/gateway/:name/listeners/:id/authentication/users/:uid") ->
|
||||||
#{ 'operationId' => users_insta
|
#{ 'operationId' => users_insta
|
||||||
, get =>
|
, get =>
|
||||||
#{ description => <<"Get user info from the gateway "
|
#{ desc => <<"Get user info from the gateway "
|
||||||
"authentication">>
|
"authentication">>
|
||||||
, parameters => params_gateway_name_in_path() ++
|
, parameters => params_gateway_name_in_path() ++
|
||||||
params_listener_id_in_path() ++
|
params_listener_id_in_path() ++
|
||||||
|
@ -362,7 +362,7 @@ schema("/gateway/:name/listeners/:id/authentication/users/:uid") ->
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
put =>
|
put =>
|
||||||
#{ description => <<"Update the user info for the gateway "
|
#{ desc => <<"Update the user info for the gateway "
|
||||||
"authentication">>
|
"authentication">>
|
||||||
, parameters => params_gateway_name_in_path() ++
|
, parameters => params_gateway_name_in_path() ++
|
||||||
params_listener_id_in_path() ++
|
params_listener_id_in_path() ++
|
||||||
|
@ -378,7 +378,7 @@ schema("/gateway/:name/listeners/:id/authentication/users/:uid") ->
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
delete =>
|
delete =>
|
||||||
#{ description => <<"Delete the user for the gateway "
|
#{ desc => <<"Delete the user for the gateway "
|
||||||
"authentication">>
|
"authentication">>
|
||||||
, parameters => params_gateway_name_in_path() ++
|
, parameters => params_gateway_name_in_path() ++
|
||||||
params_listener_id_in_path() ++
|
params_listener_id_in_path() ++
|
||||||
|
@ -390,7 +390,7 @@ schema("/gateway/:name/listeners/:id/authentication/users/:uid") ->
|
||||||
schema("/gateway/:name/listeners/:id/authentication/import_users") ->
|
schema("/gateway/:name/listeners/:id/authentication/import_users") ->
|
||||||
#{ 'operationId' => import_users
|
#{ 'operationId' => import_users
|
||||||
, post =>
|
, post =>
|
||||||
#{ description => <<"Import users into the gateway authentication">>
|
#{ desc => <<"Import users into the gateway authentication">>
|
||||||
, parameters => params_gateway_name_in_path() ++
|
, parameters => params_gateway_name_in_path() ++
|
||||||
params_listener_id_in_path()
|
params_listener_id_in_path()
|
||||||
, 'requestBody' => emqx_dashboard_swagger:schema_with_examples(
|
, 'requestBody' => emqx_dashboard_swagger:schema_with_examples(
|
||||||
|
@ -409,7 +409,7 @@ params_gateway_name_in_path() ->
|
||||||
[{name,
|
[{name,
|
||||||
mk(binary(),
|
mk(binary(),
|
||||||
#{ in => path
|
#{ in => path
|
||||||
, description => <<"Gateway Name">>
|
, desc => <<"Gateway Name">>
|
||||||
, example => <<"">>
|
, example => <<"">>
|
||||||
})}
|
})}
|
||||||
].
|
].
|
||||||
|
@ -418,7 +418,7 @@ params_listener_id_in_path() ->
|
||||||
[{id,
|
[{id,
|
||||||
mk(binary(),
|
mk(binary(),
|
||||||
#{ in => path
|
#{ in => path
|
||||||
, description => <<"Listener ID">>
|
, desc => <<"Listener ID">>
|
||||||
, example => <<"">>
|
, example => <<"">>
|
||||||
})}
|
})}
|
||||||
].
|
].
|
||||||
|
@ -426,7 +426,7 @@ params_listener_id_in_path() ->
|
||||||
params_userid_in_path() ->
|
params_userid_in_path() ->
|
||||||
[{uid, mk(binary(),
|
[{uid, mk(binary(),
|
||||||
#{ in => path
|
#{ in => path
|
||||||
, description => <<"User ID">>
|
, desc => <<"User ID">>
|
||||||
, example => <<"">>
|
, example => <<"">>
|
||||||
})}
|
})}
|
||||||
].
|
].
|
||||||
|
@ -435,13 +435,13 @@ params_paging_in_qs() ->
|
||||||
[{page, mk(integer(),
|
[{page, mk(integer(),
|
||||||
#{ in => query
|
#{ in => query
|
||||||
, required => false
|
, required => false
|
||||||
, description => <<"Page Index">>
|
, desc => <<"Page Index">>
|
||||||
, example => 1
|
, example => 1
|
||||||
})},
|
})},
|
||||||
{limit, mk(integer(),
|
{limit, mk(integer(),
|
||||||
#{ in => query
|
#{ in => query
|
||||||
, required => false
|
, required => false
|
||||||
, description => <<"Page Limit">>
|
, desc => <<"Page Limit">>
|
||||||
, example => 100
|
, example => 100
|
||||||
})}
|
})}
|
||||||
].
|
].
|
||||||
|
@ -458,22 +458,22 @@ fields(listener) ->
|
||||||
[ {tcp,
|
[ {tcp,
|
||||||
mk(ref(tcp_listener_opts),
|
mk(ref(tcp_listener_opts),
|
||||||
#{ required => {false, recursively}
|
#{ required => {false, recursively}
|
||||||
, description => <<"The tcp socket options for tcp or ssl listener">>
|
, desc => <<"The tcp socket options for tcp or ssl listener">>
|
||||||
})}
|
})}
|
||||||
, {ssl,
|
, {ssl,
|
||||||
mk(ref(ssl_listener_opts),
|
mk(ref(ssl_listener_opts),
|
||||||
#{ required => {false, recursively}
|
#{ required => {false, recursively}
|
||||||
, description => <<"The ssl socket options for ssl listener">>
|
, desc => <<"The ssl socket options for ssl listener">>
|
||||||
})}
|
})}
|
||||||
, {udp,
|
, {udp,
|
||||||
mk(ref(udp_listener_opts),
|
mk(ref(udp_listener_opts),
|
||||||
#{ required => {false, recursively}
|
#{ required => {false, recursively}
|
||||||
, description => <<"The udp socket options for udp or dtls listener">>
|
, desc => <<"The udp socket options for udp or dtls listener">>
|
||||||
})}
|
})}
|
||||||
, {dtls,
|
, {dtls,
|
||||||
mk(ref(dtls_listener_opts),
|
mk(ref(dtls_listener_opts),
|
||||||
#{ required => {false, recursively}
|
#{ required => {false, recursively}
|
||||||
, description => <<"The dtls socket options for dtls listener">>
|
, desc => <<"The dtls socket options for dtls listener">>
|
||||||
})}
|
})}
|
||||||
];
|
];
|
||||||
fields(tcp_listener_opts) ->
|
fields(tcp_listener_opts) ->
|
||||||
|
@ -530,47 +530,47 @@ common_listener_opts() ->
|
||||||
[ {enable,
|
[ {enable,
|
||||||
mk(boolean(),
|
mk(boolean(),
|
||||||
#{ required => false
|
#{ required => false
|
||||||
, description => <<"Whether to enable this listener">>})}
|
, desc => <<"Whether to enable this listener">>})}
|
||||||
, {id,
|
, {id,
|
||||||
mk(binary(),
|
mk(binary(),
|
||||||
#{ required => false
|
#{ required => false
|
||||||
, description => <<"Listener Id">>})}
|
, desc => <<"Listener Id">>})}
|
||||||
, {name,
|
, {name,
|
||||||
mk(binary(),
|
mk(binary(),
|
||||||
#{ required => false
|
#{ required => false
|
||||||
, description => <<"Listener name">>})}
|
, desc => <<"Listener name">>})}
|
||||||
, {type,
|
, {type,
|
||||||
mk(hoconsc:enum([tcp, ssl, udp, dtls]),
|
mk(hoconsc:enum([tcp, ssl, udp, dtls]),
|
||||||
#{ required => false
|
#{ required => false
|
||||||
, description => <<"Listener type. Enum: tcp, udp, ssl, dtls">>})}
|
, desc => <<"Listener type. Enum: tcp, udp, ssl, dtls">>})}
|
||||||
, {running,
|
, {running,
|
||||||
mk(boolean(),
|
mk(boolean(),
|
||||||
#{ required => false
|
#{ required => false
|
||||||
, description => <<"Listener running status">>})}
|
, desc => <<"Listener running status">>})}
|
||||||
, {bind,
|
, {bind,
|
||||||
mk(binary(),
|
mk(binary(),
|
||||||
#{ required => false
|
#{ required => false
|
||||||
, description => <<"Listener bind address or port">>})}
|
, desc => <<"Listener bind address or port">>})}
|
||||||
, {acceptors,
|
, {acceptors,
|
||||||
mk(integer(),
|
mk(integer(),
|
||||||
#{ required => false
|
#{ required => false
|
||||||
, description => <<"Listener acceptors number">>})}
|
, desc => <<"Listener acceptors number">>})}
|
||||||
, {access_rules,
|
, {access_rules,
|
||||||
mk(hoconsc:array(binary()),
|
mk(hoconsc:array(binary()),
|
||||||
#{ required => false
|
#{ required => false
|
||||||
, description => <<"Listener Access rules for client">>})}
|
, desc => <<"Listener Access rules for client">>})}
|
||||||
, {max_conn_rate,
|
, {max_conn_rate,
|
||||||
mk(integer(),
|
mk(integer(),
|
||||||
#{ required => false
|
#{ required => false
|
||||||
, description => <<"Max connection rate for the listener">>})}
|
, desc => <<"Max connection rate for the listener">>})}
|
||||||
, {max_connections,
|
, {max_connections,
|
||||||
mk(integer(),
|
mk(integer(),
|
||||||
#{ required => false
|
#{ required => false
|
||||||
, description => <<"Max connections for the listener">>})}
|
, desc => <<"Max connections for the listener">>})}
|
||||||
, {mountpoint,
|
, {mountpoint,
|
||||||
mk(binary(),
|
mk(binary(),
|
||||||
#{ required => false
|
#{ required => false
|
||||||
, description =>
|
, desc =>
|
||||||
<<"The Mounpoint for clients of the listener. "
|
<<"The Mounpoint for clients of the listener. "
|
||||||
"The gateway-level mountpoint configuration can be overloaded "
|
"The gateway-level mountpoint configuration can be overloaded "
|
||||||
"when it is not null or empty string">>})}
|
"when it is not null or empty string">>})}
|
||||||
|
@ -578,7 +578,7 @@ common_listener_opts() ->
|
||||||
, {authentication,
|
, {authentication,
|
||||||
mk(emqx_authn_schema:authenticator_type(),
|
mk(emqx_authn_schema:authenticator_type(),
|
||||||
#{ required => {false, recursively}
|
#{ required => {false, recursively}
|
||||||
, description => <<"The authenticatior for this listener">>
|
, desc => <<"The authenticatior for this listener">>
|
||||||
})}
|
})}
|
||||||
] ++ emqx_gateway_schema:proxy_protocol_opts().
|
] ++ emqx_gateway_schema:proxy_protocol_opts().
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ schema(?PATH("/lookup_cmd")) ->
|
||||||
'operationId' => lookup_cmd,
|
'operationId' => lookup_cmd,
|
||||||
get => #{
|
get => #{
|
||||||
tags => [<<"lwm2m">>],
|
tags => [<<"lwm2m">>],
|
||||||
description => <<"Look up resource">>,
|
desc => <<"Look up resource">>,
|
||||||
parameters => [
|
parameters => [
|
||||||
{clientid, mk(binary(), #{in => path, example => "urn:oma:lwm2m:oma:2"})},
|
{clientid, mk(binary(), #{in => path, example => "urn:oma:lwm2m:oma:2"})},
|
||||||
{path, mk(binary(), #{in => query, required => true, example => "/3/0/7"})},
|
{path, mk(binary(), #{in => query, required => true, example => "/3/0/7"})},
|
||||||
|
@ -66,7 +66,7 @@ schema(?PATH("/observe")) ->
|
||||||
'operationId' => observe,
|
'operationId' => observe,
|
||||||
post => #{
|
post => #{
|
||||||
tags => [<<"lwm2m">>],
|
tags => [<<"lwm2m">>],
|
||||||
description => <<"(cancel) observe resource">>,
|
desc => <<"(cancel) observe resource">>,
|
||||||
parameters => [
|
parameters => [
|
||||||
{clientid, mk(binary(), #{in => path, example => "urn:oma:lwm2m:oma:2"})},
|
{clientid, mk(binary(), #{in => path, example => "urn:oma:lwm2m:oma:2"})},
|
||||||
{path, mk(binary(), #{in => query, required => true, example => "/3/0/7"})},
|
{path, mk(binary(), #{in => query, required => true, example => "/3/0/7"})},
|
||||||
|
@ -84,7 +84,7 @@ schema(?PATH("/read")) ->
|
||||||
'operationId' => read,
|
'operationId' => read,
|
||||||
post => #{
|
post => #{
|
||||||
tags => [<<"lwm2m">>],
|
tags => [<<"lwm2m">>],
|
||||||
description => <<"Send a read command to resource">>,
|
desc => <<"Send a read command to resource">>,
|
||||||
parameters => [
|
parameters => [
|
||||||
{clientid, mk(binary(), #{in => path, example => "urn:oma:lwm2m:oma:2"})},
|
{clientid, mk(binary(), #{in => path, example => "urn:oma:lwm2m:oma:2"})},
|
||||||
{path, mk(binary(), #{in => query, required => true, example => "/3/0/7"})}
|
{path, mk(binary(), #{in => query, required => true, example => "/3/0/7"})}
|
||||||
|
@ -99,7 +99,7 @@ schema(?PATH("/write")) ->
|
||||||
#{
|
#{
|
||||||
'operationId' => write,
|
'operationId' => write,
|
||||||
post => #{
|
post => #{
|
||||||
description => <<"Send a write command to resource">>,
|
desc => <<"Send a write command to resource">>,
|
||||||
tags => [<<"lwm2m">>],
|
tags => [<<"lwm2m">>],
|
||||||
parameters => [
|
parameters => [
|
||||||
{clientid, mk(binary(), #{in => path, example => "urn:oma:lwm2m:oma:2"})},
|
{clientid, mk(binary(), #{in => path, example => "urn:oma:lwm2m:oma:2"})},
|
||||||
|
@ -117,11 +117,11 @@ schema(?PATH("/write")) ->
|
||||||
|
|
||||||
fields(resource) ->
|
fields(resource) ->
|
||||||
[
|
[
|
||||||
{operations, mk(binary(), #{description => <<"Resource Operations">>, example => "E"})},
|
{operations, mk(binary(), #{desc => <<"Resource Operations">>, example => "E"})},
|
||||||
{'dataType', mk(hoconsc:enum(?DATA_TYPE), #{description => <<"Data Type">>,
|
{'dataType', mk(hoconsc:enum(?DATA_TYPE), #{desc => <<"Data Type">>,
|
||||||
example => 'Integer'})},
|
example => 'Integer'})},
|
||||||
{path, mk(binary(), #{description => <<"Resource Path">>, example => "urn:oma:lwm2m:oma:2"})},
|
{path, mk(binary(), #{desc => <<"Resource Path">>, example => "urn:oma:lwm2m:oma:2"})},
|
||||||
{name, mk(binary(), #{description => <<"Resource Name">>, example => "lwm2m-test"})}
|
{name, mk(binary(), #{desc => <<"Resource Name">>, example => "lwm2m-test"})}
|
||||||
].
|
].
|
||||||
|
|
||||||
lookup_cmd(get, #{bindings := Bindings, query_string := QS}) ->
|
lookup_cmd(get, #{bindings := Bindings, query_string := QS}) ->
|
||||||
|
|
|
@ -129,8 +129,13 @@ settings(get, _) ->
|
||||||
{200, emqx:get_raw_config([slow_subs], #{})};
|
{200, emqx:get_raw_config([slow_subs], #{})};
|
||||||
|
|
||||||
settings(put, #{body := Body}) ->
|
settings(put, #{body := Body}) ->
|
||||||
_ = emqx_slow_subs:update_settings(Body),
|
case emqx_slow_subs:update_settings(Body) of
|
||||||
{200, emqx:get_raw_config([slow_subs], #{})}.
|
{ok, NewConf} ->
|
||||||
|
{200, NewConf};
|
||||||
|
{error, Reason} ->
|
||||||
|
Message = list_to_binary(io_lib:format("Update slow subs config failed ~p", [Reason])),
|
||||||
|
{400, 'BAD_REQUEST', Message}
|
||||||
|
end.
|
||||||
|
|
||||||
rpc_call(Fun) ->
|
rpc_call(Fun) ->
|
||||||
Nodes = mria_mnesia:running_nodes(),
|
Nodes = mria_mnesia:running_nodes(),
|
||||||
|
|
Loading…
Reference in New Issue