{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://api.spotinst.io/schemas/elastigroup",
  "title": "Spot Elastigroup",
  "description": "An Elastigroup is Spot by NetApp's intelligent auto-scaling group that uses Spot/Preemptible instances to reduce cloud costs while maintaining availability",
  "type": "object",
  "required": ["name", "region", "capacity", "compute"],
  "properties": {
    "id": {
      "type": "string",
      "description": "Unique Elastigroup identifier (assigned on creation)"
    },
    "name": {
      "type": "string",
      "description": "Descriptive name for the Elastigroup",
      "minLength": 1,
      "maxLength": 36
    },
    "description": {
      "type": "string",
      "description": "Optional description of the Elastigroup purpose"
    },
    "region": {
      "type": "string",
      "description": "Cloud provider region (e.g., us-east-1, eastus, us-central1)"
    },
    "capacity": {
      "type": "object",
      "description": "Capacity configuration for the Elastigroup",
      "required": ["minimum", "maximum", "target"],
      "properties": {
        "minimum": {
          "type": "integer",
          "description": "Minimum number of instances",
          "minimum": 0
        },
        "maximum": {
          "type": "integer",
          "description": "Maximum number of instances",
          "minimum": 1
        },
        "target": {
          "type": "integer",
          "description": "Desired number of instances",
          "minimum": 0
        },
        "unit": {
          "type": "string",
          "enum": ["instance", "weight"],
          "description": "Capacity unit type"
        }
      }
    },
    "strategy": {
      "type": "object",
      "description": "Spot instance strategy and fallback behavior",
      "properties": {
        "risk": {
          "type": "integer",
          "description": "Percentage of Spot instances (0-100)",
          "minimum": 0,
          "maximum": 100
        },
        "onDemandCount": {
          "type": "integer",
          "description": "Number of On-Demand instances to maintain",
          "minimum": 0
        },
        "availabilityVsCost": {
          "type": "string",
          "enum": ["balanced", "availabilityOriented", "costOriented"],
          "description": "Optimization strategy preference"
        },
        "fallbackToOnDemand": {
          "type": "boolean",
          "description": "Whether to fall back to On-Demand if no Spot capacity available"
        },
        "utilizeReservedInstances": {
          "type": "boolean",
          "description": "Whether to utilize Reserved Instances when available"
        }
      }
    },
    "compute": {
      "type": "object",
      "description": "Compute configuration including instance types and AMI",
      "required": ["instanceTypes"],
      "properties": {
        "instanceTypes": {
          "type": "object",
          "properties": {
            "ondemand": {
              "type": "string",
              "description": "On-Demand instance type for fallback"
            },
            "spot": {
              "type": "array",
              "description": "List of Spot instance types to use",
              "items": {
                "type": "string"
              },
              "minItems": 1
            }
          }
        },
        "launchSpecification": {
          "type": "object",
          "description": "Launch configuration for instances"
        }
      }
    },
    "createdAt": {
      "type": "string",
      "format": "date-time",
      "description": "Timestamp when the Elastigroup was created"
    },
    "updatedAt": {
      "type": "string",
      "format": "date-time",
      "description": "Timestamp when the Elastigroup was last updated"
    }
  }
}
