## 节点 (`nodes`)

已审核的边缘节点与子 IP;主节点经注册令牌自助注册,子 IP 由管理员手工添加。

鉴权: 仅管理员 · 文档: https://www-demo.kuxitong.com/zh/docs/api/nodes

### GET `/api/v2/nodes`

列出节点 · 鉴权: 仅管理员

查询参数:

| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
| `page` | integer |  | 页码,从 1 开始。 默认: 1 |
| `page_size` | integer |  | 每页条数。 默认: 20 |
| `sort` | string |  | 排序字段,逗号分隔,前缀 `-` 表示降序,如 `-created_at,id`。 |

```sh
curl "https://panel.example.com/api/v2/nodes" \
  -H "X-API-Key: $GOCDN_API_KEY"
```

### POST `/api/v2/nodes`

创建节点 · 鉴权: 仅管理员

请求体:

| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
| `area` | string |  | 地区(只做展示,不下发节点);空 = 未填。子 IP 取主节点的。 |
| `bandwidth_mbps` | integer |  | 节点带宽 Mbps(只做展示,与 monitor.bw_limit_mbps 无关);0 = 未填。子 IP 取主节点的。 |
| `des` | string |  | 备注说明 |
| `enabled` | boolean |  | 是否启用 |
| `ip` | string |  | 节点 IP 地址(IPv4 或 IPv6)。 |
| `monitor` | NodeMonitor |  | 节点监控探测设置(主控按 monitor.node 配置的间隔探这个 IP)。 |
| `name` | string | 有 | 名称 |
| `parent_id` | integer |  | 子 IP 所属主节点;null = 主节点。 |
| `region_id` | integer |  | 区域 ID |
| `service_expire` | string |  | 服务器到期日 YYYY-MM-DD(首页到期提醒用,不自动停用);null = 未填、不提醒。子 IP 取主节点的。 |
| `service_start` | string |  | 服务器开始日 YYYY-MM-DD(只做展示);null = 未填。子 IP 取主节点的。 |

```sh
curl -X POST "https://panel.example.com/api/v2/nodes" \
  -H "X-API-Key: $GOCDN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"ip":"192.0.2.20","name":"edge-1-ip2","parent_id":1}'
```

### GET `/api/v2/nodes/{id}`

获取节点 · 鉴权: 仅管理员

查询参数:

| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
| `capacity` | boolean |  | 为 true 时附带 capacity(主节点才有;没有系统信息时为 null)。 |

```sh
curl "https://panel.example.com/api/v2/nodes/{id}" \
  -H "X-API-Key: $GOCDN_API_KEY"
```

### PUT `/api/v2/nodes/{id}`

修改节点 · 鉴权: 仅管理员

请求体:

| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
| `area` | string |  | 地区(只做展示,不下发节点);空 = 未填。子 IP 取主节点的。 |
| `bandwidth_mbps` | integer |  | 节点带宽 Mbps(只做展示,与 monitor.bw_limit_mbps 无关);0 = 未填。子 IP 取主节点的。 |
| `des` | string |  | 备注说明 |
| `enabled` | boolean |  | 是否启用 |
| `ip` | string |  | 节点 IP 地址(IPv4 或 IPv6)。 |
| `monitor` | NodeMonitor |  | 节点监控探测设置(主控按 monitor.node 配置的间隔探这个 IP)。 |
| `name` | string |  | 名称 |
| `parent_id` | integer |  | 子 IP 所属主节点;null = 主节点。 |
| `region_id` | integer |  | 区域 ID |
| `service_expire` | string |  | 服务器到期日 YYYY-MM-DD(首页到期提醒用,不自动停用);null = 未填、不提醒。子 IP 取主节点的。 |
| `service_start` | string |  | 服务器开始日 YYYY-MM-DD(只做展示);null = 未填。子 IP 取主节点的。 |

```sh
curl -X PUT "https://panel.example.com/api/v2/nodes/{id}" \
  -H "X-API-Key: $GOCDN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"bandwidth_mbps":30}'
```

### DELETE `/api/v2/nodes/{id}`

