{
  "tags": [
    "用户默认配置"
  ],
  "description": "更新一个或多个用户配置。请求体可为单个对象或对象数组，单个对象会转换为数组。每个对象必须提供已有配置 ID；`name` 与 `type` 在更新时仍参与值和唯一性校验，但数据库只更新 value、作用域和启用状态。普通用户只能操作自己的配置，管理员可操作其他用户配置。",
  "operationId": "user_put_v1_user_configs",
  "security": [
    {
      "AccessToken": []
    },
    {
      "ApiKey": [],
      "ApiSecret": []
    }
  ],
  "responses": {
    "200": {
      "description": "请求已被处理。成功时 `code` 为 0、`msg` 为“更新用户配置成功”、`data` 为 null；请求格式、配置 ID、配置值、作用域或权限不正确时仍返回 HTTP 200。",
      "content": {
        "application/json": {
          "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
              }
            }
          },
          "examples": {
            "success": {
              "summary": "更新成功",
              "value": {
                "code": 0,
                "msg": "更新用户配置成功",
                "data": null
              }
            },
            "notFound": {
              "summary": "配置不存在",
              "value": {
                "code": "user_config-4",
                "msg": "user config id不存在",
                "data": ""
              }
            }
          },
          "example": {
            "code": 0,
            "msg": "更新用户配置成功",
            "data": null
          }
        }
      }
    }
  },
  "x-python-handler": "config.UserConfigAPI",
  "x-python-route-line": 613,
  "x-audience": "user",
  "x-auth": "user",
  "x-reviewed": true,
  "parameters": [],
  "requestBody": {
    "required": true,
    "content": {
      "application/json": {
        "schema": {
          "oneOf": [
            {
              "type": "object",
              "description": "单个配置更新对象。",
              "additionalProperties": false,
              "required": [
                "id"
              ],
              "properties": {
                "id": {
                  "type": "integer",
                  "minimum": 1,
                  "description": "必填。用户配置 ID。"
                },
                "name": {
                  "type": "string",
                  "description": "配置项名称；更新时不写入数据库，但用于校验 value 与配置唯一性。未传时使用原名称。"
                },
                "value": {
                  "type": "string",
                  "description": "配置值；按 name 与 type 的服务端规则校验。未传时使用原值。"
                },
                "type": {
                  "type": "string",
                  "enum": [
                    "site",
                    "stream",
                    "cert"
                  ],
                  "description": "配置类型；更新时不写入数据库，但用于校验。未传时使用原类型。"
                },
                "scope_name": {
                  "type": "string",
                  "enum": [
                    "global",
                    "group"
                  ],
                  "description": "作用域名称；全局作用域强制 scope_id 为 0。"
                },
                "scope_id": {
                  "type": "integer",
                  "minimum": 0,
                  "description": "作用域 ID；分组作用域时必须存在对应的网站组或转发组。"
                },
                "enable": {
                  "type": "integer",
                  "enum": [
                    0,
                    1
                  ],
                  "description": "启用状态。"
                },
                "uid": {
                  "type": "integer",
                  "description": "管理员专用。指定操作用户；不会改变已有配置的归属。"
                }
              }
            },
            {
              "type": "array",
              "minItems": 1,
              "description": "批量更新对象数组。",
              "items": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "id"
                ],
                "properties": {
                  "id": {
                    "type": "integer",
                    "description": "用户配置 ID。"
                  },
                  "value": {
                    "type": "string",
                    "description": "配置值。"
                  },
                  "scope_name": {
                    "type": "string",
                    "description": "作用域名称。"
                  },
                  "scope_id": {
                    "type": "integer",
                    "description": "作用域 ID。"
                  },
                  "enable": {
                    "type": "integer",
                    "enum": [
                      0,
                      1
                    ],
                    "description": "启用状态。"
                  }
                }
              }
            }
          ],
          "example": {
            "id": 9,
            "value": "[]",
            "enable": 1
          }
        }
      }
    }
  },
  "x-itecdn-source-reviewed": true,
  "extensions": [
    {
      "key": "x-python-handler",
      "value": "config.UserConfigAPI"
    },
    {
      "key": "x-python-route-line",
      "value": 613
    },
    {
      "key": "x-audience",
      "value": "user"
    },
    {
      "key": "x-auth",
      "value": "user"
    },
    {
      "key": "x-reviewed",
      "value": true
    },
    {
      "key": "x-itecdn-source-reviewed",
      "value": true
    }
  ],
  "method": "put",
  "path": "/v1/user-configs",
  "servers": [
    {
      "url": "https://master.example.invalid",
      "description": "不可调用的示例地址；复制示例后替换为自己的主控域名。"
    }
  ],
  "securitySchemes": {
    "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 同时发送。"
    }
  },
  "jsonRequestBodyExample": {
    "id": 9,
    "value": "[]",
    "enable": 1
  },
  "info": {
    "title": "itecdn v5 用户 API",
    "version": "5.x",
    "description": "itecdn v5.x Python 主控用户 API。本文档不适用于 v6 或其它实现。"
  },
  "postman": {
    "name": "批量更新用户配置",
    "description": {
      "content": "更新一个或多个用户配置。请求体可为单个对象或对象数组，单个对象会转换为数组。每个对象必须提供已有配置 ID；`name` 与 `type` 在更新时仍参与值和唯一性校验，但数据库只更新 value、作用域和启用状态。普通用户只能操作自己的配置，管理员可操作其他用户配置。",
      "type": "text/plain"
    },
    "url": {
      "path": [
        "v1",
        "user-configs"
      ],
      "host": [
        "{{baseUrl}}"
      ],
      "query": [],
      "variable": []
    },
    "header": [
      {
        "key": "Content-Type",
        "value": "application/json"
      },
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "method": "PUT",
    "body": {
      "mode": "raw",
      "raw": "",
      "options": {
        "raw": {
          "language": "json"
        }
      }
    },
    "auth": {
      "type": "apikey",
      "apikey": [
        {
          "type": "any",
          "value": "access-token",
          "key": "key"
        },
        {
          "type": "any",
          "value": "{{apiKey}}",
          "key": "value"
        },
        {
          "type": "any",
          "value": "header",
          "key": "in"
        }
      ]
    }
  }
}