Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add doc for yaml import/export #3278

Merged
merged 2 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
}
```
Loading