feat(platform): 新增工作流详情接口(节点列表)

新域名:piper.ekuaibao.com,用 EASO JWT(aud=EASO)+ platformid Header 认证。
与已有的 unity.ekuaibao.com 工作流列表接口并列,认证链路不同:
  - unity: accessToken → hose-token → UNITY JWT → EASO realm token
  - piper: accessToken → hose-token → EASO JWT(直接使用)

新增内容:
- api/platform/piper_client.py:PiperClient + get_piper_client()
- api/platform/schemas.py:WorkflowDetail / WorkflowAlarm
- api/platform/workflow_api.py:get_workflow()
- services/platform/workflow_service.py:get_workflow() / get_workflow_cmd()
- commands/platform/workflow_get.py:ekb platform workflow-get <platform_id> <wf_id>
- server/platform_router.py:GET /platforms/{id}/workflows/{wf_id}
This commit is contained in:
gitea committed 2026-04-17 10:48:48 +08:00
1 parent 98f3000b2e
commit 6019691808
8 files changed
+363 -23

No files matched your search

@@ -1,24 +1,87 @@
"""Service 层:工作流(EASO Pipeline)业务逻辑
域:unity.ekuaibao.com(EASO 子系统)
认证:EasoClient(Bearer JWT,通过 get_easo_client() 获取)
域:
- unity.ekuaibao.com(EasoClient):列表 / 统计 / 配额
- piper.ekuaibao.com(PiperClient):工作流配置详情
职责:
- 分页列出指定自建应用下的工作流
- 获取单个工作流完整配置(节点列表)
- 查询工作流执行统计
- 查询企业工作流配额
- 统一抛出 EkbError 子类,不关心上层如何渲染
"""
from ekb_cli.api.platform.easo_client import EasoClient, get_easo_client
from ekb_cli.api.platform.schemas import WorkflowPage, WorkflowStats, WorkflowCharge
from ekb_cli.api.platform.piper_client import PiperClient, get_piper_client
from ekb_cli.api.platform.schemas import WorkflowPage, WorkflowStats, WorkflowCharge, WorkflowDetail
from ekb_cli.api.platform.workflow_api import (
list_workflows as api_list_workflows,
get_workflow as api_get_workflow,
get_workflow_stats as api_get_workflow_stats,
get_workflow_charge as api_get_workflow_charge,
)
# ── 查询 ─────────────────────────────────────────────────────
def list_workflows(
client: EasoClient,
platform_id: str,
page: int = 1,
page_size: int = 20,
) -> WorkflowPage:
"""列出指定自建应用下的工作流(分页)"""
return api_list_workflows(client, platform_id, page, page_size)
def get_workflow(client: PiperClient, pipeline_id: str) -> WorkflowDetail:
"""获取单个工作流的完整配置(包含所有节点及参数)"""
return api_get_workflow(client, pipeline_id)
def get_workflow_stats(client: EasoClient, platform_id: str) -> WorkflowStats:
"""获取指定自建应用的工作流执行统计"""
return api_get_workflow_stats(client, platform_id)
def get_workflow_charge(client: EasoClient) -> WorkflowCharge:
"""获取企业工作流资源包/配额"""
return api_get_workflow_charge(client)
# ── CLI 便捷函数(自管 client 生命周期)────────────────────────
# commands/* 层调用这批函数,保持 commands → services → api 依赖方向。
def list_workflows_cmd(
platform_id: str,
page: int = 1,
page_size: int = 20,
) -> WorkflowPage:
"""CLI 便捷函数:自动获取 EasoClient 并列出工作流"""
with get_easo_client() as client:
return list_workflows(client, platform_id, page, page_size)
def get_workflow_cmd(platform_id: str, pipeline_id: str) -> WorkflowDetail:
"""CLI 便捷函数:自动获取 PiperClient 并查询工作流完整配置"""
with get_piper_client(platform_id) as client:
return get_workflow(client, pipeline_id)
def get_workflow_stats_cmd(platform_id: str) -> WorkflowStats:
"""CLI 便捷函数:自动获取 EasoClient 并查询工作流统计"""
with get_easo_client() as client:
return get_workflow_stats(client, platform_id)
def get_workflow_charge_cmd() -> WorkflowCharge:
"""CLI 便捷函数:自动获取 EasoClient 并查询工作流配额"""
with get_easo_client() as client:
return get_workflow_charge(client)
# ── 查询 ─────────────────────────────────────────────────────
def list_workflows(