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;

// HookConfig is the specification of a hook
message HookConfig {
  option (gogoproto.face) = true;
  option (gogoproto.goproto_getters) = false;

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

  // Command is the command to be executed
  string command = 2;

  // Timeout is the timeout, in seconds, at which the hook has to run
  uint32 timeout = 3 [(gogoproto.jsontag) = "timeout"];

  // Stdin indicates if hook requests have stdin enabled
  bool stdin = 4 [(gogoproto.jsontag) = "stdin"];
}

// A Hook is a hook specification and optionally the results of the hook's
// execution.
message Hook {
  // Config is the specification of a hook
  HookConfig config = 1 [(gogoproto.nullable) = false, (gogoproto.embed) = true, (gogoproto.jsontag) = ""];

  // Duration of execution
  double duration = 2;

  // Executed describes the time in which the hook request was executed
  int64 executed = 3 [(gogoproto.jsontag) = "executed"];

  // Issued describes the time in which the hook request was issued
  int64 issued = 4 [(gogoproto.jsontag) = "issued"];

  // Output from the execution of Command
  string output = 5;

  // Status is the exit status code produced by the hook
  int32 status = 6 [(gogoproto.jsontag) = "status"];
}

message HookList {
  // Hooks is the list of hooks for the check hook
  repeated string hooks = 1 [(gogoproto.jsontag) = "hooks"];

  // Type indicates the type or response code for the check hook
  string type = 2;
}
