/*
 * Daytona
 * Daytona AI platform API Docs
 *
 * The version of the OpenAPI document: 1.0
 * Contact: support@daytona.com
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */


package io.daytona.api.client.model;

import java.util.Objects;
import com.google.gson.TypeAdapter;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.annotations.SerializedName;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.Arrays;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.TypeAdapterFactory;
import com.google.gson.reflect.TypeToken;
import com.google.gson.TypeAdapter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;

import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import io.daytona.api.client.JSON;

/**
 * RunnerHealthMetrics
 */
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.21.0")
public class RunnerHealthMetrics {
  public static final String SERIALIZED_NAME_CURRENT_CPU_LOAD_AVERAGE = "currentCpuLoadAverage";
  @SerializedName(SERIALIZED_NAME_CURRENT_CPU_LOAD_AVERAGE)
  @javax.annotation.Nonnull
  private BigDecimal currentCpuLoadAverage;

  public static final String SERIALIZED_NAME_CURRENT_CPU_USAGE_PERCENTAGE = "currentCpuUsagePercentage";
  @SerializedName(SERIALIZED_NAME_CURRENT_CPU_USAGE_PERCENTAGE)
  @javax.annotation.Nonnull
  private BigDecimal currentCpuUsagePercentage;

  public static final String SERIALIZED_NAME_CURRENT_MEMORY_USAGE_PERCENTAGE = "currentMemoryUsagePercentage";
  @SerializedName(SERIALIZED_NAME_CURRENT_MEMORY_USAGE_PERCENTAGE)
  @javax.annotation.Nonnull
  private BigDecimal currentMemoryUsagePercentage;

  public static final String SERIALIZED_NAME_CURRENT_DISK_USAGE_PERCENTAGE = "currentDiskUsagePercentage";
  @SerializedName(SERIALIZED_NAME_CURRENT_DISK_USAGE_PERCENTAGE)
  @javax.annotation.Nonnull
  private BigDecimal currentDiskUsagePercentage;

  public static final String SERIALIZED_NAME_CURRENT_ALLOCATED_CPU = "currentAllocatedCpu";
  @SerializedName(SERIALIZED_NAME_CURRENT_ALLOCATED_CPU)
  @javax.annotation.Nonnull
  private BigDecimal currentAllocatedCpu;

  public static final String SERIALIZED_NAME_CURRENT_ALLOCATED_MEMORY_GI_B = "currentAllocatedMemoryGiB";
  @SerializedName(SERIALIZED_NAME_CURRENT_ALLOCATED_MEMORY_GI_B)
  @javax.annotation.Nonnull
  private BigDecimal currentAllocatedMemoryGiB;

  public static final String SERIALIZED_NAME_CURRENT_ALLOCATED_DISK_GI_B = "currentAllocatedDiskGiB";
  @SerializedName(SERIALIZED_NAME_CURRENT_ALLOCATED_DISK_GI_B)
  @javax.annotation.Nonnull
  private BigDecimal currentAllocatedDiskGiB;

  public static final String SERIALIZED_NAME_CURRENT_SNAPSHOT_COUNT = "currentSnapshotCount";
  @SerializedName(SERIALIZED_NAME_CURRENT_SNAPSHOT_COUNT)
  @javax.annotation.Nonnull
  private BigDecimal currentSnapshotCount;

  public static final String SERIALIZED_NAME_CURRENT_STARTED_SANDBOXES = "currentStartedSandboxes";
  @SerializedName(SERIALIZED_NAME_CURRENT_STARTED_SANDBOXES)
  @javax.annotation.Nonnull
  private BigDecimal currentStartedSandboxes;

  public static final String SERIALIZED_NAME_CPU = "cpu";
  @SerializedName(SERIALIZED_NAME_CPU)
  @javax.annotation.Nonnull
  private BigDecimal cpu;

  public static final String SERIALIZED_NAME_MEMORY_GI_B = "memoryGiB";
  @SerializedName(SERIALIZED_NAME_MEMORY_GI_B)
  @javax.annotation.Nonnull
  private BigDecimal memoryGiB;

  public static final String SERIALIZED_NAME_DISK_GI_B = "diskGiB";
  @SerializedName(SERIALIZED_NAME_DISK_GI_B)
  @javax.annotation.Nonnull
  private BigDecimal diskGiB;

  public RunnerHealthMetrics() {
  }

  public RunnerHealthMetrics currentCpuLoadAverage(@javax.annotation.Nonnull BigDecimal currentCpuLoadAverage) {
    this.currentCpuLoadAverage = currentCpuLoadAverage;
    return this;
  }

