重构:api层拆分 agent/rule,引入 Pydantic 校验,统一 re-export,补充 README.api.md
This commit is contained in:
1 parent
c3c389146f
commit
4466af7726
16 files changed
+487
-216
No files matched your search
@@ -0,0 +1,26 @@
|
||||
"""Rule(审核规则)相关 API 调用封装"""
|
||||
|
||||
from ekb_cli.api import EkbClient
|
||||
from ekb_cli.api.schemas import (
|
||||
EkbResponse, PageData, Rule, RuleWithAgents
|
||||
)
|
||||
|
||||
|
||||
def list_rules(client: EkbClient, page: int = 1, size: int = 1000) -> PageData[RuleWithAgents]:
|
||||
raw = client.get("/engine/hab/agent/rule/list", page=page, size=size)
|
||||
resp = EkbResponse[PageData[RuleWithAgents]].model_validate(raw)
|
||||
return resp.data
|
||||
|
||||
|
||||
def save_rule(client: EkbClient, payload: dict) -> Rule:
|
||||
"""新建规则:payload 包含 purpose / description / level"""
|
||||
raw = client.post("/engine/hab/agent/rule/save", payload)
|
||||
resp = EkbResponse[Rule].model_validate(raw)
|
||||
return resp.data
|
||||
|
||||
|
||||
def update_rule(client: EkbClient, payload: dict) -> Rule:
|
||||
"""更新规则:payload 包含 id / code / purpose / description / level"""
|
||||
raw = client.post("/engine/hab/agent/rule/update", payload)
|
||||
resp = EkbResponse[Rule].model_validate(raw)
|
||||
return resp.data
|
||||
Reference in new issue
Block a user