{
  "tags": [
    "CC 防护"
  ],
  "description": "按路径 ID 更新一条 CC 过滤器，只修改 JSON 对象中明确提供且被服务端支持的字段；JSON 对象内的 `id` 即使存在也会被路径参数覆盖。普通用户只能更新归属于自己的自定义过滤器，管理员可更新其他用户或系统内置过滤器。成功更新时配置版本号必定递增并刷新更新时间，即使请求体为空对象。修改正在使用的关键配置或系统内置过滤器时会创建节点同步任务；禁用过滤器时如仍被 CC 规则引用则拒绝，否则创建节点删除任务。",
  "operationId": "user_put_v1_cc_filters_filter_id",
  "security": [
    {
      "AccessToken": []
    },
    {
      "ApiKey": [],
      "ApiSecret": []
    }
  ],
  "responses": {
    "200": {
      "description": "业务结果通过 HTTP 200 返回。目标过滤器更新并提交后返回确认消息；请求体不是对象、过滤器不存在、访问权限不足、更新字段或 URL 鉴权配置无效、禁用时仍被引用，以及系统维护或认证失效时返回字符串业务错误码，更新事务回滚。",
      "content": {
        "application/json": {
          "schema": {
            "oneOf": [
              {
                "type": "object",
                "required": [
                  "code",
                  "msg",
                  "data"
                ],
                "properties": {
                  "code": {
                    "type": "integer",
                    "enum": [
                      0
                    ],
                    "description": "成功状态码，过滤器更新并提交后固定为 0。"
                  },
                  "msg": {
                    "type": "string",
                    "enum": [
                      "更新过滤器成功"
                    ],
                    "description": "目标过滤器更新成功后返回的确认消息。"
                  },
                  "data": {
                    "type": "string",
                    "nullable": true,
                    "enum": [
                      null
                    ],
                    "description": "单个过滤器更新成功时没有额外业务数据，固定为 null。"
                  }
                },
                "additionalProperties": false
              },
              {
                "type": "object",
                "required": [
                  "code",
                  "msg",
                  "data"
                ],
                "properties": {
                  "code": {
                    "type": "string",
                    "enum": [
                      "cc_filter-6",
                      "cc_filter-8",
                      "cc_filter-11",
                      "cc_filter-13",
                      "cc_filter-16",
                      "cc_filter-17",
                      "cc_filter-19",
                      "cc_filter-20",
                      "cc_filter-22",
                      "cc_filter-23",
                      "cc_filter-25",
                      "cc_filter-26",
                      "cc_filter-28",
                      "cc_filter-29",
                      "cc_filter-30",
                      "cc_filter-37",
                      "cc_filter-38",
                      "cc_filter-39",
                      "cc_filter-40",
                      "cc_filter-41",
                      "cc_filter-42",
                      "cc_filter-43",
                      "cc_filter-44",
                      "cc_filter-45",
                      "cc_filter-46",
                      "cc_filter-47",
                      "cc_filter-48",
                      "cc_filter-49",
                      "cc_filter-50",
                      "cc_filter-53",
                      "cc_filter-54",
                      "cc_filter-56",
                      "cc_filter-57",
                      "maintain",
                      "login_required"
                    ],
                    "description": "业务错误码：6 表示请求体不是 JSON 对象，8 表示过滤器不存在；11、13 表示名称为空或重复；16、17 表示类型为空或无效；19、20、22、23、25、26 表示统计窗口或请求上限为空、格式错误；28 至 30 表示启用状态无效或过滤器仍被 CC 规则引用；37 至 50 表示 URL 鉴权配置或 internal 标记无效；53、54 表示普通用户尝试更新内置或其他用户的过滤器；56、57 表示普通用户使用管理员专属字段；`maintain` 表示当前禁止写操作，`login_required` 表示认证无效。"
                  },
                  "msg": {
                    "type": "string",
                    "description": "与业务错误码对应的中文请求格式、记录、字段校验、引用冲突、权限、维护状态或认证失败原因。"
                  },
                  "data": {
                    "type": "string",
                    "enum": [
                      ""
                    ],
                    "description": "业务错误时固定为空字符串。"
                  }
                },
                "additionalProperties": false
              }
            ]
          },
          "example": {
            "code": 0,
            "msg": "更新过滤器成功",
            "data": null
          }
        }
      }
    }
  },
  "x-python-handler": "site.CCFilterAPI",
  "x-python-route-line": 399,
  "x-audience": "user",
  "x-auth": "user",
  "x-reviewed": true,
  "parameters": [
    {
      "name": "filter_id",
      "in": "path",
      "required": true,
      "description": "要更新的 CC 过滤器 ID；路由只接受十进制整数，记录必须存在且当前身份必须有权更新。",
      "schema": {
        "type": "integer",
        "format": "int64",
        "minimum": 1
      },
      "example": 10021
    }
  ],
  "requestBody": {
    "required": true,
    "content": {
      "application/json": {
        "schema": {
          "type": "object",
          "properties": {
            "name": {
              "type": "string",
              "minLength": 1,
              "maxLength": 255,
              "description": "新的过滤器名称；服务端会过滤可执行的 HTML 内容，处理后不得为空，并且在校验所属用户下不可与其他过滤器重名。"
            },
            "des": {
              "type": "string",
              "maxLength": 255,
              "description": "新的过滤器备注；服务端会过滤可执行的 HTML 内容，可传空字符串清空备注。"
            },
            "type": {
              "type": "string",
              "enum": [
                "easy_click_filter",
                "easy_slide_filter",
                "req_rate",
                "302_challenge",
                "browser_verify_auto",
                "slide_filter",
                "captcha_filter",
                "click_filter",
                "url_auth",
                "delay_jump_filter",
                "rotate_filter"
              ],
              "description": "新的过滤器实现类型；省略时沿用当前类型。更改该字段属于关键配置变更，过滤器正在使用或属于系统内置时会触发节点同步任务。"
            },
            "within_second": {
              "oneOf": [
                {
                  "type": "integer",
                  "minimum": 0
                },
                {
                  "type": "string",
                  "pattern": "^[0-9]+$"
                }
              ],
              "description": "新的请求统计窗口秒数；接受非负整数或仅含十进制数字的字符串，省略时保持原值。"
            },
            "max_req": {
              "oneOf": [
                {
                  "type": "integer",
                  "minimum": 0
                },
                {
                  "type": "string",
                  "pattern": "^[0-9]+$"
                }
              ],
              "description": "新的统计窗口总请求上限；接受非负整数或仅含十进制数字的字符串，省略时保持原值。"
            },
            "max_req_per_uri": {
              "oneOf": [
                {
                  "type": "integer",
                  "minimum": 0
                },
                {
                  "type": "string",
                  "pattern": "^[0-9]+$"
                }
              ],
              "description": "新的单 URI 请求上限。仅目标更新后的类型为 `req_rate` 时校验并写入，必须为非负整数或十进制数字字符串；其他类型会忽略该字段。"
            },
            "extra": {
              "type": "object",
              "properties": {
                "mode": {
                  "type": "string",
                  "enum": [
                    "TypeA",
                    "TypeB"
                  ],
                  "description": "URL 鉴权模式；TypeA 还要求 `time_name`，TypeB 不要求独立的时间戳参数名。"
                },
                "key": {
                  "type": "string",
                  "minLength": 16,
                  "maxLength": 32,
                  "description": "计算 URL 签名使用的密钥，长度必须为 16 至 32 个字符。"
                },
                "sign_name": {
                  "type": "string",
                  "minLength": 1,
                  "description": "请求 URL 中承载签名值的查询参数名，不能为空。"
                },
                "time_name": {
                  "type": "string",
                  "minLength": 1,
                  "description": "TypeA 模式下承载签名时间戳的查询参数名；TypeA 必填且不能为空。"
                },
                "time_diff": {
                  "oneOf": [
                    {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 3600
                    },
                    {
                      "type": "string",
                      "pattern": "^[0-9]+$"
                    }
                  ],
                  "description": "签名时间与服务端时间允许的最大秒数差，必须为不超过 3600 的非负整数。"
                },
                "sign_use_times": {
                  "oneOf": [
                    {
                      "type": "integer",
                      "minimum": 0
                    },
                    {
                      "type": "string",
                      "pattern": "^[0-9]+$"
                    }
                  ],
                  "description": "同一签名允许使用的次数，必须为非负整数或仅含十进制数字的字符串。"
                }
              },
              "additionalProperties": true,
              "description": "新的扩展配置。仅目标更新后的类型为 `url_auth` 时校验并序列化写入，要求 `mode`、`key`、`sign_name`、`time_diff`、`sign_use_times`，TypeA 还要求 `time_name`；其他类型会忽略该字段，附加键会随对象保存。"
            },
            "enable": {
              "type": "integer",
              "enum": [
                0,
                1
              ],
              "description": "新的启用状态：1 表示启用，0 表示禁用。禁用前会检查所有当前用户及系统 CC 规则，仍被引用时返回 `cc_filter-30`。"
            },
            "uid": {
              "type": "integer",
              "format": "int64",
              "minimum": 1,
              "description": "兼容性管理员字段，用作本次名称唯一性和 CC 规则引用检查的用户上下文；仅管理员可传。该字段不会修改过滤器数据库中的所属用户，不能用于转移过滤器。"
            },
            "internal": {
              "type": "integer",
              "enum": [
                0,
                1
              ],
              "description": "兼容性处理标记，1 要求管理员身份并会按内置过滤器流程决定同步任务。该字段不会改写数据库中已有的内置状态，不能用于转换过滤器归类。"
            }
          },
          "additionalProperties": true,
          "description": "单个过滤器的更新对象；可以为空对象，此时只递增版本并刷新更新时间。请求体必须是 JSON 对象，数组、标量或空 JSON 返回 `cc_filter-6`；未识别字段不写入记录，`id` 字段由路径参数覆盖。"
        },
        "example": {
          "name": "严格请求频率限制",
          "within_second": 60,
          "max_req": 80,
          "max_req_per_uri": 15
        }
      }
    }
  },
  "x-itecdn-source-reviewed": true,
  "extensions": [
    {
      "key": "x-python-handler",
      "value": "site.CCFilterAPI"
    },
    {
      "key": "x-python-route-line",
      "value": 399
    },
    {
      "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/cc-filters/{filter_id}",
  "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": {
    "name": "string",
    "des": "string",
    "type": "easy_click_filter",
    "within_second": 0,
    "max_req": 0,
    "max_req_per_uri": 0,
    "extra": {
      "mode": "TypeA",
      "key": "string",
      "sign_name": "string",
      "time_name": "string",
      "time_diff": 0,
      "sign_use_times": 0
    },
    "enable": 0,
    "uid": 0,
    "internal": 0
  },
  "info": {
    "title": "itecdn v5 用户 API",
    "version": "5.x",
    "description": "itecdn v5.x Python 主控用户 API。本文档不适用于 v6 或其它实现。"
  },
  "postman": {
    "name": "更新单个 CC 过滤器",
    "description": {
      "content": "按路径 ID 更新一条 CC 过滤器，只修改 JSON 对象中明确提供且被服务端支持的字段；JSON 对象内的 `id` 即使存在也会被路径参数覆盖。普通用户只能更新归属于自己的自定义过滤器，管理员可更新其他用户或系统内置过滤器。成功更新时配置版本号必定递增并刷新更新时间，即使请求体为空对象。修改正在使用的关键配置或系统内置过滤器时会创建节点同步任务；禁用过滤器时如仍被 CC 规则引用则拒绝，否则创建节点删除任务。",
      "type": "text/plain"
    },
    "url": {
      "path": [
        "v1",
        "cc-filters",
        ":filter_id"
      ],
      "host": [
        "{{baseUrl}}"
      ],
      "query": [],
      "variable": [
        {
          "disabled": false,
          "description": {
            "content": "(Required) 要更新的 CC 过滤器 ID；路由只接受十进制整数，记录必须存在且当前身份必须有权更新。",
            "type": "text/plain"
          },
          "type": "any",
          "value": "",
          "key": "filter_id"
        }
      ]
    },
    "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"
        }
      ]
    }
  }
}