# NSRecordService
> 域名记录相关服务

---

## countAllNSRecords
> 计算记录数量

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

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

```json
{
  "nsDomainId": "int64",
  "type": "string",
  "nsRouteCode": "string // 使用nsRouteCode代替",
  "keyword": "string // 关键词"
}
```

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

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

**调用示例**

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

---

## countAllNSRecordsWithName
> 查询相同记录名的记录数

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

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

```json
{
  "nsDomainId": "int64",
  "name": "string // 名称",
  "type": "string"
}
```

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

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

**调用示例**

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

---

## createNSRecord
> 创建记录

- 角色：`admin`, `user`
- HTTP：`POST https://backend.dooki.cloud/NSRecordService/createNSRecord`
- RPC：`rpc createNSRecord (CreateNSRecordRequest) returns (CreateNSRecordResponse);`

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

```json
{
  "nsDomainId": "int64",
  "description": "string // 描述（备注）",
  "name": "string // 名称",
  "type": "string",
  "value": "string",
  "ttl": "int32",
  "nsRouteCodes": "[]string // 路线代号",
  "weight": "int32 // 权重",
  "mxPriority": "int32 // mx优先级",
  "srvPriority": "int32 // SRV优先级",
  "srvWeight": "int32 // SRV权重",
  "srvPort": "int32 // SRV端口",
  "caaFlag": "int32 // CAA Flag",
  "caaTag": "string // CAA TAG"
}
```

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

```json
{
  "nsRecordId": "int64"
}
```

**调用示例**

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

---

## createNSRecords
> 批量创建记录

- 角色：`admin`, `user`
- HTTP：`POST https://backend.dooki.cloud/NSRecordService/createNSRecords`
- RPC：`rpc createNSRecords(CreateNSRecordsRequest) returns (CreateNSRecordsResponse);`

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

```json
{
  "nsDomainId": "int64",
  "description": "string // 描述（备注）",
  "names": "[]string",
  "type": "string",
  "value": "string",
  "ttl": "int32",
  "nsRouteCodes": "[]string // 路线代号",
  "weight": "int32 // 权重",
  "mxPriority": "int32 // mx优先级",
  "srvPriority": "int32 // SRV优先级",
  "srvWeight": "int32 // SRV权重",
  "srvPort": "int32 // SRV端口",
  "caaFlag": "int32 // CAA Flag",
  "caaTag": "string // CAA TAG"
}
```

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

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

**调用示例**

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

---

## createNSRecordsWithDomainNames
> 为一组域名批量创建记录

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

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

```json
{
  "nsDomainNames": "[]string",
  "recordsJSON": "bytes",
  "removeOld": "bool",
  "removeAll": "bool",
  "userId": "int64 // 用户ID"
}
```

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

```json
{}
```

**调用示例**

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

---

## deleteNSRecord
> 删除记录

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

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

```json
{
  "nsRecordId": "int64"
}
```

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

```json
{}
```

**调用示例**

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

---

## deleteNSRecordsWithDomainNames
> 批量删除一组域名的一组记录

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

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

```json
{
  "nsDomainNames": "[]string",
  "searchName": "string",
  "searchValue": "string",
  "searchType": "string",
  "searchNSRouteCodes": "[]string",
  "userId": "int64 // 用户ID"
}
```

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

```json
{}
```

**调用示例**

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

---

## findNSRecord
> 查询单个记录信息

- 角色：`admin`, `user`
- HTTP：`POST https://backend.dooki.cloud/NSRecordService/findNSRecord`
- RPC：`rpc findNSRecord (FindNSRecordRequest) returns (FindNSRecordResponse);`

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

```json
{
  "nsRecordId": "int64"
}
```

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

```json
{
  "nsRecord": "NSRecord"
}
```

**调用示例**

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

---

## findNSRecordHealthCheck
> 查询记录健康检查设置

- 角色：`admin`, `user`
- HTTP：`POST https://backend.dooki.cloud/NSRecordService/findNSRecordHealthCheck`
- RPC：`rpc findNSRecordHealthCheck(FindNSRecordHealthCheckRequest) returns (FindNSRecordHealthCheckResponse);`

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

```json
{
  "nsRecordId": "int64 // 记录ID"
}
```

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

```json
{
  "nsRecordHealthCheckJSON": "bytes // 记录健康检查配置"
}
```

**调用示例**

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

---

## findNSRecordWithNameAndType
> 使用名称和类型查询单个记录信息

- 角色：`admin`, `user`
- HTTP：`POST https://backend.dooki.cloud/NSRecordService/findNSRecordWithNameAndType`
- RPC：`rpc findNSRecordWithNameAndType(FindNSRecordWithNameAndTypeRequest) returns (FindNSRecordWithNameAndTypeResponse);`

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

