{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://github.com/api-evangelist/spot/blob/main/json-schema/elastigroup.json",
  "title": "Spot Elastigroup",
  "description": "An Elastigroup is a compute group that manages and optimizes cloud instances across spot, reserved, and on-demand capacity to ensure availability at the lowest cost.",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "description": "The unique identifier of the Elastigroup."
    },
    "name": {
      "type": "string",
      "description": "The name of the Elastigroup."
    },
    "description": {
      "type": "string",
      "description": "A description of the Elastigroup."
    },
    "region": {
      "type": "string",
      "description": "The cloud provider region where the Elastigroup is deployed."
    },
    "capacity": {
      "type": "object",
      "description": "The capacity configuration for the Elastigroup.",
      "properties": {
        "target": {
          "type": "integer",
          "description": "The desired number of instances."
        },
        "minimum": {
          "type": "integer",
          "description": "The minimum number of instances."
        },
        "maximum": {
          "type": "integer",
          "description": "The maximum number of instances."
        },
        "unit": {
          "type": "string",
          "enum": ["instance", "weight"],
          "description": "The unit of capacity measurement."
        }
      }
    },
    "strategy": {
      "type": "object",
      "description": "The optimization strategy for the Elastigroup.",
      "properties": {
        "risk": {
          "type": "integer",
          "description": "Percentage of spot instances (0-100)."
        },
        "onDemandCount": {
          "type": "integer",
          "description": "Number of on-demand instances to maintain."
        },
        "availabilityVsCost": {
          "type": "string",
          "enum": ["balanced", "costOriented", "availabilityOriented", "cheapest"],
          "description": "The optimization preference between availability and cost."
        },
        "fallbackToOd": {
          "type": "boolean",
          "description": "Whether to fall back to on-demand instances when spot is unavailable."
        },
        "utilizeReservedInstances": {
          "type": "boolean",
          "description": "Whether to utilize reserved instances when available."
        }
      }
    },
    "compute": {
      "type": "object",
      "description": "The compute configuration for the Elastigroup.",
      "properties": {
        "instanceTypes": {
          "type": "object",
          "properties": {
            "ondemand": {
              "type": "string",
              "description": "The on-demand instance type."
            },
            "spot": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "description": "The spot instance types to consider."
            }
          }
        },
        "availabilityZones": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "subnetId": {
                "type": "string"
              }
            }
          },
          "description": "The availability zones for the Elastigroup."
        }
      }
    },
    "createdAt": {
      "type": "string",
      "format": "date-time",
      "description": "The timestamp when the Elastigroup was created."
    },
    "updatedAt": {
      "type": "string",
      "format": "date-time",
      "description": "The timestamp when the Elastigroup was last updated."
    }
  }
}
