# 功能性API接口说明

## 公共分类 <a href="#u516cu5171u5206u7c7b" id="u516cu5171u5206u7c7b"></a>

### 登录 <a href="#u767bu5f5528urlu4e0du8981u519920api20290a3ca20id3du767bu5f5528urlu4e0du8981u519920api20293e203ca3e" id="u767bu5f5528urlu4e0du8981u519920api20290a3ca20id3du767bu5f5528urlu4e0du8981u519920api20293e203ca3e"></a>

#### 基本信息

**Path：** /login/account

**Method：** POST

**接口描述：**

#### 请求参数 <a href="#id-2" id="id-2"></a>

**Headers**

| 参数名称         | 参数值              | 是否必须 | 示例 | 备注 |
| ------------ | ---------------- | ---- | -- | -- |
| Content-Type | application/json | 是    |    |    |

**Body**

| 名称       | 类型     | 是否必须 | 默认值     | 备注  |
| -------- | ------ | ---- | ------- | --- |
| userName | string | 必须   | admin   | 用户名 |
| password | string | 必须   | coolpy7 | 密码  |

#### 返回数据 <a href="#id-3" id="id-3"></a>

| 名称     | 类型     | 是否必须 | 备注    |
| ------ | ------ | ---- | ----- |
| status | string | 非必须  | 结果状态  |
| token  | string | 非必须  | token |

```
//登陆示例
curl --location --request POST 'http://localhost:8081/login/account' \
--header 'Content-Type: text/plain' \
--data-raw '{"userName": "admin", "password": "coolpy7"}'
```

{% hint style="info" %}
鉴权说明：除登录接口外，其他接口均需把登录接口返回的TOKEN值 写到HTTP的header中，并使用Authorization为header键值，value值为 Bearer 加空格后带上token内容。
{% endhint %}

### Brokers节点 <a href="#brokersu8282u70b90a3ca20id3dbrokersu8282u70b93e203ca3e" id="brokersu8282u70b90a3ca20id3dbrokersu8282u70b93e203ca3e"></a>

#### 基本信息 <a href="#id-7" id="id-7"></a>

**Path：** /api/brokers

**Method：** GET

**接口描述：**

#### 请求参数 <a href="#id-8" id="id-8"></a>

#### 返回数据 <a href="#id-9" id="id-9"></a>

| 名称           | 类型         | 是否必须 | 备注         |
| ------------ | ---------- | ---- | ---------- |
| current      | number     | 非必须  | 当前页        |
| data         | object \[] | 非必须  | 数据载体       |
| ├─ addr      | string     | 必须   | 节点群集通信IP   |
| ├─ name      | string     | 必须   | 节点名称       |
| ├─ port      | number     | 必须   | 节点群集通信端口号  |
| ├─ version   | string     | 必须   | 节点版本号      |
| ├─ uptime    | string     | 必须   | 节点启动时间     |
| ├─ datetime  | string     | 必须   | 节点所在设备当前时间 |
| ├─ is\_local | boolean    | 非必须  | 是否当前节点     |
| pageSize     | number     | 非必须  | 页大小        |
| success      | boolean    | 非必须  | 请求结果       |
| total        | number     | 非必须  | 合计记录数      |

```
//示例
curl --location --request GET 'http://localhost:8081/api/brokers?current=1&pageSize=100' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJDUDciLCJleHAiOjE2MjgzMjI3NjgsImp0aSI6ImFkbWluIiwiaWF0IjoxNjI4MzE1NTY4LCJpc3MiOiJjb29scHkubmV0IiwibmJmIjoxNjI4MzE1NTY4fQ.r5cS1OIz8iJqrswAlo5-FStWNm9OP2LJchgVnVIhh9w' \
--data-raw ''
```

### 度量指标：Runtime运行统计 <a href="#u5ea6u91cfu6307u6807uff1aruntimeu8fd0u884cu7edfu8ba10a3ca20id3du5ea6u91cfu6307u6807uff1aruntimeu8fd0" id="u5ea6u91cfu6307u6807uff1aruntimeu8fd0u884cu7edfu8ba10a3ca20id3du5ea6u91cfu6307u6807uff1aruntimeu8fd0"></a>

#### 基本信息 <a href="#id-10" id="id-10"></a>

**Path：** /api/runtime

**Method：** GET

**接口描述：**