  /**
   * Current CPU load average
   * @return currentCpuLoadAverage
   */
  @javax.annotation.Nonnull
  public BigDecimal getCurrentCpuLoadAverage() {
    return currentCpuLoadAverage;
  }

  public void setCurrentCpuLoadAverage(@javax.annotation.Nonnull BigDecimal currentCpuLoadAverage) {
    this.currentCpuLoadAverage = currentCpuLoadAverage;
  }


  public RunnerHealthMetrics currentCpuUsagePercentage(@javax.annotation.Nonnull BigDecimal currentCpuUsagePercentage) {
    this.currentCpuUsagePercentage = currentCpuUsagePercentage;
    return this;
  }

  /**
   * Current CPU usage percentage
   * @return currentCpuUsagePercentage
   */
  @javax.annotation.Nonnull
  public BigDecimal getCurrentCpuUsagePercentage() {
    return currentCpuUsagePercentage;
  }

  public void setCurrentCpuUsagePercentage(@javax.annotation.Nonnull BigDecimal currentCpuUsagePercentage) {
    this.currentCpuUsagePercentage = currentCpuUsagePercentage;
  }


  public RunnerHealthMetrics currentMemoryUsagePercentage(@javax.annotation.Nonnull BigDecimal currentMemoryUsagePercentage) {
    this.currentMemoryUsagePercentage = currentMemoryUsagePercentage;
    return this;
  }

  /**
   * Current memory usage percentage
   * @return currentMemoryUsagePercentage
   */
  @javax.annotation.Nonnull
  public BigDecimal getCurrentMemoryUsagePercentage() {
    return currentMemoryUsagePercentage;
  }

  public void setCurrentMemoryUsagePercentage(@javax.annotation.Nonnull BigDecimal currentMemoryUsagePercentage) {
    this.currentMemoryUsagePercentage = currentMemoryUsagePercentage;
  }


  public RunnerHealthMetrics currentDiskUsagePercentage(@javax.annotation.Nonnull BigDecimal currentDiskUsagePercentage) {
    this.currentDiskUsagePercentage = currentDiskUsagePercentage;
    return this;
  }

  /**
   * Current disk usage percentage
   * @return currentDiskUsagePercentage
   */
  @javax.annotation.Nonnull
  public BigDecimal getCurrentDiskUsagePercentage() {
    return currentDiskUsagePercentage;
  }

  public void setCurrentDiskUsagePercentage(@javax.annotation.Nonnull BigDecimal currentDiskUsagePercentage) {
    this.currentDiskUsagePercentage = currentDiskUsagePercentage;
  }


  public RunnerHealthMetrics currentAllocatedCpu(@javax.annotation.Nonnull BigDecimal currentAllocatedCpu) {
    this.currentAllocatedCpu = currentAllocatedCpu;
    return this;
  }

  /**
   * Currently allocated CPU cores
   * @return currentAllocatedCpu
   */
  @javax.annotation.Nonnull
  public BigDecimal getCurrentAllocatedCpu() {
    return currentAllocatedCpu;
  }

  public void setCurrentAllocatedCpu(@javax.annotation.Nonnull BigDecimal currentAllocatedCpu) {
    this.currentAllocatedCpu = currentAllocatedCpu;
  }


  public RunnerHealthMetrics currentAllocatedMemoryGiB(@javax.annotation.Nonnull BigDecimal currentAllocatedMemoryGiB) {
    this.currentAllocatedMemoryGiB = currentAllocatedMemoryGiB;
    return this;
  }

  /**
   * Currently allocated memory in GiB
   * @return currentAllocatedMemoryGiB
   */
  @javax.annotation.Nonnull
  public BigDecimal getCurrentAllocatedMemoryGiB() {
    return currentAllocatedMemoryGiB;
  }

  public void setCurrentAllocatedMemoryGiB(@javax.annotation.Nonnull BigDecimal currentAllocatedMemoryGiB) {
    this.currentAllocatedMemoryGiB = currentAllocatedMemoryGiB;
  }


  public RunnerHealthMetrics currentAllocatedDiskGiB(@javax.annotation.Nonnull BigDecimal currentAllocatedDiskGiB) {
    this.currentAllocatedDiskGiB = currentAllocatedDiskGiB;
    return this;
  }

  /**
   * Currently allocated disk in GiB
   * @return currentAllocatedDiskGiB
   */
  @javax.annotation.Nonnull
  public BigDecimal getCurrentAllocatedDiskGiB() {
    return currentAllocatedDiskGiB;
  }

