重构第2批:API 层加固 + 新增 service 层
api/__init__.py: - EkbClient.get/post 捕获 HTTP 错误,转换为 AuthenticationError / ApiResponseError;识别快报 errorCode=401 结构 - get_client() 改为抛出 NotLoggedInError(原为 RuntimeError) - 新增 close() 方法便于非 with 场景使用 新增 services/ 目录(业务逻辑层): - auth_service.py:企业认证配置的增删查改,返回 CorpInfo dataclass - agent_service.py:Agent CRUD + copy + 高阶组合查询 get_dedup_rules_across_agents AgentCreateInput / AgentUpdateInput dataclass 统一输入结构 - rule_service.py:Rule 查询(支持按编码/ID 查找)+ CRUD - __init__.py:统一 re-export,上层只从此处导入
This commit is contained in:
1 parent
4faba77234
commit
475ce518f9
5 files changed
+491
-10
No files matched your search
@@ -0,0 +1,36 @@
|
||||
"""Service 层统一 re-export
|
||||
|
||||
commands / server 从此处导入所有 service 函数,
|
||||
内部模块拆分对上层透明。
|
||||
"""
|
||||
|
||||
from ekb_cli.services.auth_service import ( # noqa: F401
|
||||
CorpInfo,
|
||||
CorpDetail,
|
||||
list_corps,
|
||||
whoami,
|
||||
add_corp,
|
||||
use_corp,
|
||||
remove_corp,
|
||||
)
|
||||
from ekb_cli.services.agent_service import ( # noqa: F401
|
||||
AgentCreateInput,
|
||||
AgentUpdateInput,
|
||||
MODE_NAMES,
|
||||
MODE_DISPLAY,
|
||||
DEFAULT_ICON,
|
||||
list_agents,
|
||||
get_agent,
|
||||
create_agent,
|
||||
copy_agent,
|
||||
update_agent,
|
||||
delete_agent,
|
||||
get_dedup_rules_across_agents,
|
||||
)
|
||||
from ekb_cli.services.rule_service import ( # noqa: F401
|
||||
VALID_LEVELS,
|
||||
list_rules,
|
||||
get_rule,
|
||||
create_rule,
|
||||
update_rule,
|
||||
)
|
||||
Reference in new issue
Block a user