#### 请求参数 <a href="#id-11" id="id-11"></a>

#### 返回数据 <a href="#id-12" id="id-12"></a>

| 名称             | 类型         | 是否必须 | 备注   |
| -------------- | ---------- | ---- | ---- |
| current        | number     | 非必须  | 当前页  |
| data           | object \[] | 非必须  | 数据   |
| ├─ clientsdata | number     | 必须   | 度量值  |
| ├─ clientstype | string     | 必须   | 度量类型 |
| pageSize       | number     | 非必须  | 页大小  |
| success        | boolean    | 非必须  | 操作结果 |
| total          | number     | 非必须  | 总记录数 |

```
//示例
curl --location --request GET 'http://localhost:8081/api/runtime?current=1&pageSize=100' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJDUDciLCJleHAiOjE2MjgzMjI3NjgsImp0aSI6ImFkbWluIiwiaWF0IjoxNjI4MzE1NTY4LCJpc3MiOiJjb29scHkubmV0IiwibmJmIjoxNjI4MzE1NTY4fQ.r5cS1OIz8iJqrswAlo5-FStWNm9OP2LJchgVnVIhh9w' \
--data-raw ''
```

### 度量指标：Config配置 <a href="#u5ea6u91cfu6307u6807uff1aconfigu914du7f6e0a3ca20id3du5ea6u91cfu6307u6807uff1aconfigu914du7f6e3e203ca" id="u5ea6u91cfu6307u6807uff1aconfigu914du7f6e0a3ca20id3du5ea6u91cfu6307u6807uff1aconfigu914du7f6e3e203ca"></a>

#### 基本信息 <a href="#id-13" id="id-13"></a>

**Path：** /api/config

**Method：** GET

**接口描述：**

#### 请求参数 <a href="#id-14" id="id-14"></a>

#### 返回数据 <a href="#id-15" id="id-15"></a>

| 名称            | 类型            | 是否必须 | 备注   |
| ------------- | ------------- | ---- | ---- |
| current       | number        | 非必须  | 当前页  |
| data          | object \[]    | 非必须  | 数据   |
| ├─ configdata | number,string | 必须   | 配置值  |
| ├─ configtype | string        | 必须   | 配置类型 |
| pageSize      | number        | 非必须  | 页大小  |
| success       | boolean       | 非必须  | 操作结果 |
| total         | number        | 非必须  | 总记录数 |

```
//示例
curl --location --request GET 'http://localhost:8081/api/config?current=1&pageSize=100' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJDUDciLCJleHAiOjE2MjgzMjI3NjgsImp0aSI6ImFkbWluIiwiaWF0IjoxNjI4MzE1NTY4LCJpc3MiOiJjb29scHkubmV0IiwibmJmIjoxNjI4MzE1NTY4fQ.r5cS1OIz8iJqrswAlo5-FStWNm9OP2LJchgVnVIhh9w' \
--data-raw ''
```

### 度量指标：System <a href="#u5ea6u91cfu6307u6807uff1asystem0a3ca20id3du5ea6u91cfu6307u6807uff1asystem3e203ca3e" id="u5ea6u91cfu6307u6807uff1asystem0a3ca20id3du5ea6u91cfu6307u6807uff1asystem3e203ca3e"></a>

#### 基本信息 <a href="#id-16" id="id-16"></a>

**Path：** /api/system

**Method：** GET

**接口描述：**

#### 请求参数 <a href="#id-17" id="id-17"></a>

#### 返回数据 <a href="#id-18" id="id-18"></a>

| 名称                      | 类型         | 是否必须 | 备注         |
| ----------------------- | ---------- | ---- | ---------- |
| current                 | number     | 非必须  | 当前页        |
| data                    | object \[] | 非必须  | 数据         |
| ├─ bytes\_received      | number     | 非必须  | 输入流量       |
| ├─ bytes\_sent          | number     | 非必须  | 输出流量       |
| ├─ connections\_count   | number     | 非必须  | 当前连接数      |
| ├─ connections\_max     | number     | 非必须  | 最大连接数      |
| ├─ messages\_received   | number     | 非必须  | 消息接收数      |
| ├─ messages\_retained   | number     | 非必须  | retained消息 |
| ├─ messages\_sent       | number     | 非必须  | 消息发送数      |
| ├─ subscriptions\_count | number     | 非必须  | 订阅数        |
| ├─ subscriptions\_max   | number     | 非必须  | 最大订阅数      |
| pageSize                | number     | 非必须  | 页大小        |
| success                 | boolean    | 非必须  | 操作结果       |
| total                   | number     | 非必须  | 总记录数       |

