Explorar o código

fix(docs): add docs for partial export/import api

Signed-off-by: Jianxiang Ran <rxan_embedded@163.com>
Jianxiang Ran %!s(int64=2) %!d(string=hai) anos
pai
achega
68fd7a673f

+ 18 - 4
docs/en_US/api/cli/data.md

@@ -1,6 +1,6 @@
 # Data Import/Export Management
 
-The eKuiper rule command line tools allows to import and export all the Data.
+The eKuiper rule command line tools allows to import and export the Data.
 
 ## Data Format
 
@@ -19,8 +19,8 @@ The file format for importing and exporting Data is JSON, which can contain : `s
     "rule2": "{\"id\": \"rule2\",\"sql\": \"SELECT * FROM demo\",\"actions\": [{  \"log\": {}}]}"
   },
   "nativePlugins":{
-    "sinks_tdengine":"fail to download file file:///root/ekuiper-jran/_plugins/ubuntu/sinks/tdengine_amd64.zip: stat /root/ekuiper-jran/_plugins/ubuntu/sinks/tdengine_amd64.zip: no such file or directory",
-    "sources_random":"fail to download file file:///root/ekuiper-jran/_plugins/ubuntu/sources/random_amd64.zip: stat /root/ekuiper-jran/_plugins/ubuntu/sources/random_amd64.zip: no such file or directory"
+    "functions_image":"{\"name\":\"image\",\"file\":\"https://packages.emqx.net/kuiper-plugins/1.8.1/debian/functions/image_amd64.zip\",\"shellParas\":[]}",
+    "sources_video":"{\"name\":\"video\",\"file\":\"https://packages.emqx.net/kuiper-plugins/1.8.1/debian/sources/video_amd64.zip\",\"shellParas\":[]}",
   },
   "portablePlugins":{
   },
@@ -39,7 +39,7 @@ The file format for importing and exporting Data is JSON, which can contain : `s
 }
 ```
 
-## Import Data
+## Reset And Import Data
 
 The API resets all existing data and then imports the new data into the system. 
 
@@ -47,6 +47,14 @@ The API resets all existing data and then imports the new data into the system.
 # bin/kuiper import data -f myrules.json -s false
 ```
 
+## Import Data 
+
+The API imports the data into the system(overwrite the tables/streams/rules/source config/sink config. install plugins/schema if not exist, else ignore them).
+
+```shell
+# bin/kuiper import data -f myrules.json -p true
+```
+
 ## Import Data Status
 
 This API returns Data import errors. If all returns are empty, it means that the import is completely successful.
@@ -61,4 +69,10 @@ This command exports the Data to the specified file.
 
 ```shell
 # bin/kuiper export data myrules.json
+```
+
+This command exports the specific rules related Data to the specified file.
+
+```shell
+# bin/kuiper export data myrules.json -r '["rules1", "rules2"]'
 ```

+ 28 - 5
docs/en_US/api/restapi/data.md

@@ -1,6 +1,6 @@
 # Data Import/Export Management
 
-eKuiper REST api allows to import or export all data.
+eKuiper REST api allows to import or export data.
 
 ## Data Format
 
@@ -19,8 +19,8 @@ The file format for importing and exporting data is JSON, which can contain : `s
         "rule2": "{\"id\": \"rule2\",\"sql\": \"SELECT * FROM demo\",\"actions\": [{  \"log\": {}}]}"
     },
     "nativePlugins":{
-        "sinks_tdengine":"fail to download file file:///root/ekuiper-jran/_plugins/ubuntu/sinks/tdengine_amd64.zip: stat /root/ekuiper-jran/_plugins/ubuntu/sinks/tdengine_amd64.zip: no such file or directory",
-        "sources_random":"fail to download file file:///root/ekuiper-jran/_plugins/ubuntu/sources/random_amd64.zip: stat /root/ekuiper-jran/_plugins/ubuntu/sources/random_amd64.zip: no such file or directory"
+        "functions_image":"{\"name\":\"image\",\"file\":\"https://packages.emqx.net/kuiper-plugins/1.8.1/debian/functions/image_amd64.zip\",\"shellParas\":[]}",
+        "sources_video":"{\"name\":\"video\",\"file\":\"https://packages.emqx.net/kuiper-plugins/1.8.1/debian/sources/video_amd64.zip\",\"shellParas\":[]}"
     },
     "portablePlugins":{
     },
@@ -41,7 +41,8 @@ The file format for importing and exporting data is JSON, which can contain : `s
 
 ## Import Data
 
