fix: add alarms & banned desc

This commit is contained in:
DDDHuang 2022-04-18 20:11:21 +08:00
parent ac1bdee3ee
commit 17aa81a04f
6 changed files with 227 additions and 85 deletions

View File

@ -59,8 +59,8 @@ Retain Handling is equal to 2, even if the client successfully subscribes, the s
rap {
desc {
en: """Default value 0. This option is used to specify whether the server retains the RETAIN mark when forwarding messages to the client, and this option does not affect the RETAIN mark in the retained message. Therefore, when the option Retain As Publish is set to 0, the client will directly distinguish whether this is a normal forwarded message or a retained message according to the RETAIN mark in the message, instead of judging whether this message is the first received after subscribing(the forwarded message may be sent before the retained message, which depends on the specific implementation of different brokers)."
zh: "缺省值为 0这一选项用来指定服务端向客户端转发消息时是否要保留其中的 RETAIN 标识,注意这一选项不会影响保留消息中的 RETAIN 标识。因此当 Retain As Publish 选项被设置为 0 时,客户端直接依靠消息中的 RETAIN 标识来区分这是一个正常的转发消息还是一个保留消息,而不是去判断消息是否是自己订阅后收到的第一个消息(转发消息甚至可能会先于保留消息被发送,视不同 Broker 的具体实现而定)。"
en: """Default value 0. This option is used to specify whether the server retains the RETAIN mark when forwarding messages to the client, and this option does not affect the RETAIN mark in the retained message. Therefore, when the option Retain As Publish is set to 0, the client will directly distinguish whether this is a normal forwarded message or a retained message according to the RETAIN mark in the message, instead of judging whether this message is the first received after subscribing(the forwarded message may be sent before the retained message, which depends on the specific implementation of different brokers)."""
zh: """缺省值为 0这一选项用来指定服务端向客户端转发消息时是否要保留其中的 RETAIN 标识,注意这一选项不会影响保留消息中的 RETAIN 标识。因此当 Retain As Publish 选项被设置为 0 时,客户端直接依靠消息中的 RETAIN 标识来区分这是一个正常的转发消息还是一个保留消息,而不是去判断消息是否是自己订阅后收到的第一个消息(转发消息甚至可能会先于保留消息被发送,视不同 Broker 的具体实现而定)。"""
}
label {
en: """Retain As Publish"""
@ -78,8 +78,8 @@ MQTT v3.1.1:如果设备订阅了自己发布消息的主题,那么将收到
MQTT v5如果设备在订阅时将此选项设置为 1那么服务端将不会向设备转发自己发布的消息"""
}
label {
en: """No Local """
zh: """No Local """
en: """No Local"""
zh: """No Local"""
}
}
}

View File

@ -1,54 +0,0 @@
emqx_management {
banned {
as {
desc {
en: """Banned type clientid, username, peerhost"""
zh: """黑名单类型,可选 clientid、username、peerhost"""
}
label {
en: """Banned Type"""
zh: """黑名单类型"""
}
}
who {
desc {
en: """Client info as banned type"""
zh: """设备信息"""
}
label {
en: """Banned Info"""
zh: """黑名单信息"""
}
}
by {
desc {
en: """Commander"""
zh: """黑名单创建者"""
}
label {
en: """Commander"""
zh: """黑名单创建者"""
}
}
at {
desc {
en: """Create banned time, rfc3339, now if not specified"""
zh: """黑名单创建时间,默认为当前"""
}
label {
en: """Create banned time"""
zh: """黑名单创建时间"""
}
}
until {
desc {
en: """Cancel banned time, rfc3339, now + 5 minute if not specified"""
zh: """黑名单结束时间,默认为创建时间 + 5 分钟"""
}
label {
en: """Cancel banned time"""
zh: """黑名单结束时间"""
}
}
}
}

View File

@ -0,0 +1,80 @@
emqx_mgmt_api_alarms {
list_alarms_api {
desc {
en: """List alarms"""
zh: """列出告警,获取告警列表"""
}
}
delete_alarms_api {
desc {
en: """Remove all deactivated alarms"""
zh: """删除所有历史告警(非活跃告警)"""
}
}
delete_alarms_api_response_200 {
desc {
en: """Remove all deactivated alarms ok"""
zh: """删除所有历史告警(非活跃告警)成功"""
}
}
get_alarms_qs_activated {
desc {
en: """Activate alarms, or deactivate alarms. Default is false"""
zh: """活跃中的告警,或历史告警(非活跃告警),默认为 false"""
}
}
node {
desc {
en: """Alarm in node"""
zh: """告警节点名称"""
}
}
name {
desc {
en: """Alarm name"""
zh: """告警名称"""
}
}
message {
desc {
en: """Alarm readable information"""
zh: """告警信息"""
}
}
details {
desc {
en: """Alarm details information"""
zh: """告警详细信息"""
}
}
duration {
desc {
en: """Alarms duration time; UNIX time stamp, millisecond"""
zh: """告警持续时间,单位:毫秒"""
}
}
activate_at {
desc {
en: """Alarms activate time, RFC 3339"""
zh: """告警开始时间,使用 rfc3339 标准时间格式"""
}
}
deactivate_at {
desc {
en: """Alarms deactivate time, RFC 3339"""
zh: """告警结束时间,使用 rfc3339 标准时间格式"""
}
}
}

