syntax = "proto3";

import "github.com/gogo/protobuf/gogoproto/gogo.proto";
import "meta.proto";

package sensu.core.v2;

option go_package = "v2";
option (gogoproto.populate_all) = true;
option (gogoproto.equal_all) = true;
option (gogoproto.marshaler_all) = true;
option (gogoproto.unmarshaler_all) = true;
option (gogoproto.sizer_all) = true;
option (gogoproto.testgen_all) = true;

// A Handler is a handler specification.
message Handler {
  option (gogoproto.face) = true;
  option (gogoproto.goproto_getters) = false;

  // Metadata contains the name, namespace, labels and annotations of the handler
  ObjectMeta metadata = 1 [(gogoproto.jsontag) = "metadata,omitempty", (gogoproto.embed) = true, (gogoproto.nullable) = false];

  // Type is the handler type, i.e. pipe.
  string type = 2;

  // Mutator is the handler event data mutator.
  string mutator = 3;

  // Command is the command to be executed for a pipe handler.
  string command = 4;

  // Timeout is the handler timeout in seconds.
  uint32 timeout = 5 [(gogoproto.jsontag) = "timeout"];

  // Socket contains configuration for a TCP or UDP handler.
  HandlerSocket socket = 6 [(gogoproto.nullable) = true];

  // Handlers is a list of handlers for a handler set.
  repeated string handlers = 7 [(gogoproto.jsontag) = "handlers"];

  // Filters is a list of filters name to evaluate before executing this handler
  repeated string filters = 8 [(gogoproto.jsontag) = "filters"];

  // EnvVars is a list of environment variables to use with command execution
  repeated string env_vars = 9 [(gogoproto.jsontag) = "env_vars"];

  // RuntimeAssets are a list of assets required to execute a handler.
  repeated string runtime_assets = 13 [(gogoproto.jsontag) = "runtime_assets"];
}

// HandlerSocket contains configuration for a TCP or UDP handler.
message HandlerSocket {
  // Host is the socket peer address.
  string host = 1;

  // Port is the socket peer port.
  uint32 port = 2 [(gogoproto.jsontag) = "port"];
}
