更新模型策略接口

替换模型策略组的配置,包含模式、人员范围、资源范围、有效时间和状态,集合字段提交完整保留值。默认组的名称、模式、人员范围类型和状态固定,不能通过更新改变。

所需权限

所需权限资源Scope资源服务
模型策略管理(管理)model-policiesadmin.v1.model-policies.manageqwenwork-biz-service

PATCH /api/openapi/v1/model-policies/{policyId}

认证与请求头

使用应用 API Key 调用。当前接口校验上方独立 Scope;读取、管理与执行权限互不包含。

名称位置类型必填说明示例
Authorizationheaderstring应用 API Key,使用 Bearer 方式传递。Bearer qwk_\\*
X-Request-Idheaderstring可选的调用追踪标识;未传入时由服务端生成。req-20260831-001

请求参数

名称位置类型必填说明示例
policyIdpathstring · uuid必填需要操作的策略标识。"<uuid>"
descriptionbodystring资源策略组的用途说明。"<string>"
display_orderbodyinteger · int64展示顺序的排序值。0
modebodystring必填策略模式:allowlist 为允许所选资源,denylist 为限制所选资源。"allowlist"
namebodystring必填资源策略组的名称。"<string>"
resource_idsbodyarray | null必填策略作用的资源标识列表。["<string>"]
resource_scopebodystring必填资源范围:all 为全部资源,selected 为指定资源。"all"
statusbodystring此记录当前所处的状态。 可选值:enabled、disabled。"enabled"
subject_scopebodystring必填用户范围:all_users 为所有用户,selected 为指定对象。"all_users"
subjectsbodyarray | null必填策略或任务选择的范围对象列表。[{"include_descendants":false,"subject_id":"<string>","subject_type":"user"}]
subjects[].include_descendantsbodyboolean选择部门时,是否同时包含该部门的下级部门。false
subjects[].subject_idbodystring必填所选用户、部门或用户组的标识,与 subject_type 配合使用。"<string>"
subjects[].subject_typebodystring必填范围对象类型:user 为用户,org_unit 为部门,user_group 为用户组。"user"
surfacesbodyarray | null必填策略适用的入口,当前仅支持 qwenwork_pc;未填写时使用该入口。["<string>"]
valid_frombodystring · date-time策略有效时间范围的起点。"2026-08-27T10:00:00Z"
valid_tobodystring · date-time策略有效时间范围的终点。"2026-08-27T10:00:00Z"

请求示例

将 <BASE_URL> 替换为企业部署的千问办公 API 服务地址,并填写实际参数。示例中的占位值不能直接用于请求。

curl --request PATCH --url '<BASE_URL>/api/openapi/v1/model-policies/<policyId>' --header 'Authorization: Bearer <API_KEY>' --header 'Content-Type: application/json' --data '{  "description": "<string>",  "display_order": 0,  "mode": "allowlist",  "name": "<string>",  "resource_ids": ["<string>"  ],  "resource_scope": "all",  "status": "enabled",  "subject_scope": "all_users",  "subjects": [{"include_descendants": false,"subject_id": "<string>","subject_type": "user"}  ],  "surfaces": ["<string>"  ],  "valid_from": "2026-08-27T10:00:00Z",  "valid_to": "2026-08-27T10:00:00Z"}'

响应

200 请求成功,返回当前或更新后的数据。

名称类型必填说明示例
created_atstring · date-time此记录的创建时间。"2026-08-27T10:00:00Z"
defaultboolean是否为默认策略组。false
descriptionstring资源策略组的用途说明。"<string>"
idstring此记录的唯一标识,查询、更新或删除对应记录时使用。"<string>"
modestring策略模式:allowlist 为允许所选资源,denylist 为限制所选资源。"<string>"
namestring资源策略组的名称。"<string>"
policy_typestring策略组管理的资源类型。"<string>"
resource_countinteger · int64策略所选资源的数量。0
resource_scopestring资源范围:all 为全部资源,selected 为指定资源。"<string>"
statusstring此记录当前所处的状态。"<string>"
subject_countinteger · int64策略所选范围对象的数量。0
subject_countsobject按对象类型统计的策略范围对象数量。{}
subject_scopestring用户范围:all_users 为所有用户,selected 为指定对象。"<string>"
surfacesarray | null策略适用的入口,当前仅支持 qwenwork_pc;未填写时使用该入口。["<string>"]
updated_atstring · date-time此记录最后一次更新的时间。"2026-08-27T10:00:00Z"
{
  "created_at": "2026-08-27T10:00:00Z",
  "default": false,
  "description": "<string>",
  "id": "<string>",
  "mode": "<string>",
  "name": "<string>",
  "policy_type": "<string>",
  "resource_count": 0,
  "resource_scope": "<string>",
  "status": "<string>",
  "subject_count": 0,
  "subject_counts": {},
  "subject_scope": "<string>",
  "surfaces": [
    "<string>"
  ],
  "updated_at": "2026-08-27T10:00:00Z"
}

default 请求失败,返回错误码和错误详情。

名称类型必填说明示例
codestring用于程序判断错误原因的稳定业务错误码。"<string>"
detailstring便于阅读的错误说明。"<string>"
detailsOpenapiErrorDetails字段校验失败时的详细信息。{"field":"<string>","reason":"<string>","suggestion":"<string>"}
details.fieldstring未通过校验的请求字段。"<string>"
details.reasonstring稳定的校验失败原因,用于判断字段为何不合法。"<string>"
details.suggestionstring建议采用的规范化字段值。"<string>"
errorstring稳定的 HTTP 错误类型。"<string>"
{
  "code": "<string>",
  "detail": "<string>",
  "details": {
    "field": "<string>",
    "reason": "<string>",
    "suggestion": "<string>"
  },
  "error": "<string>"
}