Skip to content

POST /workflows/from-yaml

定义

校验 Workflow YAML(apiVersion: uniflow/v1),解析 usesbindings,将工作流注册到 Orchestrator 内存 Registry。

用途

  • 跨语言场景:Python / Java SDK 上传 YAML + HTTP bindings
  • 无需预编译 TS 插件即可挂载远程 HTTP Unit
  • CI 注册临时工作流进行集成测试

方法与路径

项目
方法POST
路径/workflows/from-yaml
Content-Typeapplication/json

请求 Body

字段类型必填说明
yamlstring完整 Workflow YAML 文本
bindingsUsesBindings远程 Unit 映射,见下表

bindings 条目

字段类型必填说明
<usesName>object键为 YAML 中 uses 字符串
type"http"当前仅支持 HTTP
endpointstringRemote Unit POST 地址
headersRecord<string, string>附加 HTTP 头

Remote Unit 请求/响应格式:Remote Unit HTTP Contract

响应

成功: 201 Created

字段类型说明
workflowIdstring来自 metadata.id
notestring提示 Registry 为内存态
json
{
  "workflowId": "cross-lang-greeter",
  "note": "Registry is in-memory; re-register after Orchestrator restart."
}

错误

状态码条件Body
400缺少 yaml 或为空{ "error": "body.yaml (string) is required" }
400Schema / 加载错误{ "error": "<message>", "type": "YamlValidationError" | "YamlLoadError" }
500其他内部错误{ "error": "<message>", "type": "Error" }

示例

bash
curl -X POST http://127.0.0.1:8787/workflows/from-yaml \
  -H "Content-Type: application/json" \
  -d '{
    "yaml": "apiVersion: uniflow/v1\nkind: Workflow\nmetadata:\n  id: demo\nspec:\n  units:\n    - id: greet\n      uses: demo.greeter\n  flow:\n    type: sequential\n    order: [greet]",
    "bindings": {
      "demo.greeter": {
        "type": "http",
        "endpoint": "http://127.0.0.1:9101/execute"
      }
    }
  }'

TypeScript SDK:

typescript
await client.loadAndRegister(yamlText, {
  'demo.greeter': { type: 'http', endpoint: 'http://127.0.0.1:9101/execute' },
});

相关

MIT Licensed