  public void setCurrentAllocatedDiskGiB(@javax.annotation.Nonnull BigDecimal currentAllocatedDiskGiB) {
    this.currentAllocatedDiskGiB = currentAllocatedDiskGiB;
  }


  public RunnerHealthMetrics currentSnapshotCount(@javax.annotation.Nonnull BigDecimal currentSnapshotCount) {
    this.currentSnapshotCount = currentSnapshotCount;
    return this;
  }

  /**
   * Number of snapshots currently stored
   * @return currentSnapshotCount
   */
  @javax.annotation.Nonnull
  public BigDecimal getCurrentSnapshotCount() {
    return currentSnapshotCount;
  }

  public void setCurrentSnapshotCount(@javax.annotation.Nonnull BigDecimal currentSnapshotCount) {
    this.currentSnapshotCount = currentSnapshotCount;
  }


  public RunnerHealthMetrics currentStartedSandboxes(@javax.annotation.Nonnull BigDecimal currentStartedSandboxes) {
    this.currentStartedSandboxes = currentStartedSandboxes;
    return this;
  }

  /**
   * Number of started sandboxes
   * @return currentStartedSandboxes
   */
  @javax.annotation.Nonnull
  public BigDecimal getCurrentStartedSandboxes() {
    return currentStartedSandboxes;
  }

  public void setCurrentStartedSandboxes(@javax.annotation.Nonnull BigDecimal currentStartedSandboxes) {
    this.currentStartedSandboxes = currentStartedSandboxes;
  }


  public RunnerHealthMetrics cpu(@javax.annotation.Nonnull BigDecimal cpu) {
    this.cpu = cpu;
    return this;
  }

  /**
   * Total CPU cores on the runner
   * @return cpu
   */
  @javax.annotation.Nonnull
  public BigDecimal getCpu() {
    return cpu;
  }

  public void setCpu(@javax.annotation.Nonnull BigDecimal cpu) {
    this.cpu = cpu;
  }


  public RunnerHealthMetrics memoryGiB(@javax.annotation.Nonnull BigDecimal memoryGiB) {
    this.memoryGiB = memoryGiB;
    return this;
  }

  /**
   * Total RAM in GiB on the runner
   * @return memoryGiB
   */
  @javax.annotation.Nonnull
  public BigDecimal getMemoryGiB() {
    return memoryGiB;
  }

  public void setMemoryGiB(@javax.annotation.Nonnull BigDecimal memoryGiB) {
    this.memoryGiB = memoryGiB;
  }


  public RunnerHealthMetrics diskGiB(@javax.annotation.Nonnull BigDecimal diskGiB) {
    this.diskGiB = diskGiB;
    return this;
  }

  /**
   * Total disk space in GiB on the runner
   * @return diskGiB
   */
  @javax.annotation.Nonnull
  public BigDecimal getDiskGiB() {
    return diskGiB;
  }

  public void setDiskGiB(@javax.annotation.Nonnull BigDecimal diskGiB) {
    this.diskGiB = diskGiB;
  }

  /**
   * A container for additional, undeclared properties.
   * This is a holder for any undeclared properties as specified with
   * the 'additionalProperties' keyword in the OAS document.
   */
  private Map<String, Object> additionalProperties;

  /**
   * Set the additional (undeclared) property with the specified name and value.
   * If the property does not already exist, create it otherwise replace it.
   *
   * @param key name of the property
   * @param value value of the property
   * @return the RunnerHealthMetrics instance itself
   */
  public RunnerHealthMetrics putAdditionalProperty(String key, Object value) {
    if (this.additionalProperties == null) {
        this.additionalProperties = new HashMap<String, Object>();
    }
    this.additionalProperties.put(key, value);
    return this;
  }

  /**
   * Return the additional (undeclared) property.
   *
   * @return a map of objects
   */
  public Map<String, Object> getAdditionalProperties() {
    return additionalProperties;
  }

