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

package pb;

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

// NS密钥相关服务
service NSKeyService {
	// 创建密钥
	rpc createNSKey (CreateNSKeyRequest) returns (CreateNSKeyResponse);

	// 修改密钥
	rpc updateNSKey (UpdateNSKeyRequest) returns (RPCSuccess);

	// 删除密钥
	rpc deleteNSKey (DeleteNSKeyRequest) returns (RPCSuccess);

	// 查找单个密钥
	rpc findNSKey (FindNSKeyRequest) returns (FindNSKeyResponse);

	// 计算密钥数量
	rpc countAllNSKeys (CountAllNSKeysRequest) returns (RPCCountResponse);

	// 列出单页密钥
	rpc listNSKeys (ListNSKeysRequest) returns (ListNSKeysResponse);

	// 根据版本列出一组密钥
	rpc listNSKeysAfterVersion (ListNSKeysAfterVersionRequest) returns (ListNSKeysAfterVersionResponse);
}

// 创建密钥
message CreateNSKeyRequest {
	int64 nsDomainId = 1;
	int64 nsZoneId = 2;
	string name = 3;
	string algo = 4;
	string secret = 5;
	string secretType = 6;
}

message CreateNSKeyResponse {
	int64 nsKeyId = 1;
}

// 修改密钥
message UpdateNSKeyRequest {
	int64 nsKeyId = 1;
	string name = 2;
	string algo = 3;
	string secret = 4;
	string secretType = 5;
	bool isOn = 6;
}

// 删除密钥
message DeleteNSKeyRequest {
	int64 nsKeyId = 1;
}

// 查找单个密钥
message FindNSKeyRequest {
	int64 nsKeyId = 1;
}

message FindNSKeyResponse {
	NSKey nsKey = 1;
}

// 计算密钥数量
message CountAllNSKeysRequest {
	int64 nsDomainId = 1;
	int64 nsZoneId = 2;
}

// 列出单页密钥
message ListNSKeysRequest {
	int64 nsDomainId = 1;
	int64 nsZoneId = 2;
	int64 offset = 3;
	int64 size = 4;
}

message ListNSKeysResponse {
	repeated NSKey nsKeys = 1;
}

// 根据版本列出一组密钥
message ListNSKeysAfterVersionRequest {
	int64 version = 1;
	int64 size = 2;
}

message ListNSKeysAfterVersionResponse {
	repeated NSKey nsKeys = 1;
}