{
  "tags": [
    "访问控制"
  ],
  "description": "根据路径中的 ACL ID 局部更新一条 ACL。请求体必须是 JSON 对象，只需提交要修改的字段；服务端会将路径 `acl_id` 作为真实目标 ID，即使请求体包含 `id` 也会被路径值覆盖。普通用户只能更新自己的 ACL，管理员可更新其他用户的 ACL。修改已被网站引用且处于启用状态的 ACL 时会创建同步任务；禁用 ACL 时会创建删除任务，但仍被网站引用的 ACL 不允许直接禁用。",
  "operationId": "user_put_v1_acls_acl_id",
  "security": [
    {
      "AccessToken": []
    },
    {
      "ApiKey": [],
      "ApiSecret": []
    }
  ],
  "responses": {
    "200": {
      "description": "请求始终通过 HTTP 200 返回。单条 ACL 更新成功时返回确认消息；请求体不是对象、ACL 不存在或无权限、字段或嵌套规则校验失败、ACL 仍被网站引用而尝试禁用时，通过字符串 `code` 和 `msg` 返回业务错误，当前更新事务会回滚。",
      "content": {
        "application/json": {
          "schema": {
            "oneOf": [
              {
                "type": "object",
                "required": [
                  "code",
                  "msg",
                  "data"
                ],
                "properties": {
                  "code": {
                    "type": "integer",
                    "enum": [
                      0
                    ],
                    "description": "成功状态码，ACL 更新成功时固定为 0。"
                  },
                  "msg": {
                    "type": "string",
                    "enum": [
                      "更新ACL成功"
                    ],
                    "description": "ACL 更新并提交事务后返回的确认消息。"
                  },
                  "data": {
                    "type": "string",
                    "nullable": true,
                    "enum": [
                      null
                    ],
                    "description": "单条更新成功时没有额外业务数据，固定为 null。"
                  }
                },
                "additionalProperties": false
              },
              {
                "type": "object",
                "required": [
                  "code",
                  "msg",
                  "data"
                ],
                "properties": {
                  "code": {
                    "type": "string",
                    "description": "业务错误码。常见值包括请求体格式错误 `acl-5`、ID 错误或资源不存在 `acl-6/acl-7`、权限错误 `acl-42/acl-43`、名称错误 `acl-9/acl-11`、默认动作错误 `acl-14/acl-15`、规则错误 `acl-17` 至 `acl-25`、启用状态错误 `acl-27/acl-28/acl-29` 以及重定向错误 `acl-35` 至 `acl-40`。"
                  },
                  "msg": {
                    "type": "string",
                    "description": "与业务错误码对应的中文校验失败或权限错误原因。"
                  },
                  "data": {
                    "type": "string",
                    "enum": [
                      ""
                    ],
                    "description": "业务错误时固定为空字符串。"
                  }
                },
                "additionalProperties": false
              }
            ]
          },
          "example": {
            "code": 0,
            "msg": "更新ACL成功",
            "data": null
          }
        }
      }
    }
  },
  "x-python-handler": "site.AclAPI",
  "x-python-route-line": 375,
  "x-audience": "user",
  "x-auth": "user",
  "x-reviewed": true,
  "parameters": [
    {
      "name": "acl_id",
      "in": "path",
      "required": true,
      "description": "要更新的 ACL ID；目标必须存在且当前身份有权管理。",
      "schema": {
        "type": "integer",
        "format": "int64",
        "minimum": 1
      },
      "example": 1
    }
  ],
  "requestBody": {
    "required": true,
    "content": {
      "application/json": {
        "schema": {
          "type": "object",
          "properties": {
            "id": {
              "type": "integer",
              "format": "int64",
              "deprecated": true,
              "description": "兼容字段；如传入会被忽略，实际目标始终由路径中的 `acl_id` 决定。"
            },
            "name": {
              "type": "string",
              "minLength": 1,
              "description": "新的 ACL 名称；不能为空，且在 ACL 所属用户下必须唯一。"
            },
            "des": {
              "type": "string",
              "description": "新的 ACL 备注说明，可设置为空字符串。"
            },
            "default_action": {
              "type": "string",
              "enum": [
                "reject",
                "allow"
              ],
              "description": "所有规则均未匹配时执行的新默认动作：`reject` 拒绝请求，`allow` 放行请求。"
            },
            "reject_code": {
              "type": "string",
              "enum": [
                "403",
                "302"
              ],
              "description": "默认拒绝动作使用的新响应方式；403 表示直接拒绝，302 表示重定向。"
            },
            "redirect_url": {
              "type": "string",
              "description": "新的默认重定向地址；最终 `reject_code` 为 302 时不能为空。"
            },
            "data": {
              "type": "array",
              "minItems": 1,
              "description": "替换现有配置的完整 ACL 规则数组；条目数不得超过系统配置的 `acl-max-limit`。",
              "items": {
                "type": "object",
                "required": [
                  "acl_action",
                  "acl_matcher"
                ],
                "properties": {
                  "acl_action": {
                    "type": "string",
                    "enum": [
                      "reject",
                      "allow"
                    ],
                    "description": "该条规则匹配后执行的动作：`reject` 拒绝请求，`allow` 放行请求。"
                  },
                  "acl_code": {
                    "type": "string",
                    "enum": [
                      "403",
                      "302"
                    ],
                    "default": "403",
                    "description": "该条规则执行 `reject` 时使用的响应方式；省略时为 403。"
                  },
                  "acl_url": {
                    "type": "string",
                    "default": "",
                    "description": "该条规则的 `acl_code` 为 302 时必填的重定向地址。"
                  },
                  "acl_matcher": {
                    "type": "array",
                    "description": "该条 ACL 规则的新匹配条件；每个条件由匹配项、操作符和值组成。",
                    "items": {
                      "type": "object",
                      "required": [
                        "item",
                        "op"
                      ],
                      "properties": {
                        "item": {
                          "type": "string",
                          "enum": [
                            "count404",
                            "uniq_ua",
                            "header",
                            "ip",
                            "host",
                            "accept_language",
                            "user_agent",
                            "referer",
                            "uri",
                            "req_uri",
                            "req_method",
                            "country_iso_code",
                            "asnumber",
                            "province",
                            "city",
                            "isp",
                            "protocol",
                            "tls_fp",
                            "uniq_tls_fp",
                            "server_port"
                          ],
                          "description": "要检查的请求或客户端属性，例如 `ip`、`host`、`uri`、国家代码或 TLS 指纹。"
                        },
                        "op": {
                          "type": "string",
                          "enum": [
                            ">",
                            "=",
                            "!=",
                            "!contain",
                            "contain",
                            "prefix",
                            "suffix",
                            "regex",
                            "!regex",
                            "exists",
                            "!exists",
                            "ip_range",
                            "!ip_range"
                          ],
                          "description": "匹配操作符；`ip_range` 和 `!ip_range` 用于判断 IP 是否属于指定 CIDR 范围。"
                        },
                        "value": {
                          "type": "string",
                          "default": "",
                          "description": "参与匹配的值。服务端会移除空行并转为小写；IP 范围操作符使用空白分隔一个或多个 CIDR。"
                        }
                      },
                      "additionalProperties": false
                    }
                  }
                },
                "additionalProperties": false
              }
            },
            "enable": {
              "type": "integer",
              "enum": [
                0,
                1
              ],
              "description": "更新后的启用状态：1 表示启用，0 表示禁用。禁用前 ACL 不能仍被网站引用。"
            },
            "uid": {
              "type": "integer",
              "format": "int64",
              "minimum": 1,
              "description": "仅管理员可传，用于按指定用户执行名称和网站引用校验；该字段不会转移 ACL 的所属用户。"
            }
          },
          "additionalProperties": false
        },
        "example": {
          "name": "办公网络访问规则",
          "default_action": "reject",
          "data": [
            {
              "acl_action": "allow",
              "acl_matcher": [
                {
                  "item": "ip",
                  "op": "ip_range",
                  "value": "192.0.2.0/24"
                }
              ]
            }
          ]
        }
      }
    }
  },
  "x-itecdn-source-reviewed": true,
  "extensions": [
    {
      "key": "x-python-handler",
      "value": "site.AclAPI"
    },
    {
      "key": "x-python-route-line",
      "value": 375
    },
    {
      "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/acls/{acl_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",
    "default_action": "reject",
    "reject_code": "403",
    "redirect_url": "string",
    "data": [
      {
        "acl_action": "reject",
        "acl_code": "403",
        "acl_url": "",
        "acl_matcher": [
          {
            "item": "count404",
            "op": ">",
            "value": ""
          }
        ]
      }
    ],
    "enable": 0,
    "uid": 0
  },
  "info": {
    "title": "itecdn v5 用户 API",
    "version": "5.x",
    "description": "itecdn v5.x Python 主控用户 API。本文档不适用于 v6 或其它实现。"
  },
  "postman": {
    "name": "更新单个 ACL",
    "description": {
      "content": "根据路径中的 ACL ID 局部更新一条 ACL。请求体必须是 JSON 对象，只需提交要修改的字段；服务端会将路径 `acl_id` 作为真实目标 ID，即使请求体包含 `id` 也会被路径值覆盖。普通用户只能更新自己的 ACL，管理员可更新其他用户的 ACL。修改已被网站引用且处于启用状态的 ACL 时会创建同步任务；禁用 ACL 时会创建删除任务，但仍被网站引用的 ACL 不允许直接禁用。",
      "type": "text/plain"
    },
    "url": {
      "path": [
        "v1",
        "acls",
        ":acl_id"
      ],
      "host": [
        "{{baseUrl}}"
      ],
      "query": [],
      "variable": [
        {
          "disabled": false,
          "description": {
            "content": "(Required) 要更新的 ACL ID；目标必须存在且当前身份有权管理。",
            "type": "text/plain"
          },
          "type": "any",
          "value": "",
          "key": "acl_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"
        }
      ]
    }
  }
}