# NSNodeService
> 域名服务器节点服务

---

## checkNSNodeLatestVersion
> 检查NS节点新版本

- 角色：`dns`, `admin`
- HTTP：`POST https://backend.dooki.cloud/NSNodeService/checkNSNodeLatestVersion`
- RPC：`rpc checkNSNodeLatestVersion (CheckNSNodeLatestVersionRequest) returns (CheckNSNodeLatestVersionResponse);`

**请求对象 (`CheckNSNodeLatestVersionRequest`)**

```json
{
  "os": "string",
  "arch": "string",
  "currentVersion": "string"
}
```

**响应对象 (`CheckNSNodeLatestVersionResponse`)**

```json
{
  "hasNewVersion": "bool",
  "newVersion": "string"
}
```

**调用示例**

```bash
curl -X POST "https://backend.dooki.cloud/NSNodeService/checkNSNodeLatestVersion" \
  -H "Content-Type: application/json" \
  -H "X-Edge-Access-Token: <YOUR_TOKEN>" \
  -d '{
    ...
  }'
```

---

## countAllNSNodes
> 所有可用的NS节点数量

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/NSNodeService/countAllNSNodes`
- RPC：`rpc countAllNSNodes (CountAllNSNodesRequest) returns (RPCCountResponse);`

**请求对象 (`CountAllNSNodesRequest`)**

```json
{}
```

**响应对象 (`RPCCountResponse`)**

```json
{
  "count": "int64 // 数量"
}
```

**调用示例**

```bash
curl -X POST "https://backend.dooki.cloud/NSNodeService/countAllNSNodes" \
  -H "Content-Type: application/json" \
  -H "X-Edge-Access-Token: <YOUR_TOKEN>" \
  -d '{
    ...
  }'
```

---

## countAllNSNodesMatch
> 计算匹配的NS节点数量

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/NSNodeService/countAllNSNodesMatch`
- RPC：`rpc countAllNSNodesMatch (CountAllNSNodesMatchRequest) returns (RPCCountResponse);`

**请求对象 (`CountAllNSNodesMatchRequest`)**

```json
{
  "nsClusterId": "int64",
  "installState": "int32",
  "activeState": "int32",
  "keyword": "string // int64 nodeGroupId = 5;",
  "nodeRegionId": "int64"
}
```

**响应对象 (`RPCCountResponse`)**

```json
{
  "count": "int64 // 数量"
}
```

**调用示例**

```bash
curl -X POST "https://backend.dooki.cloud/NSNodeService/countAllNSNodesMatch" \
  -H "Content-Type: application/json" \
  -H "X-Edge-Access-Token: <YOUR_TOKEN>" \
  -d '{
    ...
  }'
```

---

## countAllUpgradeNSNodesWithNSClusterId
> 计算需要升级的NS节点数量

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/NSNodeService/countAllUpgradeNSNodesWithNSClusterId`
- RPC：`rpc countAllUpgradeNSNodesWithNSClusterId (CountAllUpgradeNSNodesWithNSClusterIdRequest) returns (RPCCountResponse);`

**请求对象 (`CountAllUpgradeNSNodesWithNSClusterIdRequest`)**

```json
{
  "nsClusterId": "int64"
}
```

**响应对象 (`RPCCountResponse`)**

```json
{
  "count": "int64 // 数量"
}
```

**调用示例**

```bash
curl -X POST "https://backend.dooki.cloud/NSNodeService/countAllUpgradeNSNodesWithNSClusterId" \
  -H "Content-Type: application/json" \
  -H "X-Edge-Access-Token: <YOUR_TOKEN>" \
  -d '{
    ...
  }'
```

---

## createNSNode
> 创建NS节点

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/NSNodeService/createNSNode`
- RPC：`rpc createNSNode (CreateNSNodeRequest) returns (CreateNSNodeResponse);`

**请求对象 (`CreateNSNodeRequest`)**

```json
{
  "name": "string // 名称",
  "nodeClusterId": "int64 // 集群ID",
  "nodeLogin": "NodeLogin"
}
```

**响应对象 (`CreateNSNodeResponse`)**

```json
{
  "nsNodeId": "int64"
}
```

**调用示例**

```bash
curl -X POST "https://backend.dooki.cloud/NSNodeService/createNSNode" \
  -H "Content-Type: application/json" \
  -H "X-Edge-Access-Token: <YOUR_TOKEN>" \
  -d '{
    ...
  }'
```

---

