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

package pb;

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

service NodeIPAddressService {
	// 创建IP地址
	rpc createNodeIPAddress (CreateNodeIPAddressRequest) returns (CreateNodeIPAddressResponse);

	// 修改IP地址
	rpc updateNodeIPAddress (UpdateNodeIPAddressRequest) returns (RPCSuccess);

	// 修改IP地址所属节点
	rpc updateNodeIPAddressNodeId (UpdateNodeIPAddressNodeIdRequest) returns (RPCSuccess);

	// 禁用单个IP地址
	rpc disableNodeIPAddress (DisableNodeIPAddressRequest) returns (DisableNodeIPAddressResponse);

	// 禁用节点的所有IP地址
	rpc disableAllNodeIPAddressesWithNodeId (DisableAllNodeIPAddressesWithNodeIdRequest) returns (DisableAllNodeIPAddressesWithNodeIdResponse);

	// 查找单个IP地址
	rpc findEnabledNodeIPAddress (FindEnabledNodeIPAddressRequest) returns (FindEnabledNodeIPAddressResponse);

	// 查找节点的所有地址
	rpc findAllEnabledNodeIPAddressesWithNodeId (FindAllEnabledNodeIPAddressesWithNodeIdRequest) returns (FindAllEnabledNodeIPAddressesWithNodeIdResponse);

	// 计算IP地址数量
	rpc countAllEnabledNodeIPAddresses(CountAllEnabledNodeIPAddressesRequest) returns (RPCCountResponse);

	// 列出单页IP地址
	rpc listEnabledNodeIPAddresses(ListEnabledNodeIPAddressesRequest) returns (ListEnabledNodeIPAddressesResponse);

	// 设置上下线状态
	rpc updateNodeIPAddressIsUp(UpdateNodeIPAddressIsUpRequest) returns (RPCSuccess);

	// 还原备用IP状态
	rpc restoreNodeIPAddressBackupIP(RestoreNodeIPAddressBackupIPRequest) returns (RPCSuccess);
}

// 创建IP地址
message CreateNodeIPAddressRequest {
	int64 nodeId = 1;
	string role = 2;
	string name = 3;
	string ip = 4;
	bool canAccess = 5;
	bool isUp = 6;
}

message CreateNodeIPAddressResponse {
	int64 nodeIPAddressId = 1;
}

// 修改IP地址
message UpdateNodeIPAddressRequest {
	int64 nodeIPAddressId = 1;
	string name = 2;
	string ip = 3;
	bool canAccess = 4;
	bool isOn = 5;
	bool isUp = 6;
}

// 修改IP地址所属节点
message UpdateNodeIPAddressNodeIdRequest {
	int64 nodeIPAddressId = 1;
	int64 nodeId = 2;
}

// 禁用单个IP地址
message DisableNodeIPAddressRequest {
	int64 nodeIPAddressId = 1;
}

message DisableNodeIPAddressResponse {

}

// 禁用节点的所有IP地址
message DisableAllNodeIPAddressesWithNodeIdRequest {
	int64 nodeId = 1;
	string role = 2;
}

message DisableAllNodeIPAddressesWithNodeIdResponse {

}

// 查找单个IP地址
message FindEnabledNodeIPAddressRequest {
	int64 nodeIPAddressId = 1;
}

message FindEnabledNodeIPAddressResponse {
	NodeIPAddress nodeIPAddress = 1;
}

// 查找节点的所有地址
message FindAllEnabledNodeIPAddressesWithNodeIdRequest {
	int64 nodeId = 1;
	string role = 2;
}

message FindAllEnabledNodeIPAddressesWithNodeIdResponse {
	repeated NodeIPAddress nodeIPAddresses = 1;
}

// 计算IP地址数量
message CountAllEnabledNodeIPAddressesRequest {
	int64 nodeClusterId = 1;
	string role = 2;
	int32 upState = 3;
	string keyword = 4;
}

// 列出单页IP地址
message ListEnabledNodeIPAddressesRequest {
	int64 nodeClusterId = 1;
	string role = 2;
	int32 upState = 3;
	string keyword = 4;
	int64 offset = 5;
	int64 size = 6;
}

message ListEnabledNodeIPAddressesResponse {
	repeated NodeIPAddress nodeIPAddresses = 1;
}

// 设置上下线状态
message UpdateNodeIPAddressIsUpRequest {
	int64 nodeIPAddressId = 1;
	bool isUp = 2;
}

// 还原备用IP状态
message RestoreNodeIPAddressBackupIPRequest {
	int64 nodeIPAddressId = 1;
}