syntax = "proto3";
option go_package = "./pb";

package pb;

import "models/model_ns_record.proto";
import "models/rpc_messages.proto";

// 域名记录相关服务
service NSRecordService {
	// 创建记录
	rpc createNSRecord (CreateNSRecordRequest) returns (CreateNSRecordResponse);

	// 修改记录
	rpc updateNSRecord (UpdateNSRecordRequest) returns (RPCSuccess);

	// 删除记录
	rpc deleteNSRecord (DeleteNSRecordRequest) returns (RPCSuccess);

	// 计算记录数量
	rpc countAllEnabledNSRecords (CountAllEnabledNSRecordsRequest) returns (RPCCountResponse);

	// 读取单页记录
	rpc listEnabledNSRecords (ListEnabledNSRecordsRequest) returns (ListEnabledNSRecordsResponse);

	// 查询单个记录信息
	rpc findEnabledNSRecord (FindEnabledNSRecordRequest) returns (FindEnabledNSRecordResponse);

	// 根据版本列出一组记录
	rpc listNSRecordsAfterVersion (ListNSRecordsAfterVersionRequest) returns (ListNSRecordsAfterVersionResponse);
}

// 创建记录
message CreateNSRecordRequest {
	int64 nsDomainId = 1;
	string description = 2;
	string name = 3;
	string type = 4;
	string value = 5;
	int32 ttl = 6;
	repeated int64 nsRouteIds = 7 [deprecated = true];
	repeated string nsRouteCodes = 8; // 路线代号
}

message CreateNSRecordResponse {
	int64 nsRecordId = 1;
}

// 修改记录
message UpdateNSRecordRequest {
	int64 nsRecordId = 1;
	string description = 2;
	string name = 3;
	string type = 4;
	string value = 5;
	int32 ttl = 6;
	repeated int64 nsRouteIds = 7 [deprecated = true];
	bool isOn = 8;
	repeated string nsRouteCodes = 9; // 路线代号
}

// 删除记录
message DeleteNSRecordRequest {
	int64 nsRecordId = 1;
}

// 计算记录数量
message CountAllEnabledNSRecordsRequest {
	int64 nsDomainId = 1;
	string type = 2;
	int64 nsRouteId = 3 [deprecated = true]; // 使用nsRouteCode代替
	string nsRouteCode = 5;
	string keyword = 4;
}

// 读取单页记录
message ListEnabledNSRecordsRequest {
	int64 nsDomainId = 1;
	string type = 2;
	int64 nsRouteId = 3 [deprecated = true]; // 使用nsRouteCode代替
	string nsRouteCode = 7;
	string keyword = 4;
	int64 offset = 5;
	int64 size = 6;
}

message ListEnabledNSRecordsResponse {
	repeated NSRecord nsRecords = 1;
}

// 查询单个记录信息
message FindEnabledNSRecordRequest {
	int64 nsRecordId = 1;
}

message FindEnabledNSRecordResponse {
	NSRecord nsRecord = 1;
}

// 根据版本列出一组记录
message ListNSRecordsAfterVersionRequest {
	int64 version = 1;
	int64 size = 2;
}

message ListNSRecordsAfterVersionResponse {
	repeated NSRecord nsRecords = 1;
}