{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/solo/main/json-schema/solo-gloo-upstream-schema.json",
  "title": "Upstream",
  "description": "A Gloo Gateway upstream representing a backend service destination. Supports Kubernetes services, static hosts, AWS Lambda, Azure Functions, Consul services, and AI provider endpoints.",
  "type": "object",
  "properties": {
    "apiVersion": {
      "type": "string",
      "description": "API version (gloo.solo.io/v1)"
    },
    "kind": {
      "type": "string",
      "const": "Upstream",
      "description": "Resource kind"
    },
    "metadata": {
      "type": "object",
      "description": "Kubernetes resource metadata",
      "properties": {
        "name": { "type": "string" },
        "namespace": { "type": "string" },
        "labels": { "type": "object" },
        "annotations": { "type": "object" }
      }
    },
    "spec": {
      "type": "object",
      "description": "Upstream specification",
      "properties": {
        "kube": {
          "type": "object",
          "description": "Kubernetes service upstream",
          "properties": {
            "ref": {
              "type": "object",
              "properties": {
                "name": { "type": "string" },
                "namespace": { "type": "string" }
              }
            },
            "servicePort": { "type": "integer" }
          }
        },
        "static": {
          "type": "object",
          "description": "Static host upstream",
          "properties": {
            "hosts": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "addr": { "type": "string" },
                  "port": { "type": "integer" }
                }
              }
            }
          }
        },
        "aws": {
          "type": "object",
          "description": "AWS Lambda upstream",
          "properties": {
            "region": { "type": "string" },
            "secretRef": {
              "type": "object",
              "properties": {
                "name": { "type": "string" },
                "namespace": { "type": "string" }
              }
            },
            "lambdaFunctions": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "logicalName": { "type": "string" },
                  "lambdaFunctionName": { "type": "string" },
                  "qualifier": { "type": "string" }
                }
              }
            }
          }
        },
        "ai": {
          "type": "object",
          "description": "AI provider upstream (OpenAI, Anthropic, Bedrock, etc.)",
          "properties": {
            "openai": { "type": "object" },
            "anthropic": { "type": "object" },
            "azureopenai": { "type": "object" },
            "gemini": { "type": "object" },
            "vertexai": { "type": "object" },
            "ollama": { "type": "object" }
          }
        },
        "sslConfig": {
          "type": "object",
          "description": "TLS/SSL configuration for the upstream"
        },
        "healthChecks": {
          "type": "array",
          "description": "Health check configurations",
          "items": { "type": "object" }
        }
      }
    },
    "status": {
      "type": "object",
      "description": "Upstream reconciliation status",
      "properties": {
        "statuses": {
          "type": "object",
          "additionalProperties": {
            "type": "object",
            "properties": {
              "state": {
                "type": "string",
                "enum": ["Pending", "Accepted", "Rejected", "Warning"]
              },
              "reason": { "type": "string" }
            }
          }
        }
      }
    }
  }
}
