# 网关集群

# 获取候选节点列表

# 简介

获取等待加入网关集群的节点列表

# Uri
GET /admin-api/nodecandidate/list
# 请求示例
# Shell
curl \
  -H "API-token: 1df87165-3593-4eca-a910-9ac20005e6ec" \
  http://{admin-site}/admin-api/nodecandidate/list
# 响应示例
Status: 200 OK
{
    "time": 1614768787,
    "data": {
        "data": [
            {
                "internal_ip": "127.0.0.1",
                "mac_address": "06:86:ce:06:75:a6",
                "_created_unix": "2021-03-03 18:50:16.976704",
                "created_unix": 1614768616.9767,
                "hardware_id": "6b632692eb1f46bd0b8067f6ae9xxxxx",
                "csr": "-----BEGIN NEW CERTIFICATE REQUEST-----\n...\n-----END NEW CERTIFICATE REQUEST-----\n",
                "hostname": "localhost\n",
                "external_ip": "127.0.0.1",
                "os": "Linux\n3.10.0-1062.12.1.el7.x86_64\n",
                "external_ipv6": "",
                "client_city": "HK/"
            }
        ],
        "meta": {
            "count": 1
        }
    },
    "status": 0
}

# 获取网关集群列表

# 简介

获取网关集群列表

# Uri
GET /admin-api/gateway
# Uri参数
  • detail

    type: integer

    required: no

    description: Are detailed results required (default 0)

  • page

    type: integer

    required: no

    description: Results page (default 1)

  • page_size

    type: integer

    required: no

    description: Results page size (default 20)

# 请求示例
# Shell
curl \
  -H "API-token: 1df87165-3593-4eca-a910-9ac20005e6ec" \
  http://{admin-site}/admin-api/gateway?detail=1&page_size=100&page=1
# 响应示例
Status: 200 OK
{
    "data": {
        "data": [
            {
                "is_gray_partition": false,
                "id": 1, // gateway id
                "_modified_unix": 1612133743.1943,
                "nodes": [
                    {
                        "internal_ip": "127.0.0.1",
                        "id": 59, // node id
                        "online_status": true,
                        "_modified_unix": 1612136932.8338,
                        "name": "localhost",
                        "config": {
                            "error_log_level": "default",
                            "proxy_bind_local_ip_list": ["192.168.122.164", "192.168.50.243"],
                            "listen_bind_local_ip_list": ["192.168.122.164", "192.168.50.243"]
                        },
                        "serial": "3049245148",
                        "_created_unix": 1571733586.0325,
                        "sync_status_utime": 1614765663,
                        "hardware_id": "43ac1f19cf445cea5235a536e43xxxxx",
                        "version": 501,
                        "is_healthy": true,
                        "external_ip": "127.0.0.1",
                        "status": 1
                    }
                ],
                "partition": 1,
                "tag": [
                    2
                ],
                "name": "hk",
                "_created_unix": 1506091343.5212,
                "location": {
                    "country": "CN",
                    "isp": "BGP",
                    "province": "Hongkong",
                    "latitude": 30.252501,
                    "continent": "AS",
                    "longitude": 120.165024
                }
            }
        ],
        "meta": {
            "count": 11
        }
    },
    "status": 0
}

# 新建网关集群

# 简介

新建网关集群

# Uri
POST /admin-api/gateway
# Json body 参数
{
    "name": "gateway-name", // gateway name
    "partition": 1, // partition id
}
# 请求示例
# Shell
curl \
  -H "API-token: 1df87165-3593-4eca-a910-9ac20005e6ec" \
  http://{admin-site}/admin-api/gateway
  -d '{"name": "gateway-name", "partition": 1}'
# 响应示例
Status: 200 OK
{"data":{"id":61},"status":0}

# 更新网关集群信息

# 简介

更新指定网关集群的信息