View File

@ -0,0 +1,113 @@
emqx_mgmt_api_banned {
list_banned_api {
desc {
en: """List banned."""
zh: """列出黑名单"""
}
label {
en: """List Banned"""
zh: """列出黑名单"""
}
}
create_banned_api {
desc {
en: """Create banned."""
zh: """创建黑名单"""
}
}
create_banned_api_response_400 {
desc {
en: """Banned already existed, or bad args."""
zh: """黑名单已存在,或错误的参数"""
}
}
delete_banned_api {
desc {
en: """Delete banned"""
zh: """删除黑名单"""
}
}
delete_banned_api_response_400 {
desc {
en: """Banned not found. May be the banned time has been exceeded"""
zh: """黑名单未找到,可能为已经超期失效"""
}
}
create_banned {
desc {
en: """List banned."""
zh: """列出黑名单"""
}
label {
en: """List Banned"""
zh: """列出黑名单"""
}
}
as {
desc {
en: """Banned type clientid, username, peerhost"""
zh: """黑名单类型,可选 clientid、username、peerhost"""
}
label {
en: """Banned Type"""
zh: """黑名单类型"""
}
}
who {
desc {
en: """Client info as banned type"""
zh: """设备信息"""
}
label {
en: """Banned Info"""
zh: """黑名单信息"""
}
}
by {
desc {
en: """Commander"""
zh: """黑名单创建者"""
}
label {
en: """Commander"""
zh: """黑名单创建者"""
}
}
reason {
desc {
en: """Banned reason"""
zh: """黑名单创建原因"""
}
label {
en: """Reason"""
zh: """原因"""
}
}
at {
desc {
en: """Create banned time, rfc3339, now if not specified"""
zh: """黑名单创建时间,默认为当前"""
}
label {
en: """Create banned time"""
zh: """黑名单创建时间"""
}
}
until {
desc {
en: """Cancel banned time, rfc3339, now + 5 minute if not specified"""
zh: """黑名单结束时间,默认为创建时间 + 5 分钟"""
}
label {
en: """Cancel banned time"""
zh: """黑名单结束时间"""
}
}
}

View File