  /**
   * Return the additional (undeclared) property with the specified name.
   *
   * @param key name of the property
   * @return an object
   */
  public Object getAdditionalProperty(String key) {
    if (this.additionalProperties == null) {
        return null;
    }
    return this.additionalProperties.get(key);
  }


  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    RunnerHealthMetrics runnerHealthMetrics = (RunnerHealthMetrics) o;
    return Objects.equals(this.currentCpuLoadAverage, runnerHealthMetrics.currentCpuLoadAverage) &&
        Objects.equals(this.currentCpuUsagePercentage, runnerHealthMetrics.currentCpuUsagePercentage) &&
        Objects.equals(this.currentMemoryUsagePercentage, runnerHealthMetrics.currentMemoryUsagePercentage) &&
        Objects.equals(this.currentDiskUsagePercentage, runnerHealthMetrics.currentDiskUsagePercentage) &&
        Objects.equals(this.currentAllocatedCpu, runnerHealthMetrics.currentAllocatedCpu) &&
        Objects.equals(this.currentAllocatedMemoryGiB, runnerHealthMetrics.currentAllocatedMemoryGiB) &&
        Objects.equals(this.currentAllocatedDiskGiB, runnerHealthMetrics.currentAllocatedDiskGiB) &&
        Objects.equals(this.currentSnapshotCount, runnerHealthMetrics.currentSnapshotCount) &&
        Objects.equals(this.currentStartedSandboxes, runnerHealthMetrics.currentStartedSandboxes) &&
        Objects.equals(this.cpu, runnerHealthMetrics.cpu) &&
        Objects.equals(this.memoryGiB, runnerHealthMetrics.memoryGiB) &&
        Objects.equals(this.diskGiB, runnerHealthMetrics.diskGiB)&&
        Objects.equals(this.additionalProperties, runnerHealthMetrics.additionalProperties);
  }

  @Override
  public int hashCode() {
    return Objects.hash(currentCpuLoadAverage, currentCpuUsagePercentage, currentMemoryUsagePercentage, currentDiskUsagePercentage, currentAllocatedCpu, currentAllocatedMemoryGiB, currentAllocatedDiskGiB, currentSnapshotCount, currentStartedSandboxes, cpu, memoryGiB, diskGiB, additionalProperties);
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("class RunnerHealthMetrics {\n");
    sb.append("    currentCpuLoadAverage: ").append(toIndentedString(currentCpuLoadAverage)).append("\n");
    sb.append("    currentCpuUsagePercentage: ").append(toIndentedString(currentCpuUsagePercentage)).append("\n");
    sb.append("    currentMemoryUsagePercentage: ").append(toIndentedString(currentMemoryUsagePercentage)).append("\n");
    sb.append("    currentDiskUsagePercentage: ").append(toIndentedString(currentDiskUsagePercentage)).append("\n");
    sb.append("    currentAllocatedCpu: ").append(toIndentedString(currentAllocatedCpu)).append("\n");
    sb.append("    currentAllocatedMemoryGiB: ").append(toIndentedString(currentAllocatedMemoryGiB)).append("\n");
    sb.append("    currentAllocatedDiskGiB: ").append(toIndentedString(currentAllocatedDiskGiB)).append("\n");
    sb.append("    currentSnapshotCount: ").append(toIndentedString(currentSnapshotCount)).append("\n");
    sb.append("    currentStartedSandboxes: ").append(toIndentedString(currentStartedSandboxes)).append("\n");
    sb.append("    cpu: ").append(toIndentedString(cpu)).append("\n");
    sb.append("    memoryGiB: ").append(toIndentedString(memoryGiB)).append("\n");
    sb.append("    diskGiB: ").append(toIndentedString(diskGiB)).append("\n");
    sb.append("    additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
    sb.append("}");
    return sb.toString();
  }

  /**
   * Convert the given object to string with each line indented by 4 spaces
   * (except the first line).
   */
  private String toIndentedString(Object o) {
    return o == null ? "null" : o.toString().replace("\n", "\n    ");
  }


  public static HashSet<String> openapiFields;
  public static HashSet<String> openapiRequiredFields;

  static {
    // a set of all properties/fields (JSON key names)
    openapiFields = new HashSet<String>(Arrays.asList("currentCpuLoadAverage", "currentCpuUsagePercentage", "currentMemoryUsagePercentage", "currentDiskUsagePercentage", "currentAllocatedCpu", "currentAllocatedMemoryGiB", "currentAllocatedDiskGiB", "currentSnapshotCount", "currentStartedSandboxes", "cpu", "memoryGiB", "diskGiB"));

    // a set of required properties/fields (JSON key names)
    openapiRequiredFields = new HashSet<String>(Arrays.asList("currentCpuLoadAverage", "currentCpuUsagePercentage", "currentMemoryUsagePercentage", "currentDiskUsagePercentage", "currentAllocatedCpu", "currentAllocatedMemoryGiB", "currentAllocatedDiskGiB", "currentSnapshotCount", "currentStartedSandboxes", "cpu", "memoryGiB", "diskGiB"));
  }

  /**
   * Validates the JSON Element and throws an exception if issues found
   *
   * @param jsonElement JSON Element
   * @throws IOException if the JSON Element is invalid with respect to RunnerHealthMetrics
   */
  public static void validateJsonElement(JsonElement jsonElement) throws IOException {
      if (jsonElement == null) {
        if (!RunnerHealthMetrics.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
          throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field(s) %s in RunnerHealthMetrics is not found in the empty JSON string", RunnerHealthMetrics.openapiRequiredFields.toString()));
        }
      }

      // check to make sure all required properties/fields are present in the JSON string
      for (String requiredField : RunnerHealthMetrics.openapiRequiredFields) {
        if (jsonElement.getAsJsonObject().get(requiredField) == null) {
          throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString()));
        }
      }
        JsonObject jsonObj = jsonElement.getAsJsonObject();
  }

  public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
    @SuppressWarnings("unchecked")
    @Override
    public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
       if (!RunnerHealthMetrics.class.isAssignableFrom(type.getRawType())) {
         return null; // this class only serializes 'RunnerHealthMetrics' and its subtypes
       }
       final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
       final TypeAdapter<RunnerHealthMetrics> thisAdapter
                        = gson.getDelegateAdapter(this, TypeToken.get(RunnerHealthMetrics.class));

       return (TypeAdapter<T>) new TypeAdapter<RunnerHealthMetrics>() {
           @Override
           public void write(JsonWriter out, RunnerHealthMetrics value) throws IOException {
             JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
             obj.remove("additionalProperties");
             // serialize additional properties
             if (value.getAdditionalProperties() != null) {
               for (Map.Entry<String, Object> entry : value.getAdditionalProperties().entrySet()) {
                 if (entry.getValue() instanceof String)
                   obj.addProperty(entry.getKey(), (String) entry.getValue());
                 else if (entry.getValue() instanceof Number)
                   obj.addProperty(entry.getKey(), (Number) entry.getValue());
                 else if (entry.getValue() instanceof Boolean)
                   obj.addProperty(entry.getKey(), (Boolean) entry.getValue());
                 else if (entry.getValue() instanceof Character)
                   obj.addProperty(entry.getKey(), (Character) entry.getValue());
                 else {
                   JsonElement jsonElement = gson.toJsonTree(entry.getValue());
                   if (jsonElement.isJsonArray()) {
                     obj.add(entry.getKey(), jsonElement.getAsJsonArray());
                   } else {
                     obj.add(entry.getKey(), jsonElement.getAsJsonObject());
                   }
                 }
               }
             }
             elementAdapter.write(out, obj);
           }

           @Override
           public RunnerHealthMetrics read(JsonReader in) throws IOException {
             JsonElement jsonElement = elementAdapter.read(in);
             validateJsonElement(jsonElement);
             JsonObject jsonObj = jsonElement.getAsJsonObject();
             // store additional fields in the deserialized instance
             RunnerHealthMetrics instance = thisAdapter.fromJsonTree(jsonObj);
             for (Map.Entry<String, JsonElement> entry : jsonObj.entrySet()) {
               if (!openapiFields.contains(entry.getKey())) {
                 if (entry.getValue().isJsonPrimitive()) { // primitive type
                   if (entry.getValue().getAsJsonPrimitive().isString())
                     instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString());
                   else if (entry.getValue().getAsJsonPrimitive().isNumber())
                     instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber());
                   else if (entry.getValue().getAsJsonPrimitive().isBoolean())
                     instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean());
                   else
                     throw new IllegalArgumentException(String.format(java.util.Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString()));
                 } else if (entry.getValue().isJsonArray()) {
                     instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class));
                 } else { // JSON object
                     instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class));
                 }
               }
             }
             return instance;
           }

       }.nullSafe();
    }
  }

  /**
   * Create an instance of RunnerHealthMetrics given an JSON string
   *
   * @param jsonString JSON string
   * @return An instance of RunnerHealthMetrics
   * @throws IOException if the JSON string is invalid with respect to RunnerHealthMetrics
   */
  public static RunnerHealthMetrics fromJson(String jsonString) throws IOException {
    return JSON.getGson().fromJson(jsonString, RunnerHealthMetrics.class);
  }

  /**
   * Convert an instance of RunnerHealthMetrics to an JSON string
   *
   * @return JSON string
   */
  public String toJson() {
    return JSON.getGson().toJson(this);
  }
}

