/*
 * 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.annotations.SerializedName;

import java.io.IOException;
import com.google.gson.TypeAdapter;
import com.google.gson.JsonElement;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;

/**
 * The state of the sandbox
 */
@JsonAdapter(SandboxState.Adapter.class)
public enum SandboxState {
  
  CREATING("creating"),
  
  RESTORING("restoring"),
  
  DESTROYED("destroyed"),
  
  DESTROYING("destroying"),
  
  STARTED("started"),
  
  STOPPED("stopped"),
  
  STARTING("starting"),
  
  STOPPING("stopping"),
  
  ERROR("error"),
  
  BUILD_FAILED("build_failed"),
  
  PENDING_BUILD("pending_build"),
  
  BUILDING_SNAPSHOT("building_snapshot"),
  
  UNKNOWN("unknown"),
  
  PULLING_SNAPSHOT("pulling_snapshot"),
  
  ARCHIVED("archived"),
  
  ARCHIVING("archiving"),
  
  RESIZING("resizing"),
  
  SNAPSHOTTING("snapshotting"),
  
  FORKING("forking"),
  
  UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api");

  private String value;

  SandboxState(String value) {
    this.value = value;
  }

  public String getValue() {
    return value;
  }

  @Override
  public String toString() {
    return String.valueOf(value);
  }

  public static SandboxState fromValue(String value) {
    for (SandboxState b : SandboxState.values()) {
      if (b.value.equals(value)) {
        return b;
      }
    }
    return UNKNOWN_DEFAULT_OPEN_API;
  }

  public static class Adapter extends TypeAdapter<SandboxState> {
    @Override
    public void write(final JsonWriter jsonWriter, final SandboxState enumeration) throws IOException {
      jsonWriter.value(enumeration.getValue());
    }

    @Override
    public SandboxState read(final JsonReader jsonReader) throws IOException {
      String value = jsonReader.nextString();
      return SandboxState.fromValue(value);
    }
  }

  public static void validateJsonElement(JsonElement jsonElement) throws IOException {
    String value = jsonElement.getAsString();
    SandboxState.fromValue(value);
  }
}