-The API resets all existing data and then imports the new data into the system. The API supports specifying data by means of text content or file URIs.
+The API resets all existing data and then imports the new data into the system by default. But user can specify ``partial=1`` parameter in HTTP URL to keep the existing data and apply the new data.
+The API supports specifying data by means of text content or file URIs.
 
 
 Example 1: Import by text content
@@ -78,6 +79,18 @@ Content-Type: application/json
 }
 ```
 
+
+Example 4: Keep the old data and import new data (overwrite the tables/streams/rules/source config/sink config. install plugins/schema if not exist, else ignore them)
+
+```shell
+POST http://{{host}}/data/import?partial=1
+Content-Type: application/json
+
+{
+  "file": "file:///tmp/a.json"
+}
+```
+
 ## Import data status
 
 
@@ -103,7 +116,9 @@ Content-Type: application/json
   "sinkConfig":{},
   "connectionConfig":{},
   "Service":{},
-  "Schema":{}}
+  "Schema":{}
+}
+
 ```
 
 Example 2: Failed to import plugin
@@ -131,6 +146,14 @@ Content-Type: application/json
 
 The export API returns a file to download.
 
+Example 1: export all data
+
 ```shell
 GET http://{{host}}/data/export
+```
+
+Example 2: export specific rules related data
+
+```shell
+POST -d '["rule1","rule2"]' http://{{host}}/data/export
 ```

+ 18 - 4
docs/zh_CN/api/cli/data.md

@@ -1,6 +1,6 @@
 # 数据导入导出管理
 
-eKuiper 命令行工具允许您导入导出当前的所有数据。
+eKuiper 命令行工具允许您导入导出当前数据。
 
 ## 数据格式
 
@@ -19,8 +19,8 @@ eKuiper 命令行工具允许您导入导出当前的所有数据。
     "rule2": "{\"id\": \"rule2\",\"sql\": \"SELECT * FROM demo\",\"actions\": [{  \"log\": {}}]}"
   },
   "nativePlugins":{
-    "sinks_tdengine":"fail to download file file:///root/ekuiper-jran/_plugins/ubuntu/sinks/tdengine_amd64.zip: stat /root/ekuiper-jran/_plugins/ubuntu/sinks/tdengine_amd64.zip: no such file or directory",
-    "sources_random":"fail to download file file:///root/ekuiper-jran/_plugins/ubuntu/sources/random_amd64.zip: stat /root/ekuiper-jran/_plugins/ubuntu/sources/random_amd64.zip: no such file or directory"
+    "functions_image":"{\"name\":\"image\",\"file\":\"https://packages.emqx.net/kuiper-plugins/1.8.1/debian/functions/image_amd64.zip\",\"shellParas\":[]}",
+    "sources_video":"{\"name\":\"video\",\"file\":\"https://packages.emqx.net/kuiper-plugins/1.8.1/debian/sources/video_amd64.zip\",\"shellParas\":[]}",
   },
   "portablePlugins":{
   },
@@ -39,7 +39,7 @@ eKuiper 命令行工具允许您导入导出当前的所有数据。
 }
 ```
 
-## 导入数据
+## 清除旧数据并导入数据
 
 该 API 接受数据并将其导入系统中。若已有历史遗留数据,则首先清除旧有数据,然后导入。
 
@@ -47,6 +47,14 @@ eKuiper 命令行工具允许您导入导出当前的所有数据。
 # bin/kuiper import data -f myrules.json -s false
 ```
 
