{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://www.anguskit.com/schema/angusmeter/plugins/angus-elasticsearch.json",
  "title": "Elasticsearch Sampler Configuration",
  "description": "Configuration schema for the Elasticsearch sampler plugin.",
  "type": "object",
  "properties": {
    "nodes": {
      "type": "string",
      "description": "Comma-separated list of Elasticsearch node URLs.",
      "default": "http://localhost:9200",
      "examples": [
        "http://node1:9200,http://node2:9200"
      ]
    },
    "action": {
      "type": "string",
      "description": "The Elasticsearch operation to perform.",
      "enum": [
        "INDEX",
        "GET",
        "SEARCH",
        "DELETE",
        "UPDATE",
        "BULK",
        "CREATE_INDEX",
        "DELETE_INDEX",
        "EXISTS",
        "COUNT",
        "SCROLL",
        "CLEAR_SCROLL",
        "CLUSTER_HEALTH",
        "DELETE_BY_QUERY",
        "UPDATE_BY_QUERY",
        "MGET",
        "REFRESH"
      ],
      "default": "SEARCH"
    },
    "index": {
      "type": "string",
      "description": "Target index name."
    },
    "id": {
      "type": "string",
      "description": "Document ID (required for GET, DELETE, UPDATE)."
    },
    "body": {
      "type": "string",
      "description": "Request body as JSON string."
    },
    "query": {
      "type": "string",
      "description": "Optional query string parameter."
    },
    "from": {
      "type": "integer",
      "description": "Pagination start offset for SEARCH.",
      "default": 0,
      "minimum": 0
    },
    "size": {
      "type": "integer",
      "description": "Number of results to return for SEARCH.",
      "default": 10,
      "minimum": 0,
      "maximum": 10000
    },
    "scrollKeepAlive": {
      "type": "string",
      "description": "Scroll context keep-alive duration (e.g., '5m').",
      "examples": [
        "1m",
        "5m"
      ]
    },
    "scrollId": {
      "type": "string",
      "description": "Scroll ID for SCROLL / CLEAR_SCROLL actions."
    },
    "username": {
      "type": "string",
      "description": "Basic auth username."
    },
    "password": {
      "type": "string",
      "description": "Basic auth password.",
      "writeOnly": true
    },
    "useSsl": {
      "type": "boolean",
      "description": "(Deprecated — not used at runtime. TLS is determined by the node URL scheme and tls config object.) Whether to use HTTPS.",
      "default": false
    },
    "apiKey": {
      "type": "string",
      "description": "API key for authentication.",
      "writeOnly": true
    },
    "routing": {
      "type": "string",
      "description": "Custom routing value."
    },
    "pipeline": {
      "type": "string",
      "description": "Ingest pipeline name."
    },
    "timeout": {
      "type": "integer",
      "description": "Connection and socket timeout in milliseconds.",
      "default": 30000,
      "minimum": 100,
      "maximum": 300000
    },
    "auth": {
      "type": "object",
      "description": "Advanced authentication configuration.",
      "properties": {
        "bearerToken": {
          "type": "string",
          "description": "Bearer token for authentication."
        },
        "apiKeyId": {
          "type": "string",
          "description": "API key ID."
        },
        "apiKeySecret": {
          "type": "string",
          "description": "API key secret."
        }
      }
    },
    "tls": {
      "type": "object",
      "description": "TLS/SSL configuration. Mapped through TlsConfig; supports JKS/PKCS12 keystore+truststore and PEM cert/key/ca for mTLS.",
      "properties": {
        "trustAll": {
          "type": "boolean",
          "description": "If true, all server certificates are trusted (insecure, testing only).",
          "default": false
        },
        "verifyHostname": {
          "type": "boolean",
          "description": "Whether to verify the server hostname.",
          "default": true
        },
        "truststorePath": {
          "type": "string",
          "description": "Path to the truststore file (JKS/PKCS12)."
        },
        "truststorePassword": {
          "type": "string",
          "description": "Truststore password."
        },
        "keystorePath": {
          "type": "string",
          "description": "Path to the keystore file (JKS/PKCS12) for mTLS."
        },
        "keystorePassword": {
          "type": "string",
          "description": "Keystore password."
        },
        "certPath": {
          "type": "string",
          "description": "Path to client certificate (PEM) for mTLS."
        },
        "keyPath": {
          "type": "string",
          "description": "Path to client private key (PEM, PKCS#8) for mTLS."
        },
        "keyPassword": {
          "type": "string",
          "description": "Password for the PEM private key, if encrypted."
        },
        "caPath": {
          "type": "string",
          "description": "Path to CA bundle (PEM) used as trust anchors."
        },
        "protocols": {
          "type": "array",
          "description": "Enabled TLS protocols, e.g. TLSv1.2, TLSv1.3.",
          "items": {
            "type": "string"
          }
        },
        "ciphers": {
          "type": "array",
          "description": "Enabled cipher suites.",
          "items": {
            "type": "string"
          }
        }
      }
    }
  },
  "required": [
    "nodes"
  ],
  "definitions": {
    "assertion": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "description": "Human-readable label for the assertion."
        },
        "type": {
          "type": "string",
          "description": "Assertion strategy.",
          "enum": [
            "STATUS_CODE",
            "RESPONSE_TIME",
            "BODY_CONTAINS",
            "BODY_EQUALS",
            "BODY_JSON_PATH",
            "BODY_REGEX",
            "HEADER_EXISTS",
            "HEADER_VALUE",
            "NOT_NULL"
          ]
        },
        "operator": {
          "type": "string",
          "description": "Comparison operator.",
          "enum": [
            "EQUALS",
            "NOT_EQUALS",
            "CONTAINS",
            "NOT_CONTAINS",
            "GREATER_THAN",
            "LESS_THAN",
            "GREATER_OR_EQUAL",
            "LESS_OR_EQUAL",
            "MATCHES_REGEX"
          ]
        },
        "expected": {
          "type": "string"
        },
        "expression": {
          "type": "string"
        }
      },
      "required": [
        "type",
        "operator",
        "expected"
      ]
    },
    "extractor": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "description": "Extraction strategy.",
          "enum": [
            "JSON_PATH",
            "REGEX",
            "RESPONSE_CODE",
            "RESPONSE_TIME"
          ]
        },
        "expression": {
          "type": "string"
        },
        "variable": {
          "type": "string"
        },
        "defaultValue": {
          "type": "string"
        }
      },
      "required": [
        "type",
        "variable"
      ]
    }
  }
}
