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

package pb;
import "models/model_authority_node.proto";
import "models/rpc_messages.proto";

// 认证节点管理
service AuthorityNodeService {
	// 创建认证节点
	rpc createAuthorityNode (CreateAuthorityNodeRequest) returns (CreateAuthorityNodeResponse);

	// 修改认证节点
	rpc updateAuthorityNode (UpdateAuthorityNodeRequest) returns (RPCSuccess);

	// 删除认证节点
	rpc deleteAuthorityNode (DeleteAuthorityNodeRequest) returns (RPCSuccess);

	// 列出所有可用认证节点
	rpc findAllEnabledAuthorityNodes (FindAllEnabledAuthorityNodesRequest) returns (FindAllEnabledAuthorityNodesResponse);

	// 计算认证节点数量
	rpc countAllEnabledAuthorityNodes (CountAllEnabledAuthorityNodesRequest) returns (RPCCountResponse);

	// 列出单页的认证节点
	rpc listEnabledAuthorityNodes (ListEnabledAuthorityNodesRequest) returns (ListEnabledAuthorityNodesResponse);

	// 根据ID查找节点
	rpc findEnabledAuthorityNode (FindEnabledAuthorityNodeRequest) returns (FindEnabledAuthorityNodeResponse);

	// 获取当前认证节点信息
	rpc findCurrentAuthorityNode (FindCurrentAuthorityNodeRequest) returns (FindCurrentAuthorityNodeResponse);

	// 更新节点状态
	rpc updateAuthorityNodeStatus (UpdateAuthorityNodeStatusRequest) returns (RPCSuccess);
}

// 创建认证节点
message CreateAuthorityNodeRequest {
	string name = 1;
	string description = 2;
	bool isOn = 3;
}

message CreateAuthorityNodeResponse {
	int64 authorityNodeId = 1;
}

// 修改认证节点
message UpdateAuthorityNodeRequest {
	int64 authorityNodeId = 1;
	string name = 2;
	string description = 3;
	bool isOn = 4;
}

// 删除认证节点
message DeleteAuthorityNodeRequest {
	int64 authorityNodeId = 1;
}

// 列出所有可用认证节点
message FindAllEnabledAuthorityNodesRequest {

}

message FindAllEnabledAuthorityNodesResponse {
	repeated AuthorityNode authorityNodes = 1;
}

// 计算认证节点数量
message CountAllEnabledAuthorityNodesRequest {

}

// 列出单页的认证节点
message ListEnabledAuthorityNodesRequest {
	int64 offset = 1;
	int64 size = 2;
}

message ListEnabledAuthorityNodesResponse {
	repeated AuthorityNode authorityNodes = 1;
}

// 根据ID查找节点
message FindEnabledAuthorityNodeRequest {
	int64 authorityNodeId = 1;
}

message FindEnabledAuthorityNodeResponse {
	AuthorityNode authorityNode = 1;
}

// 获取当前认证节点
message FindCurrentAuthorityNodeRequest {

}

message FindCurrentAuthorityNodeResponse {
	AuthorityNode authorityNode = 1;
}

// 更新认证状态
message UpdateAuthorityNodeStatusRequest {
	int64 authorityNodeId = 1;
	bytes statusJSON = 2;
}