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

package pb;

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

// 指标相关服务
service MetricItemService {
	// 创建指标
	rpc createMetricItem (CreateMetricItemRequest) returns (CreateMetricItemResponse);

	// 修改指标
	rpc updateMetricItem (UpdateMetricItemRequest) returns (RPCSuccess);

	// 查找单个指标信息
	rpc findEnabledMetricItem (FindEnabledMetricItemRequest) returns (FindEnabledMetricItemResponse);

	// 计算指标数量
	rpc countAllEnabledMetricItems (CountAllEnabledMetricItemsRequest) returns (RPCCountResponse);

	// 列出单页指标
	rpc listEnabledMetricItems (ListEnabledMetricItemsRequest) returns (ListEnabledMetricItemsResponse);

	// 删除指标
	rpc deleteMetricItem (DeleteMetricItemRequest) returns (RPCSuccess);
}

// 创建指标
message CreateMetricItemRequest {
	string code = 1;
	string category = 2;
	string name = 3;
	repeated string keys = 4;
	int32 period = 5;
	string periodUnit = 6;
	string value = 7;
	bool isPublic = 8;
}

message CreateMetricItemResponse {
	int64 metricItemId = 1;
}

// 修改指标
message UpdateMetricItemRequest {
	int64 metricItemId = 1;
	string name = 2;
	repeated string keys = 3;
	int32 period = 4;
	string periodUnit = 5;
	string value = 6;
	bool isOn = 7;
	bool isPublic = 8;
}

// 查找单个指标信息
message FindEnabledMetricItemRequest {
	int64 metricItemId = 1;
}

message FindEnabledMetricItemResponse {
	MetricItem metricItem = 1;
}

// 计算指标数量
message CountAllEnabledMetricItemsRequest {
	string category = 1;
}

// 列出单页指标
message ListEnabledMetricItemsRequest {
	string category = 1;
	int64 offset = 2;
	int64 size = 3;
}

message ListEnabledMetricItemsResponse {
	repeated MetricItem metricItems = 1;
}

// 删除指标
message DeleteMetricItemRequest {
	int64 metricItemId = 1;
}