Merge pull request #7704 from EMQ-YangM/bridge_docs
feat: emqx_bridges i18n support
This commit is contained in:
commit
a156933841
|
@ -0,0 +1,137 @@
|
||||||
|
emqx_bridge_api {
|
||||||
|
|
||||||
|
desc_param_path_operation_cluster {
|
||||||
|
desc {
|
||||||
|
en: """Operations can be one of: enable, disable, start, stop, restart"""
|
||||||
|
zh: """集群可用操作:启用、禁用、启动、停止、重新启动"""
|
||||||
|
}
|
||||||
|
label: {
|
||||||
|
en: "Cluster Operation"
|
||||||
|
zh: "集群可用操作"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
desc_param_path_operation_on_node {
|
||||||
|
desc {
|
||||||
|
en: """Operations can be one of: start, stop, restart"""
|
||||||
|
zh: """节点可用操作:启动、停止、重新启动"""
|
||||||
|
}
|
||||||
|
label: {
|
||||||
|
en: "Node Operation "
|
||||||
|
zh: "节点可用操作"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
desc_param_path_node {
|
||||||
|
desc {
|
||||||
|
en: """The bridge Id. Must be of format {type}:{name}"""
|
||||||
|
zh: """Bridge ID , 格式为 {type}:{name}"""
|
||||||
|
}
|
||||||
|
label: {
|
||||||
|
en: "Bridge ID"
|
||||||
|
zh: "Bridge ID"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
desc_param_path_id {
|
||||||
|
desc {
|
||||||
|
en: """The bridge Id. Must be of format {type}:{name}"""
|
||||||
|
zh: """Bridge ID , 格式为 {type}:{name}"""
|
||||||
|
}
|
||||||
|
label: {
|
||||||
|
en: "Bridge ID"
|
||||||
|
zh: "Bridge ID"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
desc_api1 {
|
||||||
|
desc {
|
||||||
|
en: """List all created bridges"""
|
||||||
|
zh: """列出所有 Birdge """
|
||||||
|
}
|
||||||
|
label: {
|
||||||
|
en: "List All Bridges"
|
||||||
|
zh: "列出所有 Bridge"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
desc_api2 {
|
||||||
|
desc {
|
||||||
|
en: """Create a new bridge by type and name"""
|
||||||
|
zh: """通过类型和名字创建 Bridge"""
|
||||||
|
}
|
||||||
|
label: {
|
||||||
|
en: "Create Bridge"
|
||||||
|
zh: "创建 Bridge"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
desc_api3 {
|
||||||
|
desc {
|
||||||
|
en: """Get a bridge by Id"""
|
||||||
|
zh: """通过 ID 获取 Bridge"""
|
||||||
|
}
|
||||||
|
label: {
|
||||||
|
en: "Get Bridge"
|
||||||
|
zh: "获取 Bridge"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
desc_api4 {
|
||||||
|
desc {
|
||||||
|
en: """Update a bridge by Id"""
|
||||||
|
zh: """通过 ID 更新 Bridge"""
|
||||||
|
}
|
||||||
|
label: {
|
||||||
|
en: "Update Bridge"
|
||||||
|
zh: "更新 Bridge"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
desc_api5 {
|
||||||
|
desc {
|
||||||
|
en: """Delete a bridge by Id"""
|
||||||
|
zh: """通过 ID 删除 Bridge"""
|
||||||
|
}
|
||||||
|
label: {
|
||||||
|
en: "Delete Bridge"
|
||||||
|
zh: "删除 Bridge"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
desc_api6 {
|
||||||
|
desc {
|
||||||
|
en: """Reset a bridge metrics by Id"""
|
||||||
|
zh: """通过 ID 重置 Bridge 的计数"""
|
||||||
|
}
|
||||||
|
label: {
|
||||||
|
en: "Reset Bridge Metrics"
|
||||||
|
zh: "重置 Bridge 计数"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
desc_api7 {
|
||||||
|
desc {
|
||||||
|
en: """Enable/Disable/Stop/Restart bridges on all nodes in the cluster."""
|
||||||
|
zh: """在集群中的所有节点上启用/禁用/停止/重新启动 Bridge。"""
|
||||||
|
}
|
||||||
|
label: {
|
||||||
|
en: "Cluster Bridge Operate"
|
||||||
|
zh: "集群 Bridge 操作"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
desc_api8 {
|
||||||
|
desc {
|
||||||
|
en: """Stop/Restart bridges on a specific node.
|
||||||
|
NOTE: It's not allowed to disable/enable bridges on a single node."""
|
||||||
|
zh: """在某个节点上停止/重新启动 Bridge。
|
||||||
|
NOTE:不允许在单节点上启用/禁用 Bridge"""
|
||||||
|
}
|
||||||
|
label: {
|
||||||
|
en: "Node Bridge Operate"
|
||||||
|
zh: "单节点 Bridge 操作"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,163 @@
|
||||||
|
emqx_bridge_http_schema {
|
||||||
|
|
||||||
|
config_enable {
|
||||||
|
desc {
|
||||||
|
en: """Enable or disable this bridge"""
|
||||||
|
zh: """启用/禁用 Bridge"""
|
||||||
|
}
|
||||||
|
label: {
|
||||||
|
en: "Enable Or Disable Bridge"
|
||||||
|
zh: "启用/禁用 Bridge"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
config_direction {
|
||||||
|
desc {
|
||||||
|
en: """The direction of this bridge, MUST be 'egress'"""
|
||||||
|
zh: """Bridge 的方向, 必须是 egress"""
|
||||||
|
}
|
||||||
|
label: {
|
||||||
|
en: "Bridge Direction"
|
||||||
|
zh: "Bridge 方向"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
config_url {
|
||||||
|
desc {
|
||||||
|
en: """
|
||||||
|
The URL of the HTTP Bridge.<br>
|
||||||
|
Template with variables is allowed in the path, but variables cannot be used in the scheme, host,
|
||||||
|
or port part.<br>
|
||||||
|
For example, <code> http://localhost:9901/${topic} </code> is allowed, but
|
||||||
|
<code> http://${host}:9901/message </code> or <code> http://localhost:${port}/message </code>
|
||||||
|
is not allowed.
|
||||||
|
"""
|
||||||
|
zh: """
|
||||||
|
HTTP Bridge 的 URL。<br>
|
||||||
|
路径中允许使用带变量的模板,但是 host, port 不允许使用变量模板。<br>
|
||||||
|
例如,<code> http://localhost:9901/${topic} </code> 是允许的,
|
||||||
|
但是<code> http://${host}:9901/message </code>
|
||||||
|
或 <code> http://localhost:${port}/message </code>
|
||||||
|
不允许。
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
label: {
|
||||||
|
en: "HTTP Bridge"
|
||||||
|
zh: "HTTP Bridge"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
config_local_topic {
|
||||||
|
desc {
|
||||||
|
en: """
|
||||||
|
The MQTT topic filter to be forwarded to the HTTP server. All MQTT 'PUBLISH' messages with the topic
|
||||||
|
matching the local_topic will be forwarded.<br/>
|
||||||
|
NOTE: if this bridge is used as the output of a rule (EMQX rule engine), and also local_topic is
|
||||||
|
configured, then both the data got from the rule and the MQTT messages that match local_topic
|
||||||
|
will be forwarded.
|
||||||
|
"""
|
||||||
|
zh: """
|
||||||
|
发送到 'local_topic' 的消息都会转发到 HTTP 服务器。 <br/>
|
||||||
|
注意:如果这个 Bridge 被用作规则(EMQX 规则引擎)的输出,同时也配置了 'local_topic' ,那么这两部分的消息都会被转发到 HTTP 服务器。
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
label: {
|
||||||
|
en: "Local Topic"
|
||||||
|
zh: "本地 Topic"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
config_method {
|
||||||
|
desc {
|
||||||
|
en: """
|
||||||
|
The method of the HTTP request. All the available methods are: post, put, get, delete.<br>
|
||||||
|
Template with variables is allowed.<br>
|
||||||
|
"""
|
||||||
|
zh: """
|
||||||
|
HTTP 请求的方法。 所有可用的方法包括:post、put、get、delete。<br>
|
||||||
|
允许使用带有变量的模板。<br>"""
|
||||||
|
}
|
||||||
|
label: {
|
||||||
|
en: "HTTP Method"
|
||||||
|
zh: "HTTP 请求方法"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
config_headers {
|
||||||
|
desc {
|
||||||
|
en: """
|
||||||
|
The headers of the HTTP request.<br>
|
||||||
|
Template with variables is allowed.
|
||||||
|
"""
|
||||||
|
zh: """
|
||||||
|
HTTP 请求的标头。<br>
|
||||||
|
允许使用带有变量的模板。
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
label: {
|
||||||
|
en: "HTTP Header"
|
||||||
|
zh: "HTTP 请求标头"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
config_body {
|
||||||
|
desc {
|
||||||
|
en: """
|
||||||
|
The body of the HTTP request.<br>
|
||||||
|
Template with variables is allowed.
|
||||||
|
"""
|
||||||
|
zh: """
|
||||||
|
HTTP 请求的正文。<br>
|
||||||
|
允许使用带有变量的模板。"""
|
||||||
|
}
|
||||||
|
label: {
|
||||||
|
en: "HTTP Body"
|
||||||
|
zh: "HTTP 请求正文"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
config_request_timeout {
|
||||||
|
desc {
|
||||||
|
en: """HTTP request timeout."""
|
||||||
|
zh: """HTTP 请求超时"""
|
||||||
|
}
|
||||||
|
label: {
|
||||||
|
en: "HTTP Request Timeout"
|
||||||
|
zh: "HTTP 请求超时"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
desc_type {
|
||||||
|
desc {
|
||||||
|
en: """The Bridge Type"""
|
||||||
|
zh: """Bridge 类型"""
|
||||||
|
}
|
||||||
|
label: {
|
||||||
|
en: "Bridge Type"
|
||||||
|
zh: "Bridge 类型"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
desc_name {
|
||||||
|
desc {
|
||||||
|
en: """Bridge name, used as a human-readable description of the bridge."""
|
||||||
|
zh: """Bridge 名字,Bridge 的可读描述"""
|
||||||
|
}
|
||||||
|
label: {
|
||||||
|
en: "Bridge Name"
|
||||||
|
zh: "Bridge 名字"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
desc_config {
|
||||||
|
desc {
|
||||||
|
en: """Configuration for an HTTP bridge."""
|
||||||
|
zh: """HTTP Bridge 配置"""
|
||||||
|
}
|
||||||
|
label: {
|
||||||
|
en: "HTTP Bridge Configuration"
|
||||||
|
zh: "HTTP Bridge 配置"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
emqx_bridge_mqtt_schema {
|
||||||
|
|
||||||
|
desc_rec {
|
||||||
|
desc {
|
||||||
|
en: """Configuration for MQTT bridge."""
|
||||||
|
zh: """MQTT Bridge 配置"""
|
||||||
|
}
|
||||||
|
label: {
|
||||||
|
en: "MQTT Bridge Configuration"
|
||||||
|
zh: "MQTT Bridge 配置"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
desc_type {
|
||||||
|
desc {
|
||||||
|
en: """The bridge type."""
|
||||||
|
zh: """Bridge 的类型"""
|
||||||
|
}
|
||||||
|
label: {
|
||||||
|
en: "Bridge Type"
|
||||||
|
zh: "Bridge 类型"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
desc_name {
|
||||||
|
desc {
|
||||||
|
en: """Bridge name, used as a human-readable description of the bridge."""
|
||||||
|
zh: """Bridge 名字,Bridge 的可读描述"""
|
||||||
|
}
|
||||||
|
label: {
|
||||||
|
en: "Bridge Name"
|
||||||
|
zh: "Bridge 名字"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,219 @@
|
||||||
|
emqx_bridge_schema {
|
||||||
|
|
||||||
|
desc_enable {
|
||||||
|
desc {
|
||||||
|
en: """Enable or disable this bridge"""
|
||||||
|
zh: """启用/禁用 Bridge"""
|
||||||
|
}
|
||||||
|
label: {
|
||||||
|
en: "Enable Or Disable Bridge"
|
||||||
|
zh: "启用/禁用 Bridge"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
desc_connector {
|
||||||
|
desc {
|
||||||
|
en: """
|
||||||
|
The connector ID to be used for this bridge. Connector IDs must be of format:
|
||||||
|
<code>{type}:{name}</code>.<br>
|
||||||
|
In config files, you can find the corresponding config entry for a connector by such path:
|
||||||
|
'connectors.{type}.{name}'.<br>
|
||||||
|
"""
|
||||||
|
zh: """Bridge 使用的 Connector 的 ID。Connector ID 的格式必须为:<code>{type}:{name}</code>.<br>
|
||||||
|
在配置文件中,您可以通过以下路径找到 Connector 的相应配置条目:'connector.{type}.{name}'。<br>"""
|
||||||
|
}
|
||||||
|
label: {
|
||||||
|
en: "Connector ID"
|
||||||
|
zh: "Connector ID"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
desc_metrics {
|
||||||
|
desc {
|
||||||
|
en: """The metrics of the bridge"""
|
||||||
|
zh: """Bridge 的计数"""
|
||||||
|
}
|
||||||
|
label: {
|
||||||
|
en: "Bridge Metrics"
|
||||||
|
zh: "Bridge 计数"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
desc_node_metrics {
|
||||||
|
desc {
|
||||||
|
en: """The metrics of the bridge for each node"""
|
||||||
|
zh: """每个节点的 Bridge 计数"""
|
||||||
|
}
|
||||||
|
label: {
|
||||||
|
en: "Each Node Bridge Metircs"
|
||||||
|
zh: "每个节点的 Bridge 计数"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
desc_status {
|
||||||
|
desc {
|
||||||
|
en: """The status of the bridge"""
|
||||||
|
zh: """Bridge 的状态"""
|
||||||
|
}
|
||||||
|
label: {
|
||||||
|
en: "Bridge Status"
|
||||||
|
zh: "Bridge 状态"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
desc_node_status {
|
||||||
|
desc {
|
||||||
|
en: """The status of the bridge for each node"""
|
||||||
|
zh: """每个节点的 Bridge 状态"""
|
||||||
|
}
|
||||||
|
label: {
|
||||||
|
en: "Node Bridge Status"
|
||||||
|
zh: "每个节点的 Bridge 状态"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bridges_http {
|
||||||
|
desc {
|
||||||
|
en: """HTTP bridges to an HTTP server."""
|
||||||
|
zh: """转发消息到 HTTP 服务器的 HTTP Bridge"""
|
||||||
|
}
|
||||||
|
label: {
|
||||||
|
en: "HTTP Bridge"
|
||||||
|
zh: "HTTP Bridge"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bridges_name {
|
||||||
|
desc {
|
||||||
|
en: """MQTT bridges to/from another MQTT broker"""
|
||||||
|
zh: """桥接到另一个 MQTT Broker 的 MQTT Bridge"""
|
||||||
|
}
|
||||||
|
label: {
|
||||||
|
en: "MQTT Bridge"
|
||||||
|
zh: "MQTT Bridge"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
metric_matched {
|
||||||
|
desc {
|
||||||
|
en: """Count of this bridge is queried"""
|
||||||
|
zh: """Bridge 执行操作的次数"""
|
||||||
|
}
|
||||||
|
label: {
|
||||||
|
en: "Bridge Matched"
|
||||||
|
zh: "Bridge 执行操作的次数"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
metric_success {
|
||||||
|
desc {
|
||||||
|
en: """Count of query success"""
|
||||||
|
zh: """Bridge 执行操作成功的次数"""
|
||||||
|
}
|
||||||
|
label: {
|
||||||
|
en: "Bridge Success"
|
||||||
|
zh: "Bridge 执行操作成功的次数"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
metric_failed {
|
||||||
|
desc {
|
||||||
|
en: """Count of query failed"""
|
||||||
|
zh: """Bridge 执行操作失败的次数"""
|
||||||
|
}
|
||||||
|
label: {
|
||||||
|
en: "Bridge Failed"
|
||||||
|
zh: "Bridge 执行操作失败的次数"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
metric_rate {
|
||||||
|
desc {
|
||||||
|
en: """The rate of matched, times/second"""
|
||||||
|
zh: """执行操作的速率,次/秒"""
|
||||||
|
}
|
||||||
|
label: {
|
||||||
|
en: "Rate"
|
||||||
|
zh: "速率"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
metric_rate_max {
|
||||||
|
desc {
|
||||||
|
en: """The max rate of matched, times/second"""
|
||||||
|
zh: """执行操作的最大速率,次/秒"""
|
||||||
|
}
|
||||||
|
label: {
|
||||||
|
en: "Max Rate Of Matched"
|
||||||
|
zh: "执行操作的最大速率"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
metric_rate_last5m {
|
||||||
|
desc {
|
||||||
|
en: """The average rate of matched in the last 5 minutes, times/second"""
|
||||||
|
zh: """5 分钟平均速率,次/秒"""
|
||||||
|
}
|
||||||
|
label: {
|
||||||
|
en: "Last 5 Minutes Rate"
|
||||||
|
zh: "5 分钟平均速率"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
desc_bridges {
|
||||||
|
desc {
|
||||||
|
en: """Configuration for MQTT bridges."""
|
||||||
|
zh: """MQTT Bridge 配置"""
|
||||||
|
}
|
||||||
|
label: {
|
||||||
|
en: "MQTT Bridge Configuration"
|
||||||
|
zh: "MQTT Bridge 配置"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
desc_metrics {
|
||||||
|
desc {
|
||||||
|
en: """Bridge metrics."""
|
||||||
|
zh: """Bridge 计数"""
|
||||||
|
}
|
||||||
|
label: {
|
||||||
|
en: "Bridge Metrics"
|
||||||
|
zh: "Bridge 计数"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
desc_node_metrics {
|
||||||
|
desc {
|
||||||
|
en: """Node metrics."""
|
||||||
|
zh: """节点的计数器"""
|
||||||
|
}
|
||||||
|
label: {
|
||||||
|
en: "Node Metrics"
|
||||||
|
zh: "节点的计数器"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
desc_node_status {
|
||||||
|
desc {
|
||||||
|
en: """Node status."""
|
||||||
|
zh: """节点的状态"""
|
||||||
|
}
|
||||||
|
label: {
|
||||||
|
en: "Node Status"
|
||||||
|
zh: "节点的状态"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
desc_node_name {
|
||||||
|
desc {
|
||||||
|
en: """The node name."""
|
||||||
|
zh: """节点的名字"""
|
||||||
|
}
|
||||||
|
label: {
|
||||||
|
en: "Node Name"
|
||||||
|
zh: "节点名字"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -18,6 +18,7 @@
|
||||||
-behaviour(minirest_api).
|
-behaviour(minirest_api).
|
||||||
|
|
||||||
-include_lib("typerefl/include/types.hrl").
|
-include_lib("typerefl/include/types.hrl").
|
||||||
|
-include_lib("hocon/include/hoconsc.hrl").
|
||||||
-include_lib("emqx/include/logger.hrl").
|
-include_lib("emqx/include/logger.hrl").
|
||||||
|
|
||||||
-import(hoconsc, [mk/2, array/1, enum/1]).
|
-import(hoconsc, [mk/2, array/1, enum/1]).
|
||||||
|
@ -96,7 +97,7 @@ param_path_operation_cluster() ->
|
||||||
#{ in => path
|
#{ in => path
|
||||||
, required => true
|
, required => true
|
||||||
, example => <<"start">>
|
, example => <<"start">>
|
||||||
, desc => <<"Operations can be one of: enable, disable, start, stop, restart">>
|
, desc => ?DESC("desc_param_path_operation_cluster")
|
||||||
})}.
|
})}.
|
||||||
|
|
||||||
param_path_operation_on_node() ->
|
param_path_operation_on_node() ->
|
||||||
|
@ -104,7 +105,7 @@ param_path_operation_on_node() ->
|
||||||
#{ in => path
|
#{ in => path
|
||||||
, required => true
|
, required => true
|
||||||
, example => <<"start">>
|
, example => <<"start">>
|
||||||
, desc => <<"Operations can be one of: start, stop, restart">>
|
, desc => ?DESC("desc_param_path_operation_on_node")
|
||||||
})}.
|
})}.
|
||||||
|
|
||||||
param_path_node() ->
|
param_path_node() ->
|
||||||
|
@ -112,7 +113,7 @@ param_path_node() ->
|
||||||
#{ in => path
|
#{ in => path
|
||||||
, required => true
|
, required => true
|
||||||
, example => <<"emqx@127.0.0.1">>
|
, example => <<"emqx@127.0.0.1">>
|
||||||
, desc => <<"The bridge Id. Must be of format {type}:{name}">>
|
, desc => ?DESC("desc_param_path_node")
|
||||||
})}.
|
})}.
|
||||||
|
|
||||||
param_path_id() ->
|
param_path_id() ->
|
||||||
|
@ -120,7 +121,7 @@ param_path_id() ->
|
||||||
#{ in => path
|
#{ in => path
|
||||||
, required => true
|
, required => true
|
||||||
, example => <<"http:my_http_bridge">>
|
, example => <<"http:my_http_bridge">>
|
||||||
, desc => <<"The bridge Id. Must be of format {type}:{name}">>
|
, desc => ?DESC("desc_param_path_id")
|
||||||
})}.
|
})}.
|
||||||
|
|
||||||
bridge_info_array_example(Method) ->
|
bridge_info_array_example(Method) ->
|
||||||
|
@ -227,7 +228,7 @@ schema("/bridges") ->
|
||||||
get => #{
|
get => #{
|
||||||
tags => [<<"bridges">>],
|
tags => [<<"bridges">>],
|
||||||
summary => <<"List Bridges">>,
|
summary => <<"List Bridges">>,
|
||||||
description => <<"List all created bridges">>,
|
description => ?DESC("desc_api1"),
|
||||||
responses => #{
|
responses => #{
|
||||||
200 => emqx_dashboard_swagger:schema_with_example(
|
200 => emqx_dashboard_swagger:schema_with_example(
|
||||||
array(emqx_bridge_schema:get_response()),
|
array(emqx_bridge_schema:get_response()),
|
||||||
|
@ -237,7 +238,7 @@ schema("/bridges") ->
|
||||||
post => #{
|
post => #{
|
||||||
tags => [<<"bridges">>],
|
tags => [<<"bridges">>],
|
||||||
summary => <<"Create Bridge">>,
|
summary => <<"Create Bridge">>,
|
||||||
description => <<"Create a new bridge by type and name">>,
|
description => ?DESC("desc_api2"),
|
||||||
'requestBody' => emqx_dashboard_swagger:schema_with_examples(
|
'requestBody' => emqx_dashboard_swagger:schema_with_examples(
|
||||||
emqx_bridge_schema:post_request(),
|
emqx_bridge_schema:post_request(),
|
||||||
bridge_info_examples(post)),
|
bridge_info_examples(post)),
|
||||||
|
@ -254,7 +255,7 @@ schema("/bridges/:id") ->
|
||||||
get => #{
|
get => #{
|
||||||
tags => [<<"bridges">>],
|
tags => [<<"bridges">>],
|
||||||
summary => <<"Get Bridge">>,
|
summary => <<"Get Bridge">>,
|
||||||
description => <<"Get a bridge by Id">>,
|
description => ?DESC("desc_api3"),
|
||||||
parameters => [param_path_id()],
|
parameters => [param_path_id()],
|
||||||
responses => #{
|
responses => #{
|
||||||
200 => get_response_body_schema(),
|
200 => get_response_body_schema(),
|
||||||
|
@ -264,7 +265,7 @@ schema("/bridges/:id") ->
|
||||||
put => #{
|
put => #{
|
||||||
tags => [<<"bridges">>],
|
tags => [<<"bridges">>],
|
||||||
summary => <<"Update Bridge">>,
|
summary => <<"Update Bridge">>,
|
||||||
description => <<"Update a bridge by Id">>,
|
description => ?DESC("desc_api4"),
|
||||||
parameters => [param_path_id()],
|
parameters => [param_path_id()],
|
||||||
'requestBody' => emqx_dashboard_swagger:schema_with_examples(
|
'requestBody' => emqx_dashboard_swagger:schema_with_examples(
|
||||||
emqx_bridge_schema:put_request(),
|
emqx_bridge_schema:put_request(),
|
||||||
|
@ -278,7 +279,7 @@ schema("/bridges/:id") ->
|
||||||
delete => #{
|
delete => #{
|
||||||
tags => [<<"bridges">>],
|
tags => [<<"bridges">>],
|
||||||
summary => <<"Delete Bridge">>,
|
summary => <<"Delete Bridge">>,
|
||||||
description => <<"Delete a bridge by Id">>,
|
description => ?DESC("desc_api5"),
|
||||||
parameters => [param_path_id()],
|
parameters => [param_path_id()],
|
||||||
responses => #{
|
responses => #{
|
||||||
204 => <<"Bridge deleted">>,
|
204 => <<"Bridge deleted">>,
|
||||||
|
@ -293,7 +294,7 @@ schema("/bridges/:id/reset_metrics") ->
|
||||||
put => #{
|
put => #{
|
||||||
tags => [<<"bridges">>],
|
tags => [<<"bridges">>],
|
||||||
summary => <<"Reset Bridge Metrics">>,
|
summary => <<"Reset Bridge Metrics">>,
|
||||||
description => <<"Reset a bridge metrics by Id">>,
|
description => ?DESC("desc_api6"),
|
||||||
parameters => [param_path_id()],
|
parameters => [param_path_id()],
|
||||||
responses => #{
|
responses => #{
|
||||||
200 => <<"Reset success">>,
|
200 => <<"Reset success">>,
|
||||||
|
@ -307,8 +308,7 @@ schema("/bridges/:id/operation/:operation") ->
|
||||||
post => #{
|
post => #{
|
||||||
tags => [<<"bridges">>],
|
tags => [<<"bridges">>],
|
||||||
summary => <<"Enable/Disable/Stop/Restart Bridge">>,
|
summary => <<"Enable/Disable/Stop/Restart Bridge">>,
|
||||||
description => <<"Enable/Disable/Stop/Restart bridges on all nodes"
|
description => ?DESC("desc_api7"),
|
||||||
" in the cluster.">>,
|
|
||||||
parameters => [
|
parameters => [
|
||||||
param_path_id(),
|
param_path_id(),
|
||||||
param_path_operation_cluster()
|
param_path_operation_cluster()
|
||||||
|
@ -326,8 +326,7 @@ schema("/nodes/:node/bridges/:id/operation/:operation") ->
|
||||||
post => #{
|
post => #{
|
||||||
tags => [<<"bridges">>],
|
tags => [<<"bridges">>],
|
||||||
summary => <<"Stop/Restart Bridge">>,
|
summary => <<"Stop/Restart Bridge">>,
|
||||||
description => <<"Stop/Restart bridges on a specific node.\n"
|
description => ?DESC("desc_api8"),
|
||||||
"NOTE: It's not allowed to disable/enable bridges on a single node.">>,
|
|
||||||
parameters => [
|
parameters => [
|
||||||
param_path_node(),
|
param_path_node(),
|
||||||
param_path_id(),
|
param_path_id(),
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
-module(emqx_bridge_http_schema).
|
-module(emqx_bridge_http_schema).
|
||||||
|
|
||||||
-include_lib("typerefl/include/types.hrl").
|
-include_lib("typerefl/include/types.hrl").
|
||||||
|
-include_lib("hocon/include/hoconsc.hrl").
|
||||||
|
|
||||||
-import(hoconsc, [mk/2, enum/1]).
|
-import(hoconsc, [mk/2, enum/1]).
|
||||||
|
|
||||||
|
@ -16,30 +17,14 @@ fields("config") ->
|
||||||
basic_config() ++
|
basic_config() ++
|
||||||
[ {url, mk(binary(),
|
[ {url, mk(binary(),
|
||||||
#{ required => true
|
#{ required => true
|
||||||
, desc =>"
|
, desc => ?DESC("config_url")
|
||||||
The URL of the HTTP Bridge.<br>
|
|
||||||
Template with variables is allowed in the path, but variables cannot be used in the scheme, host,
|
|
||||||
or port part.<br>
|
|
||||||
For example, <code> http://localhost:9901/${topic} </code> is allowed, but
|
|
||||||
<code> http://${host}:9901/message </code> or <code> http://localhost:${port}/message </code>
|
|
||||||
is not allowed.
|
|
||||||
"
|
|
||||||
})}
|
})}
|
||||||
, {local_topic, mk(binary(),
|
, {local_topic, mk(binary(),
|
||||||
#{ desc =>"
|
#{ desc => ?DESC("config_local_topic")
|
||||||
The MQTT topic filter to be forwarded to the HTTP server. All MQTT 'PUBLISH' messages with the topic
|
|
||||||
matching the local_topic will be forwarded.<br/>
|
|
||||||
NOTE: if this bridge is used as the output of a rule (EMQX rule engine), and also local_topic is
|
|
||||||
configured, then both the data got from the rule and the MQTT messages that match local_topic
|
|
||||||
will be forwarded.
|
|
||||||
"
|
|
||||||
})}
|
})}
|
||||||
, {method, mk(method(),
|
, {method, mk(method(),
|
||||||
#{ default => post
|
#{ default => post
|
||||||
, desc =>"
|
, desc => ?DESC("config_method")
|
||||||
The method of the HTTP request. All the available methods are: post, put, get, delete.<br>
|
|
||||||
Template with variables is allowed.<br>
|
|
||||||
"
|
|
||||||
})}
|
})}
|
||||||
, {headers, mk(map(),
|
, {headers, mk(map(),
|
||||||
#{ default => #{
|
#{ default => #{
|
||||||
|
@ -48,22 +33,16 @@ Template with variables is allowed.<br>
|
||||||
<<"connection">> => <<"keep-alive">>,
|
<<"connection">> => <<"keep-alive">>,
|
||||||
<<"content-type">> => <<"application/json">>,
|
<<"content-type">> => <<"application/json">>,
|
||||||
<<"keep-alive">> => <<"timeout=5">>}
|
<<"keep-alive">> => <<"timeout=5">>}
|
||||||
, desc =>"
|
, desc => ?DESC("config_headers")
|
||||||
The headers of the HTTP request.<br>
|
|
||||||
Template with variables is allowed.
|
|
||||||
"
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
, {body, mk(binary(),
|
, {body, mk(binary(),
|
||||||
#{ default => <<"${payload}">>
|
#{ default => <<"${payload}">>
|
||||||
, desc =>"
|
, desc => ?DESC("config_body")
|
||||||
The body of the HTTP request.<br>
|
|
||||||
Template with variables is allowed.
|
|
||||||
"
|
|
||||||
})}
|
})}
|
||||||
, {request_timeout, mk(emqx_schema:duration_ms(),
|
, {request_timeout, mk(emqx_schema:duration_ms(),
|
||||||
#{ default => <<"15s">>
|
#{ default => <<"15s">>
|
||||||
, desc => "HTTP request timeout."
|
, desc => ?DESC("config_request_timeout")
|
||||||
})}
|
})}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -79,7 +58,7 @@ fields("get") ->
|
||||||
emqx_bridge_schema:metrics_status_fields() ++ fields("post").
|
emqx_bridge_schema:metrics_status_fields() ++ fields("post").
|
||||||
|
|
||||||
desc("config") ->
|
desc("config") ->
|
||||||
"Configuration for an HTTP bridge.";
|
?DESC("desc_config");
|
||||||
desc(Method) when Method =:= "get"; Method =:= "put"; Method =:= "post" ->
|
desc(Method) when Method =:= "get"; Method =:= "put"; Method =:= "post" ->
|
||||||
["Configuration for HTTP bridge using `", string:to_upper(Method), "` method."];
|
["Configuration for HTTP bridge using `", string:to_upper(Method), "` method."];
|
||||||
desc(_) ->
|
desc(_) ->
|
||||||
|
@ -88,12 +67,12 @@ desc(_) ->
|
||||||
basic_config() ->
|
basic_config() ->
|
||||||
[ {enable,
|
[ {enable,
|
||||||
mk(boolean(),
|
mk(boolean(),
|
||||||
#{ desc => "Enable or disable this bridge"
|
#{ desc => ?DESC("config_enable")
|
||||||
, default => true
|
, default => true
|
||||||
})}
|
})}
|
||||||
, {direction,
|
, {direction,
|
||||||
mk(egress,
|
mk(egress,
|
||||||
#{ desc => "The direction of this bridge, MUST be 'egress'"
|
#{ desc => ?DESC("config_direction")
|
||||||
, default => egress
|
, default => egress
|
||||||
})}
|
})}
|
||||||
]
|
]
|
||||||
|
@ -104,13 +83,13 @@ basic_config() ->
|
||||||
type_field() ->
|
type_field() ->
|
||||||
{type, mk(http,
|
{type, mk(http,
|
||||||
#{ required => true
|
#{ required => true
|
||||||
, desc => "The Bridge Type"
|
, desc => ?DESC("desc_type")
|
||||||
})}.
|
})}.
|
||||||
|
|
||||||
name_field() ->
|
name_field() ->
|
||||||
{name, mk(binary(),
|
{name, mk(binary(),
|
||||||
#{ required => true
|
#{ required => true
|
||||||
, desc => "Bridge name, used as a human-readable description of the bridge."
|
, desc => ?DESC("desc_name")
|
||||||
})}.
|
})}.
|
||||||
|
|
||||||
method() ->
|
method() ->
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
-module(emqx_bridge_mqtt_schema).
|
-module(emqx_bridge_mqtt_schema).
|
||||||
|
|
||||||
-include_lib("typerefl/include/types.hrl").
|
-include_lib("typerefl/include/types.hrl").
|
||||||
|
-include_lib("hocon/include/hoconsc.hrl").
|
||||||
|
|
||||||
-import(hoconsc, [mk/2]).
|
-import(hoconsc, [mk/2]).
|
||||||
|
|
||||||
|
@ -42,7 +43,7 @@ fields("get_egress") ->
|
||||||
emqx_bridge_schema:metrics_status_fields() ++ fields("post_egress").
|
emqx_bridge_schema:metrics_status_fields() ++ fields("post_egress").
|
||||||
|
|
||||||
desc(Rec) when Rec =:= "ingress"; Rec =:= "egress" ->
|
desc(Rec) when Rec =:= "ingress"; Rec =:= "egress" ->
|
||||||
"Configuration for MQTT bridge.";
|
?DESC("desc_rec");
|
||||||
desc(_) ->
|
desc(_) ->
|
||||||
undefined.
|
undefined.
|
||||||
|
|
||||||
|
@ -50,11 +51,11 @@ desc(_) ->
|
||||||
type_field() ->
|
type_field() ->
|
||||||
{type, mk(mqtt,
|
{type, mk(mqtt,
|
||||||
#{ required => true
|
#{ required => true
|
||||||
, desc => "The bridge type."
|
, desc => ?DESC("desc_type")
|
||||||
})}.
|
})}.
|
||||||
|
|
||||||
name_field() ->
|
name_field() ->
|
||||||
{name, mk(binary(),
|
{name, mk(binary(),
|
||||||
#{ required => true
|
#{ required => true
|
||||||
, desc => "Bridge name, used as a human-readable description of the bridge."
|
, desc => ?DESC("desc_name")
|
||||||
})}.
|
})}.
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
-module(emqx_bridge_schema).
|
-module(emqx_bridge_schema).
|
||||||
|
|
||||||
-include_lib("typerefl/include/types.hrl").
|
-include_lib("typerefl/include/types.hrl").
|
||||||
|
-include_lib("hocon/include/hoconsc.hrl").
|
||||||
|
|
||||||
-import(hoconsc, [mk/2, ref/2]).
|
-import(hoconsc, [mk/2, ref/2]).
|
||||||
|
|
||||||
|
@ -43,31 +44,24 @@ http_schema(Method) ->
|
||||||
common_bridge_fields() ->
|
common_bridge_fields() ->
|
||||||
[ {enable,
|
[ {enable,
|
||||||
mk(boolean(),
|
mk(boolean(),
|
||||||
#{ desc => "Enable or disable this bridge"
|
#{ desc => ?DESC("desc_enable")
|
||||||
, default => true
|
, default => true
|
||||||
})}
|
})}
|
||||||
, {connector,
|
, {connector,
|
||||||
mk(binary(),
|
mk(binary(),
|
||||||
#{ required => true
|
#{ required => true
|
||||||
, example => <<"mqtt:my_mqtt_connector">>
|
, example => <<"mqtt:my_mqtt_connector">>
|
||||||
, desc =>"""
|
, desc => ?DESC("desc_connector")
|
||||||
The connector ID to be used for this bridge. Connector IDs must be of format:
|
|
||||||
<code>{type}:{name}</code>.<br>
|
|
||||||
In config files, you can find the corresponding config entry for a connector by such path:
|
|
||||||
'connectors.{type}.{name}'.<br>
|
|
||||||
"""
|
|
||||||
})}
|
})}
|
||||||
].
|
].
|
||||||
|
|
||||||
metrics_status_fields() ->
|
metrics_status_fields() ->
|
||||||
[ {"metrics", mk(ref(?MODULE, "metrics"), #{desc => "The metrics of the bridge"})}
|
[ {"metrics", mk(ref(?MODULE, "metrics"), #{desc => ?DESC("desc_metrics")})}
|
||||||
, {"node_metrics", mk(hoconsc:array(ref(?MODULE, "node_metrics")),
|
, {"node_metrics", mk(hoconsc:array(ref(?MODULE, "node_metrics")),
|
||||||
#{ desc => "The metrics of the bridge for each node"
|
#{ desc => ?DESC("desc_node_metrics")})}
|
||||||
})}
|
, {"status", mk(status(), #{desc => ?DESC("desc_status")})}
|
||||||
, {"status", mk(status(), #{desc => "The status of the bridge"})}
|
|
||||||
, {"node_status", mk(hoconsc:array(ref(?MODULE, "node_status")),
|
, {"node_status", mk(hoconsc:array(ref(?MODULE, "node_status")),
|
||||||
#{ desc => "The status of the bridge for each node"
|
#{ desc => ?DESC("desc_node_status")})}
|
||||||
})}
|
|
||||||
].
|
].
|
||||||
|
|
||||||
direction_field(Dir, Desc) ->
|
direction_field(Dir, Desc) ->
|
||||||
|
@ -87,20 +81,20 @@ roots() -> [bridges].
|
||||||
|
|
||||||
fields(bridges) ->
|
fields(bridges) ->
|
||||||
[{http, mk(hoconsc:map(name, ref(emqx_bridge_http_schema, "config")),
|
[{http, mk(hoconsc:map(name, ref(emqx_bridge_http_schema, "config")),
|
||||||
#{desc => "HTTP bridges to an HTTP server."})}]
|
#{desc => ?DESC("bridges_http")})}]
|
||||||
++ [{T, mk(hoconsc:map(name, hoconsc:union([ ref(schema_mod(T), "ingress")
|
++ [{T, mk(hoconsc:map(name, hoconsc:union([ ref(schema_mod(T), "ingress")
|
||||||
, ref(schema_mod(T), "egress")
|
, ref(schema_mod(T), "egress")
|
||||||
])),
|
])),
|
||||||
#{desc => "MQTT bridges to/from another MQTT broker"})} || T <- ?CONN_TYPES];
|
#{desc => ?DESC("bridges_name")})} || T <- ?CONN_TYPES];
|
||||||
|
|
||||||
fields("metrics") ->
|
fields("metrics") ->
|
||||||
[ {"matched", mk(integer(), #{desc => "Count of this bridge is queried"})}
|
[ {"matched", mk(integer(), #{desc => ?DESC("metric_matched")})}
|
||||||
, {"success", mk(integer(), #{desc => "Count of query success"})}
|
, {"success", mk(integer(), #{desc => ?DESC("metric_success")})}
|
||||||
, {"failed", mk(integer(), #{desc => "Count of query failed"})}
|
, {"failed", mk(integer(), #{desc => ?DESC("metric_failed")})}
|
||||||
, {"rate", mk(float(), #{desc => "The rate of matched, times/second"})}
|
, {"rate", mk(float(), #{desc => ?DESC("metric_rate")})}
|
||||||
, {"rate_max", mk(float(), #{desc => "The max rate of matched, times/second"})}
|
, {"rate_max", mk(float(), #{desc => ?DESC("metric_rate_max")})}
|
||||||
, {"rate_last5m", mk(float(),
|
, {"rate_last5m", mk(float(),
|
||||||
#{desc => "The average rate of matched in the last 5 minutes, times/second"})}
|
#{desc => ?DESC("metric_rate_last5m")})}
|
||||||
];
|
];
|
||||||
|
|
||||||
fields("node_metrics") ->
|
fields("node_metrics") ->
|
||||||
|
@ -114,13 +108,13 @@ fields("node_status") ->
|
||||||
].
|
].
|
||||||
|
|
||||||
desc(bridges) ->
|
desc(bridges) ->
|
||||||
"Configuration for MQTT bridges.";
|
?DESC("desc_bridges");
|
||||||
desc("metrics") ->
|
desc("metrics") ->
|
||||||
"Bridge metrics.";
|
?DESC("desc_metrics");
|
||||||
desc("node_metrics") ->
|
desc("node_metrics") ->
|
||||||
"Node metrics.";
|
?DESC("desc_node_metrics");
|
||||||
desc("node_status") ->
|
desc("node_status") ->
|
||||||
"Node status.";
|
?DESC("desc_node_status");
|
||||||
desc(_) ->
|
desc(_) ->
|
||||||
undefined.
|
undefined.
|
||||||
|
|
||||||
|
@ -128,7 +122,7 @@ status() ->
|
||||||
hoconsc:enum([connected, disconnected, connecting]).
|
hoconsc:enum([connected, disconnected, connecting]).
|
||||||
|
|
||||||
node_name() ->
|
node_name() ->
|
||||||
{"node", mk(binary(), #{desc => "The node name.", example => "emqx@127.0.0.1"})}.
|
{"node", mk(binary(), #{desc => ?DESC("desc_node_name"), example => "emqx@127.0.0.1"})}.
|
||||||
|
|
||||||
schema_mod(Type) ->
|
schema_mod(Type) ->
|
||||||
list_to_atom(lists:concat(["emqx_bridge_", Type, "_schema"])).
|
list_to_atom(lists:concat(["emqx_bridge_", Type, "_schema"])).
|
||||||
|
|
Loading…
Reference in New Issue