更新任务

更新一个已暂停的导入任务。接口只会修改请求中提供的字段。

POST https://moi.matrixorigin.cn/newmoi/task/update

调用前准备

准备有目标工作区访问权限的个人访问令牌、目标工作区 ID 和任务 ID。先查询任务详情确认任务已暂停;未暂停的任务不能更新。

下方示例使用:

  • $AI_STUDIO_API_KEY:实际个人访问令牌,通过 X-API-Key Header 传递。

  • $WORKSPACE_ID:要更新任务的工作区 ID,通过 X-Workspace-ID Header 传递。

  • $TASK_ID:要更新的任务 ID。

请求体

字段

类型

是否必填

说明

task_id

string

要更新的导入任务 ID。

name

string

新任务名称;空字符串不会更新名称。

load_mode_config

object

文件导入的载入模式。提供该对象时,使用其中的字段更新载入计划。

load_mode_config.load_interval_type

integer

载入周期类型:1 每天、2 每小时、3 每分钟、4 一次性、5 每 5 分钟、6 每 10 分钟、7 每 30 分钟、8 每 2 小时、9 每 4 小时、10 每 6 小时、11 每 12 小时。

load_mode_config.interval

integer

周期参数;按天时表示执行小时。

file_filter_config

object

文件筛选配置;提供该对象时整体替换当前文件筛选配置。

file_filter_config.filename_globs

string(字符串数组)

文件名 glob 模式。

file_filter_config.min_file_size

integer

最小文件大小,单位为字节。

file_filter_config.max_file_size

integer

最大文件大小,单位为字节。

file_filter_config.min_create_time

integer

最小创建时间,使用 Unix 时间戳。

file_filter_config.max_create_time

integer

最大创建时间,使用 Unix 时间戳。

file_filter_config.file_types

integer(整数数组)

文件类型筛选代码。

file_filter_config.path_regex

string

文件路径筛选正则表达式。

uris

string(字符串数组)

来源文件 URI 列表;提供该字段时整体替换当前 URI 列表。

请求示例

curl -X POST "https://moi.matrixorigin.cn/newmoi/task/update" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  -d '{
    "task_id": "'$TASK_ID'",
    "name": "import_orders_v2",
    "load_mode_config": {
      "load_interval_type": 4
    }
  }'

成功响应

成功时返回 200datanull

{
  "code": "OK",
  "msg": "OK",
  "data": null
}

响应字段如下。

字段

类型

说明

code

string

成功时为 OK

msg

string

成功时为 OK

data

null

该接口不返回更新后的任务;请重新查询详情确认。

错误响应

{
  "code": "ErrForbidden",
  "msg": "permission denied",
  "data": null
}

常见 HTTP 错误

HTTP 状态码

错误代码

常见原因

建议操作

400

ErrParamInvalid

请求体无效,或任务不处于已暂停状态。

修正 JSON,并先暂停任务。

403

ErrForbidden

调用者没有更新任务的权限。

检查工作区和对象授权。

503

ErrCoreAuthorizeUnavailable

服务暂时无法完成授权检查。

稍后重试。

200

ErrServer

服务未能更新任务。

同时检查 HTTP 状态和 code

后续操作

本接口不返回完整任务对象。用同一任务 ID 查询任务详情确认更新结果。

最后更新于