mirror of
https://github.com/lorsanstand/HomeOps-Hub.git
synced 2026-06-19 17:45:17 +03:00
refactor: separate proto file, edit capabilities
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
syntax = "proto3";
|
||||
|
||||
import "google/protobuf/empty.proto";
|
||||
import "api/proto/homeops/register.proto";
|
||||
import "api/proto/homeops/stream.proto";
|
||||
|
||||
option go_package = "github.com/lorsanstand/HomeOps-Hub/api/gen/homeops;homeops";
|
||||
|
||||
@@ -8,77 +10,4 @@ service Hub {
|
||||
rpc Ping (google.protobuf.Empty) returns (PongResponse) {}
|
||||
rpc RegisterAgent (RegisterAgentRequest) returns (RegisterAgentResponse) {}
|
||||
rpc StreamConnection (stream AgentEvent) returns (stream ServerCommandRequest) {}
|
||||
}
|
||||
|
||||
message PongResponse {
|
||||
string pong = 1;
|
||||
}
|
||||
|
||||
message RegisterAgentRequest {
|
||||
string agent_id = 1;
|
||||
string agent_name = 2;
|
||||
string version = 3;
|
||||
HostInfo host = 4;
|
||||
repeated Capability capability = 5;
|
||||
}
|
||||
|
||||
message HostInfo {
|
||||
string system = 1;
|
||||
string hostname = 2;
|
||||
string arch = 3;
|
||||
}
|
||||
|
||||
message Capability {
|
||||
bool available = 1;
|
||||
string version = 2;
|
||||
string name = 3;
|
||||
string reason = 4;
|
||||
}
|
||||
|
||||
message RegisterAgentResponse {
|
||||
int64 heartbeat_interval_second = 1;
|
||||
string agent_id = 2;
|
||||
}
|
||||
|
||||
message ServerCommandRequest {
|
||||
string request_id = 1;
|
||||
string name = 2;
|
||||
map<string, string> args = 3;
|
||||
int64 timeout_seconds = 4;
|
||||
}
|
||||
|
||||
message AgentEvent {
|
||||
string agent_id = 1;
|
||||
|
||||
oneof event {
|
||||
Heartbeat heartbeat = 2;
|
||||
CommandResponse command_response = 3;
|
||||
Alert alert = 4;
|
||||
}
|
||||
}
|
||||
|
||||
message Heartbeat {
|
||||
int64 timestamp = 1;
|
||||
SystemMetrics metrics = 2;
|
||||
}
|
||||
|
||||
message SystemMetrics {
|
||||
float cpu_usage = 1;
|
||||
float memory_usage = 2;
|
||||
float disk_usage = 3;
|
||||
}
|
||||
|
||||
message CommandResponse {
|
||||
string request_id = 1;
|
||||
bool success = 2;
|
||||
string output = 3;
|
||||
string error = 4;
|
||||
int64 exec_time_ms = 5;
|
||||
}
|
||||
|
||||
message Alert {
|
||||
int64 timestamp = 1;
|
||||
string level = 2;
|
||||
string title = 3;
|
||||
string description = 4;
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
syntax = "proto3";
|
||||
|
||||
message PongResponse {
|
||||
string pong = 1;
|
||||
}
|
||||
|
||||
message RegisterAgentRequest {
|
||||
string agent_id = 1;
|
||||
string agent_name = 2;
|
||||
string version = 3;
|
||||
HostInfo host = 4;
|
||||
repeated Capability capability = 5;
|
||||
}
|
||||
|
||||
message HostInfo {
|
||||
string system = 1;
|
||||
string hostname = 2;
|
||||
string arch = 3;
|
||||
}
|
||||
|
||||
message Capability {
|
||||
bool available = 1; // доступен ли
|
||||
string version = 2; // версия раздела
|
||||
string name = 3; // название раздела по типу докер или управление пк
|
||||
string reason = 4; // причина если раздел не доступент
|
||||
repeated CapabilityCommand command = 5; // команды раздела
|
||||
}
|
||||
|
||||
message CapabilityCommand {
|
||||
string name = 1; // название команды
|
||||
repeated CommandsArgs opt_args = 2; // опциоанльные переменные
|
||||
repeated CommandsArgs req_args = 3; // обязательные переменные
|
||||
string version = 4; // версия команды
|
||||
string description = 5; // описание команды для документации
|
||||
}
|
||||
|
||||
message CommandsArgs {
|
||||
string name = 1; // название аргумента
|
||||
string type = 2; // какой тип path int string bool
|
||||
string description = 3; // описание для документации
|
||||
string default = 4; // значение по умолчанию
|
||||
repeated string enum = 5; // enum комманд по типу run stop restart
|
||||
ArgValidation validation = 6;
|
||||
}
|
||||
|
||||
message ArgValidation {
|
||||
int64 min_value = 1; // для чисел
|
||||
int64 max_value = 2; // для чисел
|
||||
string pattern = 3; // для regex строк
|
||||
repeated string allowed_exts = 4; // для путей и файлов по типу .zip .rar итд
|
||||
}
|
||||
|
||||
message RegisterAgentResponse {
|
||||
int64 heartbeat_interval_second = 1;
|
||||
string agent_id = 2;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
syntax = "proto3";
|
||||
|
||||
message ServerCommandRequest {
|
||||
string request_id = 1;
|
||||
string name = 2;
|
||||
map<string, string> args = 3;
|
||||
int64 timeout_seconds = 4;
|
||||
}
|
||||
|
||||
message AgentEvent {
|
||||
string agent_id = 1;
|
||||
|
||||
oneof event {
|
||||
Heartbeat heartbeat = 2;
|
||||
CommandResponse command_response = 3;
|
||||
Alert alert = 4;
|
||||
}
|
||||
}
|
||||
|
||||
message Heartbeat {
|
||||
int64 timestamp = 1;
|
||||
SystemMetrics metrics = 2;
|
||||
}
|
||||
|
||||
message SystemMetrics {
|
||||
float cpu_usage = 1;
|
||||
float memory_usage = 2;
|
||||
float disk_usage = 3;
|
||||
}
|
||||
|
||||
message CommandResponse {
|
||||
string request_id = 1;
|
||||
bool success = 2;
|
||||
string output = 3;
|
||||
string error = 4;
|
||||
int64 exec_time_ms = 5;
|
||||
}
|
||||
|
||||
message Alert {
|
||||
int64 timestamp = 1;
|
||||
string level = 2;
|
||||
string title = 3;
|
||||
string description = 4;
|
||||
}
|
||||
Reference in New Issue
Block a user