```
//示例
curl --location --request GET 'http://localhost:8081/api/system?current=1&pageSize=100' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJDUDciLCJleHAiOjE2MjgzMjI3NjgsImp0aSI6ImFkbWluIiwiaWF0IjoxNjI4MzE1NTY4LCJpc3MiOiJjb29scHkubmV0IiwibmJmIjoxNjI4MzE1NTY4fQ.r5cS1OIz8iJqrswAlo5-FStWNm9OP2LJchgVnVIhh9w' \
--data-raw ''
```

### Clients客户端 <a href="#clientsu5ba2u6237u7aef0a3ca20id3dclientsu5ba2u6237u7aef3e203ca3e" id="clientsu5ba2u6237u7aef0a3ca20id3dclientsu5ba2u6237u7aef3e203ca3e"></a>

#### 基本信息 <a href="#id-19" id="id-19"></a>

**Path：** /api/clients

**Method：** GET

**接口描述：**

#### 请求参数 <a href="#id-20" id="id-20"></a>

**Query**

| 参数名称     | 是否必须 | 示例                      |
| -------- | ---- | ----------------------- |
| current  | 是    | ?current=1\&pageSize=10 |
| pageSize | 是    | ?current=1\&pageSize=10 |

**Body**

| 名称        | 类型     | 是否必须 | 备注    |
| --------- | ------ | ---- | ----- |
| ClientId  | string | 非必须  | 客户端ID |
| Ip        | string | 非必须  | 客户端IP |
| Protocol  | string | 非必须  | 协议类型  |
| SessionAt | string | 非必须  | 会话时间  |
| Status    | string | 非必须  | 状态    |

#### 返回数据 <a href="#id-21" id="id-21"></a>

| 名称             | 类型         | 是否必须 | 备注    |
| -------------- | ---------- | ---- | ----- |
| current        | number     | 非必须  | 当前页   |
| data           | object \[] | 非必须  | 数据    |
| ├─ client\_id  | string     | 必须   | 客户端ID |
| ├─ ip          | string     | 必须   | 客户端IP |
| ├─ protocol    | string     | 必须   | 协议类型  |
| ├─ session\_at | string     | 必须   | 会话时间  |
| ├─ status      | string     | 必须   | 客户端状态 |
| ├─ subscribes  | number     | 必须   | 订阅数   |
| ├─ updated\_at | string     | 必须   | 更新时间  |
| ├─ user\_name  | string     | 必须   | 用户名   |
| pageSize       | number     | 非必须  | 页大小   |
| success        | boolean    | 非必须  | 操作结果  |
| total          | number     | 非必须  | 总记录数  |

```
curl --location --request GET 'http://localhost:8081/api/clients?current=1&pageSize=100' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJDUDciLCJleHAiOjE2MjgzMjI3NjgsImp0aSI6ImFkbWluIiwiaWF0IjoxNjI4MzE1NTY4LCJpc3MiOiJjb29scHkubmV0IiwibmJmIjoxNjI4MzE1NTY4fQ.r5cS1OIz8iJqrswAlo5-FStWNm9OP2LJchgVnVIhh9w' \
--data-raw ''
```

### Topics主题 <a href="#topicsu4e3bu98980a3ca20id3dtopicsu4e3bu98983e203ca3e" id="topicsu4e3bu98980a3ca20id3dtopicsu4e3bu98983e203ca3e"></a>

#### 基本信息 <a href="#id-22" id="id-22"></a>

**Path：** /api/topics

**Method：** GET

**接口描述：**

#### 请求参数 <a href="#id-23" id="id-23"></a>

**Query**

| 参数名称     | 是否必须 | 示例                      |
| -------- | ---- | ----------------------- |
| current  | 是    | ?current=1\&pageSize=10 |
| pageSize | 是    | ?current=1\&pageSize=10 |

#### 返回数据 <a href="#id-24" id="id-24"></a>

