工作空间资源导入¶
POST /api/v1/workspace/resource/upload
概述¶
上传工作空间资源压缩包并发起导入
参数补充说明¶
1. 接口用途
上传工作空间资源压缩包,并发起导入任务。
该接口是异步任务接口。在没有重复冲突时,会返回 taskId;有重复冲突时,不会创建任务,而是直接返回重复信息。
2. 请求类型
请求类型为 multipart/form-data。
必填文件字段:
- files
3. 推荐调用流程
- 先上传
resource.zip并携带各资源的冲突处理参数 - 如果返回
taskId,说明任务已创建,可继续轮询状态接口 - 如果返回
repeat_name/repeat_identifier,说明存在重复,需要调整导入策略后重新提交
4. 返回分支说明
4.1 可直接导入
4.2 存在重复,待调用方确认
{
"repeat_name": {
"checker": ["CPU使用率告警"],
"tag": ["0306"]
},
"repeat_identifier": {
"dashboard": [
{
"identifier": "system_overview",
"existName": "系统概览",
"importName": "系统概览V2"
}
]
}
}
5. 各冲突处理参数说明
5.1 监控器
repeatNameOp- 适用资源:监控器
- 可选值:
check/skip/recover/continue
5.2 仪表板和查看器标识ID
repeatIdentifierOp- 适用资源:仪表板、查看器
- 可选值:
check/skip/recover
5.3 其他新增资源重名处理
以下参数都只支持:
- check
- skip
- recover
包括:
- repeatNotifyObjectNameOp
- repeatAlertPolicyNameOp
- repeatLogBackupCfgNameOp
- repeatSloNameOp
- repeatSecurityRuleNameOp
- repeatFieldNameOp
- repeatLabelNameOp
- repeatEnvVariableNameOp
- repeatRoleNameOp
- repeatLogIndexNameOp
- repeatBlacklistNameOp
- repeatPipelineNameOp
- repeatRegularExpressionNameOp
- repeatFieldDisplayPermissionNameOp
- repeatSensitiveDataScannerNameOp
6. 当前资源边界说明
当前工作空间资源导入导出有以下边界:
- 环境变量不包含
scope=rum - 日志索引不包含外部索引和
default - 字段管理只处理工作空间自定义字段
- 数据访问当前不支持工作空间导入导出
7. 兼容说明
导入时如果压缩包中包含当前不支持或已被忽略的特殊数据,系统会按当前实现规则进行跳过或失败处理,实际结果请以任务状态接口返回为准。
请求例子¶
curl 'https://openapi.guance.com/api/v1/workspace/resource/upload' \
-H 'DF-API-KEY: <DF-API-KEY>' \
-F 'files=@guance.com' \
-F 'repeatNameOp=check' \
-F 'repeatIdentifierOp=check' \
--compressed