# Uri
POST /admin-api/gateway/{gateway_id}
# Json body 参数
{
    "partition":1,    // 分区id
    "location":{      // 地理位置信息
        "province":"Loopback Address",
        "isp":"",
        "country":"AF"
    },
    "id":3,           // 网关集群id
    "nodes":[         // 节点信息
        {
            "config":{
                "enable_qat":false,     // 启用qat     
                "error_log_level":"default",   // 日志级别
                "proxy_bind_local_ip_list": ["192.168.122.164", "192.168.50.243"],   // 上游转发绑定的本地ip
                "listen_bind_local_ip_list": ["192.168.122.164", "192.168.50.243"]   // 下游监听绑定的本地ip
            },
            "_modified_unix":1615258796.6619,
            "name":"centos8",
            "_created_unix":1615258796.6241,
            "version":210,
            "external_ip":"127.0.0.1",         // 公网ip
            "internal_ip":"192.168.122.164",   // 内网ip
            "id":4,       // 节点id
            "status":0,   // 0:开启dns,开启集群缓存 1:关闭dns,开启集群缓存 2:关闭dns,关闭集群缓存
            "hardware_id":"d593e4c8bfff4a303e75fac1de7b6e69",
            "online_status":true,   // 节点是否上线
            "sync_status_utime":0,  
            "serial":"214994338",
            "gatewayName":"server",
            "external_ipv6":null      // 公网ipv6
        }
    ],
    "_created_unix":1615258791.9496,
    "name":"server",
    "_modified_unix":1615258796.5665,
    "syncStatus":"1 (100%)",
    "partitionLabel":"default",
    "rowspan":1,
    "node":{
        "config":{
            "enable_qat":false
        },
        "_modified_unix":1615258796.6619,
        "name":"centos8",
        "_created_unix":1615258796.6241,
        "version":210,
        "external_ip":"127.0.0.1",
        "internal_ip":"192.168.122.164",
        "id":4,
        "status":1,
        "hardware_id":"d593e4c8bfff4a303e75fac1de7b6e69",
        "online_status":true,
        "sync_status_utime":0,
        "serial":"214994338",
        "gatewayName":"server"
    },
    "tag":[

    ],
    "bandwidth":null,
    "bandwidth_unit":null
}
# 请求示例
# Shell
curl 'http://{admin-site}/admin-api/gateway' \
  -X 'PUT' \
  --data-raw '{"partition":1,"location":{"province":"Loopback Address","isp":"","country":"AF"},"id":3,"nodes":[{"config":{"enable_qat":false,"error_log_level":"default"},"_modified_unix":1615258796.6619,"name":"centos8","_created_unix":1615258796.6241,"version":210,"external_ip":"127.0.0.1","internal_ip":"192.168.122.164","id":4,"status":0,"hardware_id":"d593e4c8bfff4a303e75fac1de7b6e69","online_status":true,"sync_status_utime":0,"serial":"214994338","gatewayName":"server","external_ipv6":null}],"_created_unix":1615258791.9496,"name":"server","_modified_unix":1615258796.5665,"syncStatus":"1 (100%)","partitionLabel":"default","rowspan":1,"node":{"config":{"enable_qat":false},"_modified_unix":1615258796.6619,"name":"centos8","_created_unix":1615258796.6241,"version":210,"external_ip":"127.0.0.1","internal_ip":"192.168.122.164","id":4,"status":1,"hardware_id":"d593e4c8bfff4a303e75fac1de7b6e69","online_status":true,"sync_status_utime":0,"serial":"214994338","gatewayName":"server"},"tag":[],"bandwidth":null,"bandwidth_unit":null}'
# 响应示例
Status: 200 OK

# 批准候选节点加入网关集群

# 简介

批准候选节点加入网关集群

# Uri
POST /admin-api/nodecandidate/approve
# Json body 参数
    {
        "cluster": 1, // gateway id
        "status": 1, // 1: Enable, 2: Disabled DNS 3: Offline
        "internal_ip": "127.0.0.1",
        "mac_address": "06:86:ce:06:75:a6",
        "_created_unix": "2021-03-03 18:50:16.976704",
        "created_unix": 1614768616.9767,
        "hardware_id": "6b632692eb1f46bd0b8067f6ae9xxxxx",
        "csr": "-----BEGIN NEW CERTIFICATE REQUEST-----\n...\n-----END NEW CERTIFICATE REQUEST-----\n",
        "hostname": "localhost\n",
        "external_ip": "127.0.0.1",
        "os": "Linux\n3.10.0-1062.12.1.el7.x86_64\n",
        "external_ipv6": "",
        "client_city": "HK/"
    }
# 请求示例
# Shell
curl \
  -H "API-token: 1df87165-3593-4eca-a910-9ac20005e6ec" \
  http://{admin-site}/admin-api/nodecandidate/approve \
  -d '{"cluster": 1, "status": 1, "internal_ip":"127.0.0.1","mac_address":"06:86:ce:06:75:a6","_created_unix":"2021-03-03 18:50:16.976704","created_unix":1614768616.9767,"hardware_id":"6b632692eb1f46bd0b8067f6ae9xxxxx","csr":"-----BEGIN NEW CERTIFICATE REQUEST-----\n...\n-----END NEW CERTIFICATE REQUEST-----\n","hostname":"localhost\n","external_ip":"127.0.0.1","os":"Linux\n3.10.0-1062.12.1.el7.x86_64\n","external_ipv6":"","client_city":"HK/"}'
# 响应示例
Status: 200 OK

{"time":1614782044,"status":0}

# 移除网关集群中节点

# 简介

移除网关集群中节点

# Uri
DELETE /admin-api/gateway/{gateway_id}/nodes/{node_id}
# 请求示例
# Shell
curl -X DELETE
  -H "API-token: 1df87165-3593-4eca-a910-9ac20005e6ec" \
  http://{admin-site}/admin-api/gateway/1/nodes/1
# 响应示例
Status: 200 OK
{"status":0}