## deleteNSNode
> 删除NS节点

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/NSNodeService/deleteNSNode`
- RPC：`rpc deleteNSNode (DeleteNSNodeRequest) returns (RPCSuccess);`

**请求对象 (`DeleteNSNodeRequest`)**

```json
{
  "nsNodeId": "int64"
}
```

**响应对象 (`RPCSuccess`)**

```json
{}
```

**调用示例**

```bash
curl -X POST "https://backend.dooki.cloud/NSNodeService/deleteNSNode" \
  -H "Content-Type: application/json" \
  -H "X-Edge-Access-Token: <YOUR_TOKEN>" \
  -d '{
    ...
  }'
```

---

## findAllNSNodesWithNSClusterId
> 根据集群查找所有NS节点

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/NSNodeService/findAllNSNodesWithNSClusterId`
- RPC：`rpc findAllNSNodesWithNSClusterId (FindAllNSNodesWithNSClusterIdRequest) returns (FindAllNSNodesWithNSClusterIdResponse);`

**请求对象 (`FindAllNSNodesWithNSClusterIdRequest`)**

```json
{
  "nsClusterId": "int64"
}
```

**响应对象 (`FindAllNSNodesWithNSClusterIdResponse`)**

```json
{
  "nsNodes": "[]NSNode"
}
```

**调用示例**

```bash
curl -X POST "https://backend.dooki.cloud/NSNodeService/findAllNSNodesWithNSClusterId" \
  -H "Content-Type: application/json" \
  -H "X-Edge-Access-Token: <YOUR_TOKEN>" \
  -d '{
    ...
  }'
```

---

## findLatestNSNodeVersion
> 获取NS节点最新版本

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/NSNodeService/findLatestNSNodeVersion`
- RPC：`rpc findLatestNSNodeVersion (FindLatestNSNodeVersionRequest) returns (FindLatestNSNodeVersionResponse);`

**请求对象 (`FindLatestNSNodeVersionRequest`)**

```json
{}
```

**响应对象 (`FindLatestNSNodeVersionResponse`)**

```json
{
  "version": "string"
}
```

**调用示例**

```bash
curl -X POST "https://backend.dooki.cloud/NSNodeService/findLatestNSNodeVersion" \
  -H "Content-Type: application/json" \
  -H "X-Edge-Access-Token: <YOUR_TOKEN>" \
  -d '{
    ...
  }'
```

---

## findNSNode
> 获取单个NS节点信息

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/NSNodeService/findNSNode`
- RPC：`rpc findNSNode (FindNSNodeRequest) returns (FindNSNodeResponse);`

**请求对象 (`FindNSNodeRequest`)**

```json
{
  "nsNodeId": "int64"
}
```

**响应对象 (`FindNSNodeResponse`)**

```json
{
  "nsNode": "NSNode"
}
```

**调用示例**

```bash
curl -X POST "https://backend.dooki.cloud/NSNodeService/findNSNode" \
  -H "Content-Type: application/json" \
  -H "X-Edge-Access-Token: <YOUR_TOKEN>" \
  -d '{
    ...
  }'
```

---

## findNSNodeAPIConfig
> 查找单个节点的API相关配置

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/NSNodeService/findNSNodeAPIConfig`
- RPC：`rpc findNSNodeAPIConfig(FindNSNodeAPIConfigRequest) returns (FindNSNodeAPIConfigResponse);`

**请求对象 (`FindNSNodeAPIConfigRequest`)**

```json
{
  "nsNodeId": "int64"
}
```

**响应对象 (`FindNSNodeAPIConfigResponse`)**

```json
{
  "apiNodeAddrsJSON": "bytes"
}
```

**调用示例**

```bash
curl -X POST "https://backend.dooki.cloud/NSNodeService/findNSNodeAPIConfig" \
  -H "Content-Type: application/json" \
  -H "X-Edge-Access-Token: <YOUR_TOKEN>" \
  -d '{
    ...
  }'
```

---

## findNSNodeDDoSProtection
> 获取NS节点的DDoS设置

- 角色：`admin`, `dns`
- HTTP：`POST https://backend.dooki.cloud/NSNodeService/findNSNodeDDoSProtection`
- RPC：`rpc findNSNodeDDoSProtection(FindNSNodeDDoSProtectionRequest) returns (FindNSNodeDDoSProtectionResponse);`

**请求对象 (`FindNSNodeDDoSProtectionRequest`)**

```json
{
  "nsNodeId": "int64"
}
```

**响应对象 (`FindNSNodeDDoSProtectionResponse`)**

```json
{
  "ddosProtectionJSON": "bytes"
}
```

**调用示例**

```bash
curl -X POST "https://backend.dooki.cloud/NSNodeService/findNSNodeDDoSProtection" \
  -H "Content-Type: application/json" \
  -H "X-Edge-Access-Token: <YOUR_TOKEN>" \
  -d '{
    ...
  }'
```

