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

package pb;

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

// 节点动作服务
service NodeActionService {
	// 添加动作
	rpc createNodeAction(CreateNodeActionRequest) returns (CreateNodeActionResponse);

	// 删除动作
	rpc deleteNodeAction(DeleteNodeActionRequest) returns (RPCSuccess);

	// 修改动作
	rpc updateNodeAction(UpdateNodeActionRequest) returns (RPCSuccess);

	// 列出某个节点的所有动作
	rpc findAllNodeActions(FindAllNodeActionsRequest) returns (FindAllNodeActionsResponse);

	// 查找单个节点动作
	rpc findNodeAction(FindNodeActionRequest) returns (FindNodeActionResponse);

	// 设置节点动作排序
	rpc updateNodeActionOrders(UpdateNodeActionOrdersRequest) returns (RPCSuccess);
}

// 添加动作
message CreateNodeActionRequest {
	int64 nodeId = 1; // 节点ID
	string role = 2; // 节点角色
	bytes condsJSON = 3; // 条件设置
	bytes actionJSON = 4; // 动作设置
	bytes durationJSON = 5; // 持续时间
}

message CreateNodeActionResponse {
	int64 nodeActionId = 1;
}

// 删除动作
message DeleteNodeActionRequest {
	int64 nodeActionId = 1;
}

// 修改动作
message UpdateNodeActionRequest {
	int64 nodeActionId = 1; // 动作ID
	bytes condsJSON = 2;
	bytes actionJSON = 3;
	bytes durationJSON = 4; // 持续时间
	bool isOn = 5; // 是否启用
}

// 列出某个节点的所有动作
message FindAllNodeActionsRequest {
	int64 nodeId = 1; // 节点ID
	string role = 2; // 节点角色
}

message FindAllNodeActionsResponse {
	repeated NodeAction nodeActions = 1; // 动作列表
}

// 查找单个节点动作
message FindNodeActionRequest {
	int64 nodeActionId = 1; // 动作ID
}

message FindNodeActionResponse {
	NodeAction nodeAction = 1;
}

// 设置节点动作排序
message UpdateNodeActionOrdersRequest {
	repeated int64 nodeActionIds = 1; // 节点动作ID列表
}