| 名称             | 类型         | 是否必须 | 备注    |
| -------------- | ---------- | ---- | ----- |
| current        | number     | 非必须  | 当前页   |
| data           | object \[] | 非必须  | 数据    |
| ├─ client\_id  | string     | 必须   | 客户端ID |
| ├─ node\_name  | string     | 必须   | 节点名称  |
| ├─ qos         | number     | 必须   | 消息质量  |
| ├─ topic       | string     | 必须   | 主题    |
| ├─ updated\_at | string     | 必须   | 更新时间  |
| pageSize       | number     | 非必须  | 页大小   |
| success        | boolean    | 非必须  | 操作结果  |
| total          | number     | 非必须  | 总记录数  |

```
curl --location --request GET 'http://localhost:8081/api/topics?current=1&pageSize=100' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJDUDciLCJleHAiOjE2MjgzMjI3NjgsImp0aSI6ImFkbWluIiwiaWF0IjoxNjI4MzE1NTY4LCJpc3MiOiJjb29scHkubmV0IiwibmJmIjoxNjI4MzE1NTY4fQ.r5cS1OIz8iJqrswAlo5-FStWNm9OP2LJchgVnVIhh9w' \
--data-raw ''
```

### 规则新增 <a href="#u89c4u5219u65b0u589e0a3ca20id3du89c4u5219u65b0u589e3e203ca3e" id="u89c4u5219u65b0u589e0a3ca20id3du89c4u5219u65b0u589e3e203ca3e"></a>

#### 基本信息 <a href="#id-28" id="id-28"></a>

**Path：** /api/rules

**Method：** POST

**接口描述：**

#### 请求参数 <a href="#id-29" id="id-29"></a>

**Headers**

| 参数名称         | 参数值              | 是否必须 |
| ------------ | ---------------- | ---- |
| Content-Type | application/json | 是    |

**Body**

| 名称       | 类型     | 是否必须 | 备注     |
| -------- | ------ | ---- | ------ |
| ruleName | string | 必须   | 规则名称   |
| rule     | string | 必须   | 规则脚本内容 |

#### 返回数据 <a href="#id-30" id="id-30"></a>

| 名称       | 类型      | 是否必须 | 备注    |
| -------- | ------- | ---- | ----- |
| success  | boolean | 非必须  | 状态    |
| id       | string  | 非必须  | 规则ID  |
| ruleDesc | string  | 非必须  | 规则备注  |
| ruleName | string  | 非必须  | 规则名   |
| salience | string  | 非必须  | 规则优先级 |

```
curl --location --request POST 'http://localhost:8081/api/rules' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJDUDciLCJleHAiOjE2MjgzMjI3NjgsImp0aSI6ImFkbWluIiwiaWF0IjoxNjI4MzE1NTY4LCJpc3MiOiJjb29scHkubmV0IiwibmJmIjoxNjI4MzE1NTY4fQ.r5cS1OIz8iJqrswAlo5-FStWNm9OP2LJchgVnVIhh9w' \
--header 'Content-Type: text/plain' \
--data-raw '{"ruleName":"rule2","rule":"//规则名称为rule2，规则备注，执行优先级\nrule \"rule2\" \"rule-describtion\" salience  1\nbegin\n  //过滤主题为aaa的消息才进行处理\n  if Message.Topic == \"aaa\" {\n    //反序列化消息中的载体\n    payload = Core.FromJson(Message.Payload)\n    //判断消息载体是否为空\n    if isNil(payload) {\n        println(\"parse error\")\n        return\n    }\n    //实例化一个map用于转换消息体格式\n    res = Core.MakeMap()\n    //把原消息的msg内容付值到新消息体的m键中\n    res[\"m\"] = payload[\"msg\"]\n    //序列化新的消息体为json\n    reMsg = Core.ToJson(res)\n    //传送序列化是否失败\n    if isNil(reMsg) {\n        println(\"format error\")\n        return\n    }\n    //打印序列化结果于服务端\n    println(Core.String(reMsg))\n    //实例化mqtt消息体\n    newMsg = Core.MakeMessage()\n    //设置新的接收主题\n    newMsg.Topic = \"bbb/#\"\n    //消息质量控制\n    newMsg.QOS = 0\n    newMsg.Retain = false\n    //把新的载体付值到新消息载体中\n    newMsg.Payload = reMsg\n    //通过内核发布新消息\n    err = Core.Publish(newMsg)\n    if err != \"\" {\n        println(err)\n    }\n  }\nend","method":"post"}'
```

