# NSDomainService
> 域名相关服务

---

## countAllNSDomains
> 计算域名数量

- 角色：`admin`, `user`
- HTTP：`POST https://backend.dooki.cloud/NSDomainService/countAllNSDomains`
- RPC：`rpc countAllNSDomains (CountAllNSDomainsRequest) returns (RPCCountResponse);`

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

```json
{
  "userId": "int64 // 用户ID",
  "nsClusterId": "int64",
  "keyword": "string // 关键词",
  "nsDomainGroupId": "int64",
  "status": "string"
}
```

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

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

**调用示例**

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

---

## createNSDomain
> 创建单个域名

- 角色：`admin`, `user`
- HTTP：`POST https://backend.dooki.cloud/NSDomainService/createNSDomain`
- RPC：`rpc createNSDomain (CreateNSDomainRequest) returns (CreateNSDomainResponse);`

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

```json
{
  "nsClusterId": "int64 // 所属集群",
  "userId": "int64 // 所属用户",
  "name": "string // 域名",
  "nsDomainGroupIds": "[]int64 // 域名分组ID"
}
```

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

```json
{
  "nsDomainId": "int64"
}
```

**调用示例**

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

---

## createNSDomains
> 批量创建域名

- 角色：`admin`, `user`
- HTTP：`POST https://backend.dooki.cloud/NSDomainService/createNSDomains`
- RPC：`rpc createNSDomains(CreateNSDomainsRequest) returns (CreateNSDomainsResponse);`

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

```json
{
  "nsClusterId": "int64 // 所属集群",
  "userId": "int64 // 所属用户",
  "names": "[]string // 一组域名",
  "nsDomainGroupIds": "[]int64 // 域名分组ID"
}
```

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

```json
{
  "nsDomainIds": "[]int64"
}
```

**调用示例**

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

---

## deleteNSDomain
> 删除域名

- 角色：`admin`, `user`
- HTTP：`POST https://backend.dooki.cloud/NSDomainService/deleteNSDomain`
- RPC：`rpc deleteNSDomain (DeleteNSDomainRequest) returns (RPCSuccess);`

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

```json
{
  "nsDomainId": "int64"
}
```

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

```json
{}
```

**调用示例**

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

---

## deleteNSDomains
> 批量删除域名

- 角色：`admin`, `user`
- HTTP：`POST https://backend.dooki.cloud/NSDomainService/deleteNSDomains`
- RPC：`rpc deleteNSDomains(DeleteNSDomainsRequest) returns (RPCSuccess);`

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

```json
{
  "names": "[]string",
  "userId": "int64 // 域名所属用户ID"
}
```

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

```json
{}
```

**调用示例**

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

---

## existNSDomains
> 检查一组域名是否在用户账户中存在

- 角色：`admin`, `user`
- HTTP：`POST https://backend.dooki.cloud/NSDomainService/existNSDomains`
- RPC：`rpc existNSDomains(ExistNSDomainsRequest) returns (ExistNSDomainsResponse);`

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

```json
{
  "names": "[]string",
  "userId": "int64 // 用户ID"
}
```

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

```json
{
  "existingNames": "[]string"
}
```

**调用示例**

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

---

## existVerifiedNSDomains
> 检查一组域名是否已通过验证

- 角色：`admin`, `user`
- HTTP：`POST https://backend.dooki.cloud/NSDomainService/existVerifiedNSDomains`
- RPC：`rpc existVerifiedNSDomains(ExistVerifiedNSDomainsRequest) returns (ExistVerifiedNSDomainsResponse);`

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

```json
{
  "names": "[]string"
}
```

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

```json
{
  "existingNames": "[]string"
}
```

**调用示例**

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

---

## findNSDomain
> 查找单个域名

- 角色：`admin`, `user`
- HTTP：`POST https://backend.dooki.cloud/NSDomainService/findNSDomain`
- RPC：`rpc findNSDomain (FindNSDomainRequest) returns (FindNSDomainResponse);`

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

```json
{
  "nsDomainId": "int64 // 域名ID"
}
```

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

```json
{
  "nsDomain": "NSDomain"
}
```

**调用示例**

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

---

## findNSDomainRecordsHealthCheck
> 查询记录健康检查全局设置

- 角色：`admin`, `user`
- HTTP：`POST https://backend.dooki.cloud/NSDomainService/findNSDomainRecordsHealthCheck`
- RPC：`rpc findNSDomainRecordsHealthCheck(FindNSDomainRecordsHealthCheckRequest) returns (FindNSDomainRecordsHealthCheckResponse);`

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

```json
{
  "nsDomainId": "int64 // 域名ID"
}
```

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

```json
{
  "nsDomainRecordsHealthCheckJSON": "bytes // 健康检查设置"
}
```

**调用示例**

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

---

## findNSDomainTSIG
> 查找TSIG配置

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/NSDomainService/findNSDomainTSIG`
- RPC：`rpc findNSDomainTSIG (FindNSDomainTSIGRequest) returns (FindNSDomainTSIGResponse);`

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

```json
{
  "nsDomainId": "int64"
}
```

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

```json
{
  "tsigJSON": "bytes"
}
```

**调用示例**

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

---

## findNSDomainVerifyingInfo
> 获取域名验证信息

- 角色：`admin`, `user`
- HTTP：`POST https://backend.dooki.cloud/NSDomainService/findNSDomainVerifyingInfo`
- RPC：`rpc findNSDomainVerifyingInfo(FindNSDomainVerifyingInfoRequest) returns (FindNSDomainVerifyingInfoResponse);`

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

