/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package org.apache.gravitino.dto;

import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Collections;
import java.util.Map;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;

/** Represents the result of a single health check (e.g. entity store, HTTP server). */
@Getter
@EqualsAndHashCode
@ToString
public class HealthCheckDTO {

  /** Status of a health check, matching MicroProfile Health vocabulary. */
  public enum Status {
    /** The component is healthy and functioning normally. */
    UP,
    /** The component is unhealthy or unreachable. */
    DOWN
  }

  @JsonProperty("name")
  private final String name;

  @JsonProperty("status")
  private final Status status;

  @JsonProperty("details")
  private final Map<String, String> details;

  /**
   * Constructor for HealthCheckDTO.
   *
   * @param name the name of the check (e.g. "entityStore")
   * @param status the status of the check
   * @param details optional diagnostic details; null is coerced to empty map
   */
  public HealthCheckDTO(String name, Status status, Map<String, String> details) {
    this.name = name;
    this.status = status;
    this.details = details == null ? Collections.emptyMap() : details;
  }

  /** Default constructor for HealthCheckDTO. (Used for Jackson deserialization.) */
  public HealthCheckDTO() {
    this.name = null;
    this.status = null;
    this.details = Collections.emptyMap();
  }
}