### 规则修改 <a href="#u89c4u5219u4feeu65390a3ca20id3du89c4u5219u4feeu65393e203ca3e" id="u89c4u5219u4feeu65390a3ca20id3du89c4u5219u4feeu65393e203ca3e"></a>

#### 基本信息 <a href="#id-31" id="id-31"></a>

**Path：** /api/rules

**Method：** PUT

**接口描述：**

#### 请求参数 <a href="#id-32" id="id-32"></a>

**Headers**

| 参数名称         | 参数值              | 是否必须 |
| ------------ | ---------------- | ---- |
| Content-Type | application/json | 是    |

**Body**

| 名称       | 类型     | 是否必须 | 备注     |
| -------- | ------ | ---- | ------ |
| ruleName | string | 必须   | 规则名    |
| rule     | string | 必须   | 规则脚本内容 |

#### 返回数据 <a href="#id-30" id="id-30"></a>

| 名称       | 类型      | 是否必须 | 备注    |
| -------- | ------- | ---- | ----- |
| success  | boolean | 非必须  | 状态    |
| id       | string  | 非必须  | 规则ID  |
| ruleDesc | string  | 非必须  | 规则备注  |
| ruleName | string  | 非必须  | 规则名   |
| salience | string  | 非必须  | 规则优先级 |

```
curl --location --request PUT 'http://localhost:8081/api/rules' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJDUDciLCJleHAiOjE2MjgzMjI3NjgsImp0aSI6ImFkbWluIiwiaWF0IjoxNjI4MzE1NTY4LCJpc3MiOiJjb29scHkubmV0IiwibmJmIjoxNjI4MzE1NTY4fQ.r5cS1OIz8iJqrswAlo5-FStWNm9OP2LJchgVnVIhh9w' \
--header 'Content-Type: text/plain' \
--data-raw '{"ruleName":"rule2","rule":"//规则名称为rule2，规则备注，执行优先级\nrule \"rule2\" \"rule-describtion\" salience  1\nbegin\n  //过滤主题为aaa的消息才进行处理\n  if Message.Topic == \"aaa\" {\n    //反序列化消息中的载体\n    payload = Core.FromJson(Message.Payload)\n    //判断消息载体是否为空\n    if isNil(payload) {\n        println(\"parse error\")\n        return\n    }\n    //实例化一个map用于转换消息体格式\n    res = Core.MakeMap()\n    //把原消息的msg内容付值到新消息体的m键中\n    res[\"m\"] = payload[\"msg\"]\n    //序列化新的消息体为json\n    reMsg = Core.ToJson(res)\n    //传送序列化是否失败\n    if isNil(reMsg) {\n        println(\"format error\")\n        return\n    }\n    //打印序列化结果于服务端\n    println(Core.String(reMsg))\n    //实例化mqtt消息体\n    newMsg = Core.MakeMessage()\n    //设置新的接收主题\n    newMsg.Topic = \"bbb/#\"\n    //消息质量控制\n    newMsg.QOS = 0\n    newMsg.Retain = false\n    //把新的载体付值到新消息载体中\n    newMsg.Payload = reMsg\n    //通过内核发布新消息\n    err = Core.Publish(newMsg)\n    if err != \"\" {\n        println(err)\n    }\n  }\nend","method":"post"}'
```

### 规则列表 <a href="#u89c4u5219u5217u88680a3ca20id3du89c4u5219u5217u88683e203ca3e" id="u89c4u5219u5217u88680a3ca20id3du89c4u5219u5217u88683e203ca3e"></a>

#### 基本信息 <a href="#id-34" id="id-34"></a>

**Path：** /api/rules

**Method：** GET

**接口描述：**

#### 请求参数 <a href="#id-35" id="id-35"></a>

**Query**

| 参数名称     | 是否必须 | 示例                      |
| -------- | ---- | ----------------------- |
| current  | 是    | ?current=1\&pageSize=10 |
| pageSize | 是    | ?current=1\&pageSize=10 |

#### 返回数据 <a href="#id-36" id="id-36"></a>