```json
{
  "nsDomainId": "int64",
  "name": "string // 名称",
  "type": "string"
}
```

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

```json
{
  "nsRecord": "NSRecord"
}
```

**调用示例**

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

---

## findNSRecordsWithNameAndType
> 使用名称和类型查询多个记录信息

- 角色：`admin`, `user`
- HTTP：`POST https://backend.dooki.cloud/NSRecordService/findNSRecordsWithNameAndType`
- RPC：`rpc findNSRecordsWithNameAndType(FindNSRecordsWithNameAndTypeRequest) returns (FindNSRecordsWithNameAndTypeResponse);`

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

```json
{
  "nsDomainId": "int64",
  "name": "string // 名称",
  "type": "string"
}
```

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

```json
{
  "nsRecords": "[]NSRecord"
}
```

**调用示例**

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

---

## importNSRecords
> 导入域名解析

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

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

```json
{
  "nsRecords": "[]Record",
  "userId": "int64 // 用户ID",
  "nsDomainName": "string",
  "name": "string // 名称",
  "type": "string",
  "value": "string",
  "ttl": "int32",
  "mxPriority": "int32 // MX优先级",
  "weight": "int32 // 权重",
  "srvPriority": "int32 // SRV优先级",
  "srvWeight": "int32 // SRV权重",
  "srvPort": "int32 // SRV端口",
  "caaFlag": "int32 // CAA Flag",
  "caaTag": "string // CAA TAG"
}
```

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

```json
{}
```

**调用示例**

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

---

## listNSRecords
> 读取单页记录

- 角色：`admin`, `user`
- HTTP：`POST https://backend.dooki.cloud/NSRecordService/listNSRecords`
- RPC：`rpc listNSRecords (ListNSRecordsRequest) returns (ListNSRecordsResponse);`

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

```json
{
  "nsDomainId": "int64",
  "type": "string",
  "nsRouteCode": "string // 使用nsRouteCode代替",
  "keyword": "string // 关键词",
  "nameAsc": "bool",
  "nameDesc": "bool",
  "typeAsc": "bool",
  "typeDesc": "bool",
  "ttlAsc": "bool",
  "ttlDesc": "bool",
  "upAsc": "bool",
  "upDesc": "bool",
  "offset": "int64 // 读取位置",
  "size": "int64 // 数量，通常不能小于0"
}
```

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

```json
{
  "nsRecords": "[]NSRecord"
}
```

**调用示例**

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

---

## updateNSRecord
> 修改记录

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

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

```json
{
  "nsRecordId": "int64",
  "description": "string // 描述（备注）",
  "name": "string // 名称",
  "type": "string",
  "value": "string",
  "ttl": "int32",
  "isOn": "bool // 是否启用",
  "nsRouteCodes": "[]string // 路线代号",
  "weight": "int32 // 权重",
  "mxPriority": "int32 // mx优先级",
  "srvPriority": "int32 // SRV优先级",
  "srvWeight": "int32 // SRV权重",
  "srvPort": "int32 // SRV端口",
  "caaFlag": "int32 // CAA Flag",
  "caaTag": "string // CAA TAG"
}
```

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

```json
{}
```

**调用示例**

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

---

## updateNSRecordHealthCheck
> 修改记录健康检查设置

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

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

```json
{
  "nsRecordId": "int64 // 记录ID",
  "nsRecordHealthCheckJSON": "bytes // 记录健康检查配置"
}
```

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

```json
{}
```

**调用示例**

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

---

## updateNSRecordIsUp
> 手动修改记录在线状态

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

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

```json
{
  "nsRecordId": "int64 // 记录ID",
  "isUp": "bool // 是否在线"
}
```

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

```json
{}
```

**调用示例**

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

---

## updateNSRecordsIsOnWithDomainNames
> 批量一组域名的一组记录启用状态

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

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

```json
{
  "nsDomainNames": "[]string",
  "searchName": "string",
  "searchValue": "string",
  "searchType": "string",
  "searchNSRouteCodes": "[]string",
  "isOn": "bool // 是否启用",
  "userId": "int64 // 用户ID"
}
```

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

```json
{}
```

**调用示例**

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

---

## updateNSRecordsWithDomainNames
> 批量修改一组域名的一组记录

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

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

```json
{
  "nsDomainNames": "[]string",
  "searchName": "string",
  "searchValue": "string",
  "searchType": "string",
  "searchNSRouteCodes": "[]string",
  "newName": "string",
  "newValue": "string",
  "newType": "string",
  "newNSRouteCodes": "[]string",
  "userId": "int64 // 用户ID"
}
```

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

```json
{}
```

**调用示例**

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

---
