此技能是 HIPC 系列技能的 核心前置组件,用于管理 API 密钥( hipc_secret)的生命周期。
它具备 检查、 设置 和 格式校验 三种能力,确保在执行任何业务查询前,系统拥有合法且格式正确的访问凭证。
在调用任何 HIPC 业务技能(如查询电脑列表、统计数据)之前,你必须先调用本技能!
第一步:调用 hipc_config_manager,设置参数 action="check"。
判断:
status: "error"(即密钥缺失), 立即停止 后续业务操作, 直接向用户发送一条消息,提示需要配置密钥。status: "success" 时,才允许继续执行用户请求的业务逻辑。本技能通过读写本地文件 hipc_config.json 来持久化存储密钥。
检查模式 ( check):
hipc_config.json 文件。hipc_secret 字段是否存在且非空。设置模式 ( set):
secret 和 env。数字_字符串 的格式,例如 35097_y2GX...)。hipc_config.json 文件,覆盖旧值。action (String, 必填):
"check"(检查配置)或 "set"(保存配置)。secret (String, 可选):
action="set" 时 必填。env (String, 可选):
action="set" 时使用,指定要配置的环境。场景 A:业务前置检查(配置存在)
hipc_config_manager,参数 action="check"。status: "success"。hipc_computer_list 技能。场景 B:业务前置检查(配置缺失)
hipc_config_manager,参数 action="check"。status: "error"。场景 C:用户主动配置密钥(格式正确)
hipc_config_manager,参数 action="set", secret="35097_y2GX52eDGNdgaM", env="prod"。status: "success"。场景 D:用户配置密钥(格式错误)
hipc_config_manager,参数 action="set", secret="35097_y2GX52eDGNdgaM", env="prod"。数字_ 前缀),返回 status: "error"。数字_ 开头(例如 35097_xxxxx),请检查后重新提供。”bash
python scripts/main.py --action={{action}}{{#if secret}} --secret={{secret}}{{/if}}{{#if env}} --env={{env}}{{/if}}