itecdn 5.x / 用户 API
更新指定用户配置
PUT
/v1/user-configs/{config_id}更新一个用户配置。路径中的 config_id 会覆盖请求体 ID,请求体必须是 JSON 对象。普通用户只能更新自己的配置;管理员可更新其他用户配置。更新时配置值与作用域会重新校验,名称与类型不写入数据库但仍用于校验。
身份认证
access-token
api-key + api-secret
认证定义
{
"AccessToken": {
"type": "apiKey",
"in": "header",
"name": "access-token",
"description": "通过登录接口获得的短期访问令牌。"
},
"ApiKey": {
"type": "apiKey",
"in": "header",
"name": "api-key",
"description": "API Key;必须和 api-secret 同时发送。"
},
"ApiSecret": {
"type": "apiKey",
"in": "header",
"name": "api-secret",
"description": "API Secret;必须和 api-key 同时发送。"
}
}请求参数
| 参数 | 位置 | 类型 | 必填 | 说明与约束 |
|---|---|---|---|---|
config_id | path | integer | 必填 | 要更新的用户配置 ID,必须存在且当前用户有权限操作。 完整参数定义 |
请求体 · 必填
application/json
object
| 字段 | 类型 | 必填 | 说明与约束 |
|---|---|---|---|
name | string | 可选 | 配置项名称;更新时不写入数据库,但用于 value 校验和配置唯一性检查。未传时使用原名称。 |
value | string | 可选 | 配置值;按照 name 与 type 对应的服务端规则校验。未传时使用原值。 |
type | string | 可选 | 配置类型;更新时不写入数据库,但用于 value 校验。未传时使用原类型。 约束 / 默认值 / 示例 |
scope_name | string | 可选 | 作用域名称;global 时 scope_id 固定为 0。 约束 / 默认值 / 示例 |
scope_id | integer | 可选 | 作用域 ID;分组作用域必须存在对应的网站组或转发组。 约束 / 默认值 / 示例 |
enable | integer | 可选 | 启用状态。 约束 / 默认值 / 示例 |
uid | integer | 可选 | 管理员专用。指定操作用户;不会改变已有配置的归属。 |
完整 Schema
{
"type": "object",
"additionalProperties": false,
"properties": {
"name": {
"type": "string",
"description": "配置项名称;更新时不写入数据库,但用于 value 校验和配置唯一性检查。未传时使用原名称。"
},
"value": {
"type": "string",
"description": "配置值;按照 name 与 type 对应的服务端规则校验。未传时使用原值。"
},
"type": {
"type": "string",
"enum": [
"site",
"stream",
"cert"
],
"description": "配置类型;更新时不写入数据库,但用于 value 校验。未传时使用原类型。"
},
"scope_name": {
"type": "string",
"enum": [
"global",
"group"
],
"description": "作用域名称;global 时 scope_id 固定为 0。"
},
"scope_id": {
"type": "integer",
"minimum": 0,
"description": "作用域 ID;分组作用域必须存在对应的网站组或转发组。"
},
"enable": {
"type": "integer",
"enum": [
0,
1
],
"description": "启用状态。"
},
"uid": {
"type": "integer",
"description": "管理员专用。指定操作用户;不会改变已有配置的归属。"
}
},
"example": {
"value": "[]",
"enable": 1
}
}请求体示例
{
"value": "[]",
"enable": 1
}响应
HTTP 200
请求已被处理。成功时 code 为 0、msg 为“更新用户配置成功”、data 为 null;配置不存在、请求体非对象、值或作用域无效、无权限时仍返回 HTTP 200。
application/json
object
| 字段 | 类型 | 必填 | 说明与约束 |
|---|---|---|---|
code | integer | 必填 | 业务状态码;成功为 0。 约束 / 默认值 / 示例 |
msg | string | 必填 | 处理结果说明。 约束 / 默认值 / 示例 |
data | string | 必填 | 成功时为 null;失败时为空字符串。 约束 / 默认值 / 示例 |
完整 Schema
{
"type": "object",
"required": [
"code",
"msg",
"data"
],
"properties": {
"code": {
"type": "integer",
"description": "业务状态码;成功为 0。",
"example": 0
},
"msg": {
"type": "string",
"description": "处理结果说明。",
"example": "更新用户配置成功"
},
"data": {
"type": "string",
"nullable": true,
"description": "成功时为 null;失败时为空字符串。",
"example": null
}
}
}示例
{
"code": 0,
"msg": "更新用户配置成功",
"data": null
}更新成功
{
"code": 0,
"msg": "更新用户配置成功",
"data": null
}请求体不是对象
{
"code": "user_config-13",
"msg": "需要字典格式",
"data": ""
}cURL 示例
根据文档生成;请替换主控地址、路径参数和凭证,并按上表补充查询参数。
curl --request PUT \
"https://master.example.invalid/v1/user-configs/{config_id}" \
--header "access-token: YOUR_ACCESS_TOKEN" \
--header "Content-Type: application/json" \
--data '{"value": "[]", "enable": 1}'