```json
{
  "nsDomainId": "int64 // 要验证的域名ID"
}
```

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

```json
{
  "requireTXT": "bool // 是否需要TXT验证，如果不需要（值false），则表示用户不需要手动设置TXT，此时 txt 字段内容可能为空",
  "txt": "string // TXT记录",
  "expiresAt": "int64 // TXT过期时间",
  "status": "string // 当前状态"
}
```

**调用示例**

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

---

## findNSDomainWithName
> 根据域名名称查找域名

- 角色：`admin`, `user`
- HTTP：`POST https://backend.dooki.cloud/NSDomainService/findNSDomainWithName`
- RPC：`rpc findNSDomainWithName(FindNSDomainWithNameRequest) returns (FindNSDomainWithNameResponse);`

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

```json
{
  "userId": "int64 // 用户ID，只有管理员才能指定用户",
  "name": "string // 域名"
}
```

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

```json
{
  "nsDomain": "NSDomain"
}
```

**调用示例**

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

---

## findVerifiedNSDomainOnCluster
> 根据域名名称查找集群中的已验证域名

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/NSDomainService/findVerifiedNSDomainOnCluster`
- RPC：`rpc findVerifiedNSDomainOnCluster(FindVerifiedNSDomainOnClusterRequest) returns (FindVerifiedNSDomainOnClusterResponse);`

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

```json
{
  "nsClusterId": "int64 // 集群ID",
  "name": "string // 域名"
}
```

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

```json
{
  "nsDomain": "NSDomain"
}
```

**调用示例**

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

---

## listNSDomains
> 列出单页域名

- 角色：`admin`, `user`
- HTTP：`POST https://backend.dooki.cloud/NSDomainService/listNSDomains`
- RPC：`rpc listNSDomains (ListNSDomainsRequest) returns (ListNSDomainsResponse);`

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

```json
{
  "userId": "int64 // 用户ID",
  "nsClusterId": "int64",
  "keyword": "string // 关键词",
  "nsDomainGroupId": "int64",
  "offset": "int64 // 读取位置",
  "size": "int64 // 数量，通常不能小于0"
}
```

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

```json
{
  "nsDomains": "[]NSDomain"
}
```

**调用示例**

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

---

## updateNSDomain
> 修改域名

- 角色：`admin`, `user`
- HTTP：`POST https://backend.dooki.cloud/NSDomainService/updateNSDomain`
- RPC：`rpc updateNSDomain (UpdateNSDomainRequest) returns (RPCSuccess);`

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

```json
{
  "nsDomainId": "int64",
  "nsClusterId": "int64",
  "userId": "int64 // 用户ID",
  "nsDomainGroupIds": "[]int64 // 域名分组ID",
  "isOn": "bool // 是否启用"
}
```

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

```json
{}
```

**调用示例**

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

---

## updateNSDomainRecordsHealthCheck
> 修改记录健康检查全局设置

- 角色：`admin`, `user`
- HTTP：`POST https://backend.dooki.cloud/NSDomainService/updateNSDomainRecordsHealthCheck`
- RPC：`rpc updateNSDomainRecordsHealthCheck(UpdateNSDomainRecordsHealthCheckRequest) returns (RPCSuccess);`

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

```json
{
  "nsDomainId": "int64 // 域名ID",
  "nsDomainRecordsHealthCheckJSON": "bytes // 健康检查设置"
}
```

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

```json
{}
```

**调用示例**

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

---

## updateNSDomainStatus
> 修改域名状态

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/NSDomainService/updateNSDomainStatus`
- RPC：`rpc updateNSDomainStatus(UpdateNSDomainStatusRequest) returns (RPCSuccess);`

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

```json
{
  "nsDomainId": "int64",
  "status": "string"
}
```

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

```json
{}
```

**调用示例**

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

---

## updateNSDomainTSIG
> 修改TSIG配置

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/NSDomainService/updateNSDomainTSIG`
- RPC：`rpc updateNSDomainTSIG (UpdateNSDomainTSIGRequest) returns (RPCSuccess);`

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

```json
{
  "nsDomainId": "int64",
  "tsigJSON": "bytes"
}
```

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

```json
{}
```

**调用示例**

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

---

## verifyNSDomain
> 验证域名信息

- 角色：`admin`, `user`
- HTTP：`POST https://backend.dooki.cloud/NSDomainService/verifyNSDomain`
- RPC：`rpc verifyNSDomain(VerifyNSDomainRequest) returns (VerifyNSDomainResponse);`

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

```json
{
  "nsDomainId": "int64"
}
```

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

```json
{
  "isOk": "bool // 是否成功",
  "errorCode": "string // 错误代码",
  "errorMessage": "string // 错误消息",
  "currentTXTValues": "[]string // 当前的TXT值",
  "currentNSValues": "[]string // 当前的NS记录值"
}
```

**调用示例**

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

---
