Skip to content

Commit

Permalink
* NEW [docs] udpate http api config_update docs(zh).
Browse files Browse the repository at this point in the history
Signed-off-by: lee-emqx <lihj@emqx.io>
  • Loading branch information
xinyi-xs committed Jan 31, 2024
1 parent ff9a5a3 commit 833cfdf
Show file tree
Hide file tree
Showing 2 changed files with 201 additions and 4 deletions.
102 changes: 99 additions & 3 deletions docs/en_US/api/v4.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ The possible returned codes are as follows:
| 117 | Request parameters are not in legal HOCON format|
| 118 | Write config file failed |

= 117,
WRITE_CONFIG_FAILED = 118,


## API Endpoints

Expand Down Expand Up @@ -693,6 +690,105 @@ $ curl -i --basic -u admin:public -X POST 'http://localhost:8081/api/v4/reload'
{"code":0}
```

## Update configuration file

### POST /api/v4/config_update

配置文件更新。

**Parameters (json):**

| Name | Type | Required | Value | Description |
| ---- | ------ | -------- | ----- | -------------------------------------------------------- |
| data | Object | Required | | The transferred data content is a new configuration. You can refer to the [configuration](../config-description/introduction.md) for details.|

**Success Response Body (JSON):**

| Name | Type | Description |
| ---- | ------- | ----------- |
| code | Integer | 0 |

**Examples:**

```bash
$ curl --basic -u admin:public -X POST "http://localhost:8081/api/v4/config_update" -d \
'
# NanoMQ Configuration 0.18.0
# #============================================================
# # NanoMQ Broker
# #============================================================
mqtt {
property_size = 32
max_packet_size = 10KB
max_mqueue_len = 2048
retry_interval = 10s
keepalive_multiplier = 1.25
# Three of below, unsupported now
max_inflight_window = 2048
max_awaiting_rel = 10s
await_rel_timeout = 10s
}
listeners.tcp {
bind = "0.0.0.0:1883"
}
# listeners.ssl {
# bind = "0.0.0.0:8883"
# keyfile = "/etc/certs/key.pem"
# certfile = "/etc/certs/cert.pem"
# cacertfile = "/etc/certs/cacert.pem"
# verify_peer = false
# fail_if_no_peer_cert = false
# }
listeners.ws {
bind = "0.0.0.0:8083/mqtt"
}
http_server {
port = 8081
limit_conn = 2
username = admin
password = public
auth_type = basic
jwt {
public.keyfile = "/etc/certs/jwt/jwtRS256.key.pub"
}
}
log {
to = [file, console]
level = info
dir = "/tmp"
file = "nanomq.log"
rotation {
size = 10MB
count = 5
}
}
auth {
allow_anonymous = true
no_match = allow
deny_action = ignore
cache = {
max_size = 32
ttl = 1m
}
# password = {include "/etc/nanomq_pwd.conf"}
# acl = {include "/etc/nanomq_acl.conf"}
}
'

{"code":0}
```



## Get bridges configuration
Expand Down
103 changes: 102 additions & 1 deletion docs/zh_CN/api/v4.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ NanoMQ 接口的响应消息体为 JSON 格式,其中总是包含返回码 `co
| 114 | 旧密码错误 |
| 115 | 不合法的主题 |
| 116 | Token 已过期 |

| 117 | 请求参数不是合法的 HOCON 格式 |
| 118 | 配置文件写失败 |


## API Endpoints
Expand Down Expand Up @@ -694,6 +695,106 @@ $ curl -i --basic -u admin:public -X POST 'http://localhost:8081/api/v4/reload'
```


## 配置文件更新

### POST /api/v4/config_update

配置文件更新。

**Parameters (json):**

| Name | Type | Required | Value | Description |
| ---- | ------ | -------- | ----- | -------------------------------------------------------- |
| data | Object | Required | | 传输的数据内容是新的配置,配置内容可参考 [配置](../config-description/introduction.md)|

**Success Response Body (JSON):**

| Name | Type | Description |
| ---- | ------- | ----------- |
| code | Integer | 0 |

**Examples:**

```bash
$ curl --basic -u admin:public -X POST "http://localhost:8081/api/v4/config_update" -d \
'
# NanoMQ Configuration 0.18.0
# #============================================================
# # NanoMQ Broker
# #============================================================
mqtt {
property_size = 32
max_packet_size = 10KB
max_mqueue_len = 2048
retry_interval = 10s
keepalive_multiplier = 1.25
# Three of below, unsupported now
max_inflight_window = 2048
max_awaiting_rel = 10s
await_rel_timeout = 10s
}
listeners.tcp {
bind = "0.0.0.0:1883"
}
# listeners.ssl {
# bind = "0.0.0.0:8883"
# keyfile = "/etc/certs/key.pem"
# certfile = "/etc/certs/cert.pem"
# cacertfile = "/etc/certs/cacert.pem"
# verify_peer = false
# fail_if_no_peer_cert = false
# }
listeners.ws {
bind = "0.0.0.0:8083/mqtt"
}
http_server {
port = 8081
limit_conn = 2
username = admin
password = public
auth_type = basic
jwt {
public.keyfile = "/etc/certs/jwt/jwtRS256.key.pub"
}
}
log {
to = [file, console]
level = info
dir = "/tmp"
file = "nanomq.log"
rotation {
size = 10MB
count = 5
}
}
auth {
allow_anonymous = true
no_match = allow
deny_action = ignore
cache = {
max_size = 32
ttl = 1m
}
# password = {include "/etc/nanomq_pwd.conf"}
# acl = {include "/etc/nanomq_acl.conf"}
}
'

{"code":0}
```



## 获取桥接配置

Expand Down

0 comments on commit 833cfdf

Please sign in to comment.