创建工作流CreateFlow
更新时间:2024-07-05
接口描述
- 本接口用于创建工作流。
请求结构
POST /v1/flow HTTP/1.1
Host: xflow.bj.baidubce.com
Authorization: authorization string
Content-Type: application/json
请求头域
除公共头域外,无其它特殊头域。
请求参数
参数名称 | 类型 | 是否必需 | 参数位置 | 描述 |
---|---|---|---|---|
name | string | 是 | Body参数 | 工作流的名字,最大长度: 128,最小长度: 1 |
type | string | 是 | Body参数 | 类型,当前为固定值 "FDL" |
definition | string | 是 | Body参数 | 自定义的 yaml,最大长度10000 |
description | string | 否 | Body参数 | 一个简短的说明 0-128字符 |
响应头域
除公共头域,无其它特殊头域。
响应参数
参数名称 | 类型 | 描述 |
---|---|---|
name | string | 工作流的名称,只能由数字、字母、-或_组成,必须以字母或_开头,长度小于64个字符 |
type | string | 类型,当前为固定值 "FDL" |
definition | string | 满足工作流语法规范的 yaml 定义 |
description | string | 工作流描述,0-128字符 |
created_at | string | 工作流创建时间。ISO-8601 格式 (YYYY-MM-DDThh:mm:ss.sTZD) |
updated_at | string | 工作流最新更新时间。ISO-8601 格式 (YYYY-MM-DDThh:mm:ss.sTZD) |
请求示例
POST /v1/flow HTTP/1.1
Host: xflow.bj.baidubce.com
Authorization: authorization string
Content-Type: application/json
{
"name":"testWorkFlow",
"description":"first WorkFlow",
"definition":"name: demo\nstart: initData\nstates:\n - type: pass\n name: initData\n data:\n hello: world\n next: demoSwitch\n - type: switch\n name: demoSwitch\n description: \"using jq expression to decide whether to exec demo\"\n conditions:\n - condition: .execDemo == true\n next: startExec\n - condition: .execDemo == false\n next: stop\n default:\n next: startExec\n - type: parallel\n name: startExec\n next: succ\n branches:\n - start: wait3s\n states:\n - type: wait\n name: wait3s\n seconds: 3\n end: true\n - start: invokeCfc\n states:\n - type: operation\n name: invokeCfc\n resource: \"brn:bce:cfc:bj:7c54a6e14823a11c:function:test:$LATEST\"\n end: true\n catch:\n - errors:\n - XFlow.ALL\n next: errorHandler\n - type: pass\n name: errorHandler\n end: true\n - type: fail\n name: stop\n cause: \"stop demo\"\n - type: succeed\n name: succ",
"type":"FDL"
}
返回示例
HTTP/1.1 201 Created
Content-Type: application/json
{
"description":"first WorkFlow",
"created_at":"2021-12-27 16:20:08",
"name":"testWorkFlow",
"updated_at":"2021-12-27 16:23:37",
"type":"FDL",
"definition":"name: demo\nstart: initData\nstates:\n - type: pass\n name: initData\n data:\n hello: world\n next: demoSwitch\n - type: switch\n name: demoSwitch\n description: \"using jq expression to decide whether to exec demo\"\n conditions:\n - condition: .execDemo == true\n next: startExec\n - condition: .execDemo == false\n next: stop\n default:\n next: startExec\n - type: parallel\n name: startExec\n next: succ\n branches:\n - start: wait3s\n states:\n - type: wait\n name: wait3s\n seconds: 3\n end: true\n - start: invokeCfc\n states:\n - type: operation\n name: invokeCfc\n resource: \"brn:bce:cfc:bj:7c54a6e14823a11c:function:test:$LATEST\"\n end: true\n catch:\n - errors:\n - XFlow.ALL\n next: errorHandler\n - type: pass\n name: errorHandler\n end: true\n - type: fail\n name: stop\n cause: \"stop demo\"\n - type: succeed\n name: succ"
}