syntax = "proto3";

package health;

import "google/protobuf/timestamp.proto";
import "google/protobuf/empty.proto";
import "google/api/annotations.proto";

option csharp_namespace = "CMSMicroservice.Protobuf.Protos.Health";

service HealthContract
{
    rpc GetSystemHealth(google.protobuf.Empty) returns (GetSystemHealthResponse){
        option (google.api.http) = {
            get: "/Health/System"
        };
    };
    
    rpc GetServiceHealth(GetServiceHealthRequest) returns (GetServiceHealthResponse){
        option (google.api.http) = {
            get: "/Health/Service/{service_name}"
        };
    };
}

message GetServiceHealthRequest
{
    string service_name = 1;
}

message GetSystemHealthResponse
{
    bool overall_healthy = 1;
    repeated ServiceHealthModel services = 2;
    google.protobuf.Timestamp checked_at = 3;
    string version = 4;
    string environment = 5;
}

message GetServiceHealthResponse
{
    ServiceHealthModel service = 1;
    google.protobuf.Timestamp checked_at = 2;
}

message ServiceHealthModel
{
    string service_name = 1;
    HealthStatus status = 2;
    string description = 3;
    int64 response_time_ms = 4;
    google.protobuf.Timestamp last_check = 5;
    repeated HealthDetail details = 6;
}

message HealthDetail
{
    string key = 1;
    string value = 2;
    HealthStatus status = 3;
}

enum HealthStatus
{
    UNKNOWN = 0;
    HEALTHY = 1;
    DEGRADED = 2;
    UNHEALTHY = 3;
}