feat(platform): 新增自建应用子域 API/Service 层

新增 api/platform/ 子包(对齐 api/sealai/ 结构):
- platform_api: list_platforms(DataLink Platform 列表)
- easo_client: EasoClient + get_easo_client()(EASO Bearer JWT 认证)
- workflow_api: list_workflows / get_workflow_stats / get_workflow_charge
- schemas: Platform / Workflow* 模型(从全局 schemas.py 独立出来)

新增 services/platform/ 子包:
- list_platforms / list_platforms_cmd
- list_workflows / get_workflow_stats / get_workflow_charge 及 _cmd 变体

全局 api/schemas.py 清理 platform/workflow 相关模型,只保留通用结构。
未实现子模块(entity/page/card/variable/log)在各层以 README 预留。
This commit is contained in:
gitea committed 2026-04-16 17:54:35 +08:00
1 parent f7c065f59b
commit 474349e7e4
14 files changed
+644

No files matched your search

@@ -0,0 +1,66 @@
"""Service 层:工作流(EASO Pipeline)业务逻辑
域:unity.ekuaibao.com(EASO 子系统)
认证:EasoClient(Bearer JWT,通过 get_easo_client() 获取)
职责:
- 分页列出指定自建应用下的工作流
- 查询工作流执行统计
- 查询企业工作流配额
- 统一抛出 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.workflow_api import (
list_workflows as api_list_workflows,
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_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_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)