+## 导入新数据
+
+该 API 接受数据并将其导入系统中(覆盖 tables/streams/rules/source config/sink 相关数据. 如果 plugins/schema 在系统中不存在, 那么安装,否则忽略相关配置)。
+
+```shell
+# bin/kuiper import data -f myrules.json -p true
+```
+
 ## 导入数据状态查询
 
 该 API 返回数据导入出错情况,如所有返回为空,则代表导入完全成功。
@@ -61,4 +69,10 @@ eKuiper 命令行工具允许您导入导出当前的所有数据。
 
 ```shell
 # bin/kuiper export data myrules.json
+```
+
+导出特定规则相关数据
+
+```shell
+# bin/kuiper export data myrules.json -r '["rules1", "rules2"]'
 ```

+ 25 - 5
docs/zh_CN/api/restapi/data.md

@@ -1,6 +1,6 @@
 # 数据导入导出管理
 
-eKuiper REST api 允许您导入导出当前的所有数据。
+eKuiper REST api 允许您导入导出数据。
 
 ## 数据格式
 
@@ -19,8 +19,8 @@ eKuiper REST api 允许您导入导出当前的所有数据。
         "rule2": "{\"id\": \"rule2\",\"sql\": \"SELECT * FROM demo\",\"actions\": [{  \"log\": {}}]}"
     },
     "nativePlugins":{
-        "sinks_tdengine":"fail to download file file:///root/ekuiper-jran/_plugins/ubuntu/sinks/tdengine_amd64.zip: stat /root/ekuiper-jran/_plugins/ubuntu/sinks/tdengine_amd64.zip: no such file or directory",
-        "sources_random":"fail to download file file:///root/ekuiper-jran/_plugins/ubuntu/sources/random_amd64.zip: stat /root/ekuiper-jran/_plugins/ubuntu/sources/random_amd64.zip: no such file or directory"
+        "functions_image":"{\"name\":\"image\",\"file\":\"https://packages.emqx.net/kuiper-plugins/1.8.1/debian/functions/image_amd64.zip\",\"shellParas\":[]}",
+        "sources_video":"{\"name\":\"video\",\"file\":\"https://packages.emqx.net/kuiper-plugins/1.8.1/debian/sources/video_amd64.zip\",\"shellParas\":[]}",
     },
     "portablePlugins":{
     },
@@ -41,7 +41,8 @@ eKuiper REST api 允许您导入导出当前的所有数据。
 
 ## 导入数据
 
-该 API 接受数据并将其导入系统中。若已有历史遗留数据,则首先清除旧有数据,然后导入。 API 支持通过文本内容或者文件 URI 的方式指定数据。
+该 API 接受数据并将其导入系统中,支持通过文本内容或者文件 URI 的方式指定数据。
+默认情况下若已有历史遗留数据,则首先清除旧有数据然后导入,用户可通过在 HTTP URL 中指定 ``partial=1`` 参数,使其直接导入,不再清除旧有数据。 
 
 示例1:通过文本内容导入
 
@@ -71,12 +72,23 @@ Content-Type: application/json
 ```shell
 POST http://{{host}}/data/import?stop=1
 Content-Type: application/json
+{
+  "file": "file:///tmp/a.json"
+}
+```
+
+示例4: 导入新数据但是不清除旧有数据 (覆盖 tables/streams/rules/source config/sink 相关数据. 如果 plugins/schema 在系统中不存在, 那么安装,否则忽略相关配置)
+
+```shell
+POST http://{{host}}/data/import?partial=1
+Content-Type: application/json
 
 {
   "file": "file:///tmp/a.json"
 }
 ```
 
+
 ## 导入数据状态查询
 
 该 API 返回数据导入出错情况,如所有返回为空,则代表导入完全成功。
@@ -129,6 +141,14 @@ Content-Type: application/json
 
 导出 API 返回二进制流,在浏览器使用时,可选择下载保存的文件路径。
 
+示例1:导出所有数据
+
 ```shell
 GET http://{{host}}/data/export
-```
+```
+
+示例2:导出特定规则的数据
+
+```shell
+POST -d '["rule1","rule2"]' http://{{host}}/data/export
+```