syntax = "proto3";

package pbservice;

option go_package = "github.com/hashicorp/consul/proto/pbservice";

import "google/protobuf/duration.proto";
import "proto/pbcommon/common.proto";

// This fake import path is replaced by the build script with a versioned path
import "gogoproto/gogo.proto";

option (gogoproto.goproto_unkeyed_all) = false;
option (gogoproto.goproto_unrecognized_all) = false;
option (gogoproto.goproto_getters_all) = false;
option (gogoproto.goproto_sizecache_all) = false;

// HealthCheck represents a single check on a given node
//
// mog annotation:
//
// target=github.com/hashicorp/consul/agent/structs.HealthCheck
// output=healthcheck.gen.go
// name=Structs
message HealthCheck {
    string Node = 1;
    string CheckID = 2 [(gogoproto.casttype) = "github.com/hashicorp/consul/types.CheckID"];
    string Name = 3;
    string Status = 4;                // The current check status
    string Notes = 5;                 // Additional notes with the status
    string Output = 6;                // Holds output of script runs
    string ServiceID = 7;             // optional associated service
    string ServiceName = 8;           // optional service name
    repeated string ServiceTags = 9;  // optional service tags
    string Type = 12;                 // Check type: http/ttl/tcp/etc

    HealthCheckDefinition Definition = 10 [(gogoproto.nullable) = false];

    // mog: func-to=RaftIndexToStructs func-from=NewRaftIndexFromStructs
    common.RaftIndex RaftIndex = 11 [(gogoproto.embed) = true, (gogoproto.nullable) = false];

    // mog: func-to=EnterpriseMetaToStructs func-from=NewEnterpriseMetaFromStructs
    common.EnterpriseMeta EnterpriseMeta = 13  [(gogoproto.nullable) = false];
}

message HeaderValue {
    repeated string Value = 1;
}

// HealthCheckDefinition of a single HealthCheck.
//
// mog annotation:
//
// target=github.com/hashicorp/consul/agent/structs.HealthCheckDefinition
// output=healthcheck.gen.go
// name=Structs
message HealthCheckDefinition {
    string HTTP = 1;
    bool TLSSkipVerify = 2;

    // mog: func-to=MapHeadersToStructs func-from=NewMapHeadersFromStructs
    map<string, HeaderValue> Header = 3 [(gogoproto.nullable) = false];
    string Method = 4;
    string Body = 18;
    bool DisableRedirects = 22;
    string TCP = 5;
    google.protobuf.Duration Interval = 6
    [(gogoproto.stdduration) = true, (gogoproto.nullable) = false];

    // mog: func-to=uint func-from=uint32
    uint32 OutputMaxSize = 9;
    google.protobuf.Duration Timeout = 7
    [(gogoproto.stdduration) = true, (gogoproto.nullable) = false];
    google.protobuf.Duration DeregisterCriticalServiceAfter = 8
    [(gogoproto.stdduration) = true, (gogoproto.nullable) = false];
    repeated string ScriptArgs = 10;
    string DockerContainerID = 11;
    string Shell = 12;
    string GRPC = 13;
    bool GRPCUseTLS = 14;
    string AliasNode = 15;
    string AliasService = 16;
    google.protobuf.Duration TTL = 17
    [(gogoproto.stdduration) = true, (gogoproto.nullable) = false];
}

// CheckType is used to create either the CheckMonitor or the CheckTTL.
// The following types are supported: Script, HTTP, TCP, Docker, TTL, GRPC,
// Alias. Script,
// HTTP, Docker, TCP and GRPC all require Interval. Only one of the types may
// to be provided: TTL or Script/Interval or HTTP/Interval or TCP/Interval or
// Docker/Interval or GRPC/Interval or AliasService.
//
// mog annotation:
//
// target=github.com/hashicorp/consul/agent/structs.CheckType
// output=healthcheck.gen.go
// name=Structs
message CheckType {
    string CheckID = 1 [(gogoproto.casttype) = "github.com/hashicorp/consul/types.CheckID"];
    string Name = 2;
    string Status = 3;
    string Notes = 4;

    repeated string ScriptArgs = 5;
    string HTTP = 6;
    // mog: func-to=MapHeadersToStructs func-from=NewMapHeadersFromStructs
    map<string, HeaderValue> Header = 20 [(gogoproto.nullable) = false];
    string Method = 7;
    string Body = 26;
    bool DisableRedirects = 31;
    string TCP = 8;
    google.protobuf.Duration Interval = 9
    [(gogoproto.stdduration) = true, (gogoproto.nullable) = false];

    string AliasNode = 10;
    string AliasService = 11;
    string DockerContainerID = 12;
    string Shell = 13;
    string GRPC = 14;
    bool GRPCUseTLS = 15;
    bool TLSSkipVerify = 16;
    google.protobuf.Duration Timeout = 17
    [(gogoproto.stdduration) = true, (gogoproto.nullable) = false];
    google.protobuf.Duration TTL = 18
    [(gogoproto.stdduration) = true, (gogoproto.nullable) = false];

    // mog: func-to=int func-from=int32
    int32 SuccessBeforePassing = 21;
    // mog: func-to=int func-from=int32
    int32 FailuresBeforeCritical = 22;

    // Definition fields used when exposing checks through a proxy
    string ProxyHTTP = 23;
    string ProxyGRPC = 24;

    // DeregisterCriticalServiceAfter, if >0, will cause the associated
    // service, if any, to be deregistered if this check is critical for
    // longer than this duration.
    google.protobuf.Duration DeregisterCriticalServiceAfter = 19
    [(gogoproto.stdduration) = true, (gogoproto.nullable) = false];

    // mog: func-to=int func-from=int32
    int32 OutputMaxSize = 25;
}