---

## findNSNodeInstallStatus
> 读取NS节点安装状态

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/NSNodeService/findNSNodeInstallStatus`
- RPC：`rpc findNSNodeInstallStatus (FindNSNodeInstallStatusRequest) returns (FindNSNodeInstallStatusResponse);`

**请求对象 (`FindNSNodeInstallStatusRequest`)**

```json
{
  "nsNodeId": "int64"
}
```

**响应对象 (`FindNSNodeInstallStatusResponse`)**

```json
{
  "installStatus": "NodeInstallStatus"
}
```

**调用示例**

```bash
curl -X POST "https://backend.dooki.cloud/NSNodeService/findNSNodeInstallStatus" \
  -H "Content-Type: application/json" \
  -H "X-Edge-Access-Token: <YOUR_TOKEN>" \
  -d '{
    ...
  }'
```

---

## installNSNode
> 安装NS节点

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/NSNodeService/installNSNode`
- RPC：`rpc installNSNode (InstallNSNodeRequest) returns (InstallNSNodeResponse);`

**请求对象 (`InstallNSNodeRequest`)**

```json
{
  "nsNodeId": "int64"
}
```

**响应对象 (`InstallNSNodeResponse`)**

```json
{}
```

**调用示例**

```bash
curl -X POST "https://backend.dooki.cloud/NSNodeService/installNSNode" \
  -H "Content-Type: application/json" \
  -H "X-Edge-Access-Token: <YOUR_TOKEN>" \
  -d '{
    ...
  }'
```

---

## listNSNodesMatch
> 列出单页NS节点

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/NSNodeService/listNSNodesMatch`
- RPC：`rpc listNSNodesMatch (ListNSNodesMatchRequest) returns (ListNSNodesMatchResponse);`

**请求对象 (`ListNSNodesMatchRequest`)**

```json
{
  "offset": "int64 // 读取位置",
  "size": "int64 // 数量，通常不能小于0",
  "nsClusterId": "int64",
  "installState": "int32",
  "activeState": "int32",
  "keyword": "string // int64 nodeGroupId = 7;",
  "nodeRegionId": "int64"
}
```

**响应对象 (`ListNSNodesMatchResponse`)**

```json
{
  "nsNodes": "[]NSNode"
}
```

**调用示例**

```bash
curl -X POST "https://backend.dooki.cloud/NSNodeService/listNSNodesMatch" \
  -H "Content-Type: application/json" \
  -H "X-Edge-Access-Token: <YOUR_TOKEN>" \
  -d '{
    ...
  }'
```

---

## sendCommandToNSNode
> 向NS节点发送命令

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/NSNodeService/sendCommandToNSNode`
- RPC：`rpc sendCommandToNSNode (NSNodeStreamMessage) returns (NSNodeStreamMessage);`

**请求对象 (`NSNodeStreamMessage`)**

```json
{
  "nsNodeId": "int64",
  "requestId": "int64",
  "timeoutSeconds": "int32",
  "code": "string",
  "dataJSON": "bytes",
  "isOk": "bool",
  "message": "string"
}
```

**响应对象 (`NSNodeStreamMessage`)**

```json
{
  "nsNodeId": "int64",
  "requestId": "int64",
  "timeoutSeconds": "int32",
  "code": "string",
  "dataJSON": "bytes",
  "isOk": "bool",
  "message": "string"
}
```

**调用示例**

```bash
curl -X POST "https://backend.dooki.cloud/NSNodeService/sendCommandToNSNode" \
  -H "Content-Type: application/json" \
  -H "X-Edge-Access-Token: <YOUR_TOKEN>" \
  -d '{
    ...
  }'
```

---

## startNSNode
> 启动NS节点

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/NSNodeService/startNSNode`
- RPC：`rpc startNSNode (StartNSNodeRequest) returns (StartNSNodeResponse);`

**请求对象 (`StartNSNodeRequest`)**

```json
{
  "nsNodeId": "int64"
}
```

**响应对象 (`StartNSNodeResponse`)**

```json
{
  "isOk": "bool",
  "error": "string"
}
```

**调用示例**

```bash
curl -X POST "https://backend.dooki.cloud/NSNodeService/startNSNode" \
  -H "Content-Type: application/json" \
  -H "X-Edge-Access-Token: <YOUR_TOKEN>" \
  -d '{
    ...
  }'
```

---

## stopNSNode
> 停止NS节点

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/NSNodeService/stopNSNode`
- RPC：`rpc stopNSNode (StopNSNodeRequest) returns (StopNSNodeResponse);`