删除节点 · 鉴权: 仅管理员

```sh
curl -X DELETE "https://panel.example.com/api/v2/nodes/{id}" \
  -H "X-API-Key: $GOCDN_API_KEY"
```

### POST `/api/v2/nodes/{id}/config-readmit`

重新下发被节点回滚的配置 · 鉴权: 仅管理员

```sh
curl -X POST "https://panel.example.com/api/v2/nodes/{id}/config-readmit" \
  -H "X-API-Key: $GOCDN_API_KEY"
```

### GET `/api/v2/nodes/{id}/local-addrs`

节点网卡地址 · 鉴权: 仅管理员

```sh
curl "https://panel.example.com/api/v2/nodes/{id}/local-addrs" \
  -H "X-API-Key: $GOCDN_API_KEY"
```

### POST `/api/v2/nodes/{id}/to-pending`

节点移回待初始化 · 鉴权: 仅管理员

```sh
curl -X POST "https://panel.example.com/api/v2/nodes/{id}/to-pending" \
  -H "X-API-Key: $GOCDN_API_KEY"
```

节点对象:

| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
| `area` | string |  | 地区(只做展示,不下发节点);空 = 未填。子 IP 取主节点的。 |
| `bandwidth_mbps` | integer |  | 节点带宽 Mbps(只做展示,与 monitor.bw_limit_mbps 无关);0 = 未填。子 IP 取主节点的。 |
| `capacity` | NodeCapacity |  | 节点内存容量(只读,只在 GET /nodes/{id}?capacity=true 给出):单站常驻 = location 数 × 28.1KB + https 占比 × 25.5KB,预算 = 内存 MiB × 0.25 / 2 − 28MiB,上限 = 预算 / 单站。null = 没有该节点的系统信息或缺内存总量。 (只读) |
| `cert_expiry` | string |  | 最近一次签发证书的到期时刻;null = 还没领过证(或子 IP)。 |
| `created_at` | string |  | 创建时间 (只读) |
| `des` | string |  | 备注说明 |
| `disable_by` | string |  | 停用来源(manual = 管理员;monitor = 节点监控自动停用,探测恢复后自动启用;bandwidth = 出站带宽超过 monitor.bw_limit_mbps 自动停用,回落后自动启用);启用时为空。 |
| `enabled` | boolean |  | 是否启用 |
| `enrolled_at` | string |  | 节点注册时刻;手工添加的子 IP 为 null。 |
| `hints` | string[] |  | 提示(如取不到网卡地址)。 |
| `hostname` | string |  | 节点主机名,注册时上报。 |
| `id` | integer |  | 记录 ID (只读) |
| `ip` | string |  | 节点 IP 地址(IPv4 或 IPv6)。 |
| `monitor` | NodeMonitor |  | 节点监控探测设置(主控按 monitor.node 配置的间隔探这个 IP)。 |
| `name` | string |  | 名称 |
| `ops` | NodeOps |  | 节点运维状态(只读,来自心跳):在线、配置是否落后于最新已发布版本、时钟是否同步。子 IP 跟随主节点。 (只读) |
| `parent_id` | integer |  | 子 IP 所属主节点;null = 主节点。 |
| `region_id` | integer |  | 区域 ID |
| `role` | string |  | 节点角色:edge 边缘节点;l2 二级缓存节点。 可选值: ["edge","l2"] |
| `service_expire` | string |  | 服务器到期日 YYYY-MM-DD(首页到期提醒用,不自动停用);null = 未填、不提醒。子 IP 取主节点的。 |
| `service_start` | string |  | 服务器开始日 YYYY-MM-DD(只做展示);null = 未填。子 IP 取主节点的。 |
| `status` | string |  | ok = 有结果;pending = 已排指令,稍后再取;unknown = 节点不在线。 可选值: ["ok","pending","unknown"] |
| `updated_at` | string |  | 更新时间 (只读) |
| `v4` | string[] |  | 节点网卡上的 IPv4 地址。 |
| `v6` | string[] |  | 节点网卡上的 IPv6 地址。 |
