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

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

service APINodeService {
	// 创建API节点
	rpc createAPINode (CreateAPINodeRequest) returns (CreateAPINodeResponse);

	// 修改API节点
	rpc updateAPINode (UpdateAPINodeRequest) returns (RPCSuccess);

	// 删除API节点
	rpc deleteAPINode (DeleteAPINodeRequest) returns (RPCSuccess);

	// 列出所有可用API节点
	rpc findAllEnabledAPINodes (FindAllEnabledAPINodesRequest) returns (FindAllEnabledAPINodesResponse);

	// 计算API节点数量
	rpc countAllEnabledAPINodes (CountAllEnabledAPINodesRequest) returns (RPCCountResponse);

	// 计算启用的API节点数量
	rpc countAllEnabledAndOnAPINodes (CountAllEnabledAndOnAPINodesRequest) returns (RPCCountResponse);

	// 列出单页的API节点
	rpc listEnabledAPINodes (ListEnabledAPINodesRequest) returns (ListEnabledAPINodesResponse);

	// 根据ID查找节点
	rpc findEnabledAPINode (FindEnabledAPINodeRequest) returns (FindEnabledAPINodeResponse);

	// 获取当前API节点的版本
	rpc findCurrentAPINodeVersion (FindCurrentAPINodeVersionRequest) returns (FindCurrentAPINodeVersionResponse);

	// 计算使用某个SSL证书的API节点数量
	rpc countAllEnabledAPINodesWithSSLCertId (CountAllEnabledAPINodesWithSSLCertIdRequest) returns (RPCCountResponse);
}

// 创建API节点
message CreateAPINodeRequest {
	string name = 1;
	string description = 2;
	bytes httpJSON = 3;
	bytes httpsJSON = 4;
	bytes accessAddrsJSON = 5;
	bool isOn = 6;
	bool restIsOn = 7;
	bytes restHTTPJSON = 8;
	bytes restHTTPSJSON = 9;
}

message CreateAPINodeResponse {
	int64 apiNodeId = 1;
}

// 修改API节点
message UpdateAPINodeRequest {
	int64 apiNodeId = 1;
	string name = 2;
	string description = 3;
	bytes httpJSON = 4;
	bytes httpsJSON = 5;
	bytes accessAddrsJSON = 6;
	bool isOn = 7;
	bool restIsOn = 8;
	bytes restHTTPJSON = 9;
	bytes restHTTPSJSON = 10;
}

// 删除API节点
message DeleteAPINodeRequest {
	int64 apiNodeId = 1;
}

// 列出所有可用API节点
message FindAllEnabledAPINodesRequest {

}

message FindAllEnabledAPINodesResponse {
	repeated APINode apiNodes = 1;
}

// 计算API节点数量
message CountAllEnabledAPINodesRequest {

}

// 计算启用的API节点数量
message CountAllEnabledAndOnAPINodesRequest {

}

// 列出单页的API节点
message ListEnabledAPINodesRequest {
	int64 offset = 1;
	int64 size = 2;
}

message ListEnabledAPINodesResponse {
	repeated APINode apiNodes = 1;
}

// 根据ID查找节点
message FindEnabledAPINodeRequest {
	int64 apiNodeId = 1;
}

message FindEnabledAPINodeResponse {
	APINode apiNode = 1;
}

// 获取当前API节点的版本
message FindCurrentAPINodeVersionRequest {

}

message FindCurrentAPINodeVersionResponse {
	string version = 1;
}

// 计算使用某个SSL证书的API节点数量
message CountAllEnabledAPINodesWithSSLCertIdRequest {
	int64 sslCertId = 1;
}