**请求对象 (`StopNSNodeRequest`)**

```json
{
  "nsNodeId": "int64"
}
```

**响应对象 (`StopNSNodeResponse`)**

```json
{
  "isOk": "bool",
  "error": "string"
}
```

**调用示例**

```bash
curl -X POST "https://backend.dooki.cloud/NSNodeService/stopNSNode" \
  -H "Content-Type: application/json" \
  -H "X-Edge-Access-Token: <YOUR_TOKEN>" \
  -d '{
    ...
  }'
```

---

## updateNSNode
> 修改NS节点

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/NSNodeService/updateNSNode`
- RPC：`rpc updateNSNode (UpdateNSNodeRequest) returns (RPCSuccess);`

**请求对象 (`UpdateNSNodeRequest`)**

```json
{
  "nsNodeId": "int64",
  "name": "string // 名称",
  "nsClusterId": "int64",
  "nodeLogin": "NodeLogin",
  "isOn": "bool // 是否启用"
}
```

**响应对象 (`RPCSuccess`)**

```json
{}
```

**调用示例**

```bash
curl -X POST "https://backend.dooki.cloud/NSNodeService/updateNSNode" \
  -H "Content-Type: application/json" \
  -H "X-Edge-Access-Token: <YOUR_TOKEN>" \
  -d '{
    ...
  }'
```

---

## updateNSNodeAPIConfig
> 修改某个节点的API相关配置

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/NSNodeService/updateNSNodeAPIConfig`
- RPC：`rpc updateNSNodeAPIConfig(UpdateNSNodeAPIConfigRequest) returns (RPCSuccess);`

**请求对象 (`UpdateNSNodeAPIConfigRequest`)**

```json
{
  "nsNodeId": "int64",
  "apiNodeAddrsJSON": "bytes"
}
```

**响应对象 (`RPCSuccess`)**

```json
{}
```

**调用示例**

```bash
curl -X POST "https://backend.dooki.cloud/NSNodeService/updateNSNodeAPIConfig" \
  -H "Content-Type: application/json" \
  -H "X-Edge-Access-Token: <YOUR_TOKEN>" \
  -d '{
    ...
  }'
```

---

## updateNSNodeDDoSProtection
> 修改NS节点的DDoS设置

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/NSNodeService/updateNSNodeDDoSProtection`
- RPC：`rpc updateNSNodeDDoSProtection(UpdateNSNodeDDoSProtectionRequest) returns (RPCSuccess);`

**请求对象 (`UpdateNSNodeDDoSProtectionRequest`)**

```json
{
  "nsNodeId": "int64",
  "ddosProtectionJSON": "bytes"
}
```

**响应对象 (`RPCSuccess`)**

```json
{}
```

**调用示例**

```bash
curl -X POST "https://backend.dooki.cloud/NSNodeService/updateNSNodeDDoSProtection" \
  -H "Content-Type: application/json" \
  -H "X-Edge-Access-Token: <YOUR_TOKEN>" \
  -d '{
    ...
  }'
```

---

## updateNSNodeIsInstalled
> 修改NS节点安装状态

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/NSNodeService/updateNSNodeIsInstalled`
- RPC：`rpc updateNSNodeIsInstalled (UpdateNSNodeIsInstalledRequest) returns (RPCSuccess);`

**请求对象 (`UpdateNSNodeIsInstalledRequest`)**

```json
{
  "nsNodeId": "int64",
  "isInstalled": "bool"
}
```

**响应对象 (`RPCSuccess`)**

```json
{}
```

**调用示例**

```bash
curl -X POST "https://backend.dooki.cloud/NSNodeService/updateNSNodeIsInstalled" \
  -H "Content-Type: application/json" \
  -H "X-Edge-Access-Token: <YOUR_TOKEN>" \
  -d '{
    ...
  }'
```

---

## updateNSNodeLogin
> 修改NS节点登录信息

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/NSNodeService/updateNSNodeLogin`
- RPC：`rpc updateNSNodeLogin (UpdateNSNodeLoginRequest) returns (RPCSuccess);`

**请求对象 (`UpdateNSNodeLoginRequest`)**

```json
{
  "nsNodeId": "int64",
  "nodeLogin": "NodeLogin"
}
```

**响应对象 (`RPCSuccess`)**

```json
{}
```

**调用示例**

```bash
curl -X POST "https://backend.dooki.cloud/NSNodeService/updateNSNodeLogin" \
  -H "Content-Type: application/json" \
  -H "X-Edge-Access-Token: <YOUR_TOKEN>" \
  -d '{
    ...
  }'
```

---