@ -18,6 +18,7 @@
-behaviour(minirest_api).
-include_lib("hocon/include/hoconsc.hrl").
-include_lib("emqx/include/emqx.hrl").
-include_lib("typerefl/include/types.hrl").
@ -38,12 +39,12 @@ schema("/alarms") ->
#{
'operationId' => alarms,
get => #{
description => <<"EMQX alarms">>,
description => ?DESC(list_alarms_api),
parameters => [
hoconsc:ref(emqx_dashboard_swagger, page),
hoconsc:ref(emqx_dashboard_swagger, limit),
{activated, hoconsc:mk(boolean(), #{in => query,
desc => <<"All alarms, if not specified">>,
desc => ?DESC(get_alarms_qs_activated),
required => false})}
],
responses => #{
@ -54,9 +55,9 @@ schema("/alarms") ->
}
},
delete => #{
description => <<"Remove all deactivated alarms">>,
description => ?DESC(delete_alarms_api),
responses => #{
204 => <<"Remove all deactivated alarms ok">>
204 => ?DESC(delete_alarms_api_response_200)
}
}
}.
@ -64,20 +65,17 @@ schema("/alarms") ->
fields(alarm) ->
[
{node, hoconsc:mk(binary(),
#{desc => <<"Alarm in node">>, example => atom_to_list(node())})},
#{desc => ?DESC(node), example => atom_to_list(node())})},
{name, hoconsc:mk(binary(),
#{desc => <<"Alarm name">>, example => <<"high_system_memory_usage">>})},
{message, hoconsc:mk(binary(), #{desc => <<"Alarm readable information">>,
#{desc => ?DESC(node), example => <<"high_system_memory_usage">>})},
{message, hoconsc:mk(binary(), #{desc => desc => ?DESC(message),
example => <<"System memory usage is higher than 70%">>})},
{details, hoconsc:mk(map(), #{desc => <<"Alarm details information">>,
{details, hoconsc:mk(map(), #{desc => ?DESC(details),
example => #{<<"high_watermark">> => 70}})},
{duration, hoconsc:mk(integer(),
#{desc => <<"Alarms duration time; UNIX time stamp, millisecond">>,
example => 297056})},
{activate_at, hoconsc:mk(binary(), #{desc => <<"Alarms activate time, RFC 3339">>,
{duration, hoconsc:mk(integer(), #{desc => ?DESC(duration), example => 297056})},
{activate_at, hoconsc:mk(binary(), #{desc => ?DESC(activate_at),
example => <<"2021-10-25T11:52:52.548+08:00">>})},
{deactivate_at, hoconsc:mk(binary(),
#{desc => <<"Nullable, alarms deactivate time, RFC 3339">>,
{deactivate_at, hoconsc:mk(binary(), #{desc => ?DESC(deactivate_at),
example => <<"2021-10-31T10:52:52.548+08:00">>})}
];

View File

@ -16,6 +16,7 @@
-module(emqx_mgmt_api_banned).
-include_lib("hocon/include/hoconsc.hrl").
-include_lib("emqx/include/emqx.hrl").
-include_lib("typerefl/include/types.hrl").
@ -50,7 +51,7 @@ schema("/banned") ->
#{
'operationId' => banned,
get => #{
description => <<"List banned">>,
description => ?DESC(list_banned_api),
parameters => [
hoconsc:ref(emqx_dashboard_swagger, page),
hoconsc:ref(emqx_dashboard_swagger, limit)
@ -63,13 +64,15 @@ schema("/banned") ->
}
},
post => #{
description => <<"Create banned">>,
description => ?DESC(create_banned_api),
'requestBody' => hoconsc:mk(hoconsc:ref(ban)),
responses => #{
200 => [{data, hoconsc:mk(hoconsc:array(hoconsc:ref(ban)), #{})}],
400 => emqx_dashboard_swagger:error_codes(
['ALREADY_EXISTS', 'BAD_REQUEST'],
<<"Banned already existed, or bad args">>)
""
?DESC(create_banned_api_response_400)
)
}
}
};
@ -77,14 +80,14 @@ schema("/banned/:as/:who") ->
#{
'operationId' => delete_banned,
delete => #{
description => <<"Delete banned">>,
description => ?DESC(delete_banned_api),
parameters => [
{as, hoconsc:mk(hoconsc:enum(?BANNED_TYPES), #{
desc => <<"Banned type">>,
desc => ?DESC(as),
in => path,
example => username})},
{who, hoconsc:mk(binary(), #{
desc => <<"Client info as banned type">>,
desc => ?DESC(who),
in => path,
example => <<"Badass">>})}
],
@ -92,7 +95,9 @@ schema("/banned/:as/:who") ->
204 => <<"Delete banned success">>,
404 => emqx_dashboard_swagger:error_codes(
['NOT_FOUND'],
<<"Banned not found. May be the banned time has been exceeded">>)
""
?DESC(delete_banned_api_response_400)
)
}
}
}.
@ -100,27 +105,27 @@ schema("/banned/:as/:who") ->
fields(ban) ->
[
{as, hoconsc:mk(hoconsc:enum(?BANNED_TYPES), #{
desc => <<"Banned type clientid, username, peerhost">>,
desc => ?DESC(as),
required => true,
example => username})},
{who, hoconsc:mk(binary(), #{
desc => <<"Client info as banned type">>,
desc => ?DESC(who),
required => true,
example => <<"Banned name"/utf8>>})},
{by, hoconsc:mk(binary(), #{
desc => <<"Commander">>,
desc => ?DESC(by),
required => false,
example => <<"mgmt_api">>})},
{reason, hoconsc:mk(binary(), #{
desc => <<"Banned reason">>,
desc => ?DESC(reason),
required => false,
example => <<"Too many requests">>})},
{at, hoconsc:mk(emqx_datetime:epoch_second(), #{
desc => <<"Create banned time, rfc3339, now if not specified">>,
desc => ?DESC(at),
required => false,
example => <<"2021-10-25T21:48:47+08:00">>})},
{until, hoconsc:mk(emqx_datetime:epoch_second(), #{
desc => <<"Cancel banned time, rfc3339, now + 5 minute if not specified">>,
desc => ?DESC(until),
required => false,
example => <<"2021-10-25T21:53:47+08:00">>})
}