syntax = "proto3";

package panel.v1;

option go_package = "github.com/dbledeez/panel/proto/panel/v1;panelv1";

import "google/protobuf/timestamp.proto";

// RunMode selects how a game instance is launched on a Target.
enum RunMode {
  RUN_MODE_UNSPECIFIED = 0;
  RUN_MODE_DOCKER = 1;
  RUN_MODE_HOST = 2;
}

// InstanceStatus is the coarse lifecycle state of an instance.
enum InstanceStatus {
  INSTANCE_STATUS_UNSPECIFIED = 0;
  INSTANCE_STATUS_STOPPED = 1;
  INSTANCE_STATUS_STARTING = 2;
  INSTANCE_STATUS_RUNNING = 3;
  INSTANCE_STATUS_STOPPING = 4;
  INSTANCE_STATUS_CRASHED = 5;
  INSTANCE_STATUS_UPDATING = 6;
}

// ResourceLimits caps an instance's CPU / memory / disk usage.
message ResourceLimits {
  uint32 cpu_shares = 1;       // relative weight, 1024 = 1 core equivalent
  uint64 mem_bytes = 2;        // hard memory ceiling
  uint64 disk_bytes = 3;       // data dir quota, 0 = unlimited
}

// PortMap declares a port exposed by an instance.
message PortMap {
  string name = 1;             // logical name: "game", "rcon", "query"
  string proto = 2;            // "tcp" or "udp"
  uint32 container_port = 3;   // port inside the sandbox
  uint32 host_port = 4;        // port on the Target host (0 = same as container_port)
  bool internal = 5;           // true = not exposed outside the Target
}

// Error is a structured error payload carried on the wire.
message Error {
  string code = 1;             // short machine-readable code
  string message = 2;          // human-readable message
  google.protobuf.Timestamp at = 3;
}
