syntax = "proto3";

package protobuf;

import "google/protobuf/any.proto";
import "google/protobuf/timestamp.proto";

option go_package = "internal/agent/pb";

message Container {
  string id = 1;
  string name = 2;
  string image = 3;
  string status = 4; // deprecated
  string state = 5;
  string ImageId = 6; // deprecated
  google.protobuf.Timestamp created = 7;
  google.protobuf.Timestamp started = 8;
  string health = 9;
  string host = 10;
  bool tty = 11;
  map<string, string> labels = 12;
  repeated ContainerStat stats = 13;
  string group = 14;
  string command = 15;
  google.protobuf.Timestamp finished = 16;
  uint64 memoryLimit = 17;
  double cpuLimit = 18;
  bool fullyLoaded = 19;
  repeated string env = 20;
  repeated string ports = 21;
  repeated string mounts = 22;
  string restartPolicy = 23;
  string networkMode = 24;
}

message ContainerStat {
  string id = 1;
  double cpuPercent = 2;
  double memoryUsage = 3;
  double memoryPercent = 4;
  uint64 networkRxTotal = 5;
  uint64 networkTxTotal = 6;
}

message LogFragment {
  string message = 1;
}

message LogEvent {
  uint32 id = 1;
  string containerId = 2;
  google.protobuf.Any message = 3; // SingleMessage, GroupMessage, or ComplexMessage
  google.protobuf.Timestamp timestamp = 4;
  string level = 5;
  string stream = 6;
  string type = 7; // "single", "group", or "complex"
  string rawMessage = 8;
}

message SingleMessage {
  string message = 1;
}

message GroupMessage {
  repeated LogFragment fragments = 1;
}

message ComplexMessage {
  bytes data = 1;
}

message ContainerEvent {
  string actorId = 1;
  string name = 2;
  string host = 3;
  google.protobuf.Timestamp timestamp = 4;
  map<string, string> actorAttributes = 5;
}

message Host {
  string id = 1;
  string name = 2;
  string nodeAddress = 3;
  bool swarm = 4;
  map<string, string> labels = 5;
  string operatingSystem = 6;
  string osVersion = 7;
  string osType = 8;
  uint32 cpuCores = 9;
  uint64 memory = 10;
  string agentVersion = 11;
  string dockerVersion = 12;
}

enum ContainerAction {
  Start = 0;
  Stop = 1;
  Restart = 2;
}

message NotificationSubscription {
  int32 id = 1;
  string name = 2;
  bool enabled = 3;
  int32 dispatcherId = 4;
  string logExpression = 5;
  string containerExpression = 6;
  string metricExpression = 7;
  int32 cooldown = 8;
  int32 sampleWindow = 9;
  string eventExpression = 10;
}

message NotificationDispatcher {
  int32 id = 1;
  string name = 2;
  string type = 3;
  string url = 4;
  string template = 5;
  map<string, string> headers = 6;
  // Fields 7-9 removed (cloud fields moved to NotificationCloudConfig)
  reserved 7, 8, 9;
}

message NotificationCloudConfig {
  string apiKey = 1;
  string prefix = 2;
  google.protobuf.Timestamp expiresAt = 3;
}

message NotificationSubscriptionStats {
  int32 subscriptionId = 1;
  int64 triggerCount = 2;
  google.protobuf.Timestamp lastTriggeredAt = 3;
  repeated string triggeredContainerIds = 4;
}