| 名称          | 类型         | 是否必须 | 备注   |
| ----------- | ---------- | ---- | ---- |
| current     | number     | 非必须  | 当前页  |
| data        | object \[] | 非必须  | 数据   |
| ├─ id       | string     | 必须   | 规则ID |
| ├─ ruleName | string     | 必须   | 规则名称 |
| pageSize    | number     | 非必须  | 页大小  |
| success     | boolean    | 非必须  | 操作结果 |
| total       | number     | 非必须  | 总记录数 |

```
curl --location --request GET 'http://localhost:8081/api/rules?current=1&pageSize=100' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJDUDciLCJleHAiOjE2MjgzMjI3NjgsImp0aSI6ImFkbWluIiwiaWF0IjoxNjI4MzE1NTY4LCJpc3MiOiJjb29scHkubmV0IiwibmJmIjoxNjI4MzE1NTY4fQ.r5cS1OIz8iJqrswAlo5-FStWNm9OP2LJchgVnVIhh9w'
```

### 规则详情 <a href="#u89c4u5219u8be6u60c50a3ca20id3du89c4u5219u8be6u60c53e203ca3e" id="u89c4u5219u8be6u60c50a3ca20id3du89c4u5219u8be6u60c53e203ca3e"></a>

#### 基本信息 <a href="#id-37" id="id-37"></a>

**Path：** /api/rule/:ruleid

**Method：** GET

**接口描述：**

#### 请求参数 <a href="#id-38" id="id-38"></a>

**路径参数**

| 参数名称   | 示例    | 备注   |
| ------ | ----- | ---- |
| ruleid | rule2 | 规则名称 |

#### 返回数据 <a href="#id-39" id="id-39"></a>

| 名称          | 类型      | 是否必须 | 备注     |
| ----------- | ------- | ---- | ------ |
| success     | boolean | 非必须  | 操作结果   |
| data        | object  | 非必须  | 数据     |
| ├─ rule     | string  | 非必须  | 规则脚本内容 |
| ├─ ruleName | string  | 非必须  | 规则名称   |

```
curl --location --request GET 'http://localhost:8081/api/rule/rule1' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJDUDciLCJleHAiOjE2MjgzMjI3NjgsImp0aSI6ImFkbWluIiwiaWF0IjoxNjI4MzE1NTY4LCJpc3MiOiJjb29scHkubmV0IiwibmJmIjoxNjI4MzE1NTY4fQ.r5cS1OIz8iJqrswAlo5-FStWNm9OP2LJchgVnVIhh9w'
```

### 规则删除单个或删除所有 <a href="#u89c4u5219u5220u9664u5355u4e2au6216u5220u9664u6240u67090a3ca20id3du89c4u5219u5220u9664u5355u4e2au621" id="u89c4u5219u5220u9664u5355u4e2au6216u5220u9664u6240u67090a3ca20id3du89c4u5219u5220u9664u5355u4e2au621"></a>

#### 基本信息 <a href="#id-40" id="id-40"></a>

**Path：** /api/rules

**Method：** DELETE

**接口描述：**

#### 请求参数 <a href="#id-41" id="id-41"></a>

**Headers**

| 参数名称         | 参数值              | 是否必须 |
| ------------ | ---------------- | ---- |
| Content-Type | application/json | 是    |

**Body**

| 参数名称 | 参数类型      | 是否必须 | 示例                 | 备注                      |
| ---- | --------- | ---- | ------------------ | ----------------------- |
| ids  | string\[] | 否    | {"ids":\["rule2"]} | 删除单个规则需要传规则id，不传则删除所有规则 |

#### 返回数据 <a href="#id-42" id="id-42"></a>

| 名称      | 类型      | 是否必须 | 备注 |
| ------- | ------- | ---- | -- |
| success | boolean | 非必须  | 状态 |

```
curl --location --request DELETE 'http://localhost:8081/api/rules' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJDUDciLCJleHAiOjE2MjgzMjI3NjgsImp0aSI6ImFkbWluIiwiaWF0IjoxNjI4MzE1NTY4LCJpc3MiOiJjb29scHkubmV0IiwibmJmIjoxNjI4MzE1NTY4fQ.r5cS1OIz8iJqrswAlo5-FStWNm9OP2LJchgVnVIhh9w' \
--header 'Content-Type: text/plain' \
--data-raw '{"ids":["rule2"]}'
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://coolpy7.gitbook.io/coolpy7book/kai-shi-shi-yong/gong-neng-xing-api-jie-kou-shuo-ming.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
