Skip to content

Commit

Permalink
docs: add doc for yaml import/export (#3278)
Browse files Browse the repository at this point in the history
Signed-off-by: Song Gao <[email protected]>
  • Loading branch information
Yisaer authored Oct 10, 2024
1 parent 464f01a commit 0c66643
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
40 changes: 40 additions & 0 deletions docs/en_US/api/restapi/data.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,43 @@ Example 2: export specific rules related data
```shell
POST -d '["rule1","rule2"]' http://{{host}}/data/export
```

## Import and export data through yaml format

For eKuiper configuration, the yaml format is more readable. eKuiper also supports importing and exporting configurations through yaml format, including stream `stream`, table `table`, rule `rule`, plug-in `plugin`, and source configuration etc. Each type stores a name and a key-value pair of the creation statement. In the following example file, we define flows, rules, tables, plug-ins, source configurations, and target action configurations.

GET /v2/data/export

```yaml
sourceConfig:
sources.mqtt.mqttconf1:
connectionSelector: mqttcon
qos: 1
sourceType: stream
connectionConfig:
connections.mqtt.mqttcon:
insecureSkipVerify: false
protocolVersion: 3.1.1
server: tcp://127.0.0.1:1883
streams:
mqttstream1:
sql: ' CREATE STREAM mqttstream1 () WITH (DATASOURCE="topic1", FORMAT="json", CONF_KEY="mqttconf1", TYPE="mqtt", SHARED="false", );'
rules:
rule1:
triggered: false
id: rule1
sql: select * from mqttstream1
actions:
- log: {}
```
Import Configuration
POST http://{{host}}/v2/data/import
Content-Type: application/json
```json
{
"file": "file:///tmp/a.yaml"
}
```
40 changes: 40 additions & 0 deletions docs/zh_CN/api/restapi/data.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,43 @@ GET http://{{host}}/data/export
```shell
POST -d '["rule1","rule2"]' http://{{host}}/data/export
```

## 通过 yaml 格式导入导出数据

对于 eKuiper 配置而言,yaml 格式具有更好的可读性,eKuiper 同时支持通过 yaml 格式导入导出配置,包含流 `stream`,表 `table`,规则 `rule`,插件 `plugin`,源配置 `source yaml` 等。每种类型保存名字和创建语句的键值对。在以下示例文件中,我们定义了流、规则、表、插件、源配置、目标动作配置。

GET http://{{host}}/v2/data/export

```yaml
sourceConfig:
sources.mqtt.mqttconf1:
connectionSelector: mqttcon
qos: 1
sourceType: stream
connectionConfig:
connections.mqtt.mqttcon:
insecureSkipVerify: false
protocolVersion: 3.1.1
server: tcp://127.0.0.1:1883
streams:
mqttstream1:
sql: ' CREATE STREAM mqttstream1 () WITH (DATASOURCE="topic1", FORMAT="json", CONF_KEY="mqttconf1", TYPE="mqtt", SHARED="false", );'
rules:
rule1:
triggered: false
id: rule1
sql: select * from mqttstream1
actions:
- log: {}
```
导入配置
POST http://{{host}}/v2/data/import
Content-Type: application/json
```json
{
"file": "file:///tmp/a.yaml"
}
```

0 comments on commit 0c66643

Please sign in to comment.