{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://www.anguskit.com/schema/angusmeter/plugins/angus-s3.json",
  "type": "object",
  "properties": {
    "region": {
      "type": "string",
      "default": "us-east-1",
      "description": "AWS region (e.g. us-east-1, eu-west-1)"
    },
    "endpoint": {
      "type": "string",
      "description": "Custom endpoint URL for MinIO/LocalStack (e.g. http://localhost:9000)"
    },
    "accessKeyId": {
      "type": "string",
      "description": "AWS access key ID"
    },
    "secretAccessKey": {
      "type": "string",
      "writeOnly": true,
      "description": "AWS secret access key"
    },
    "action": {
      "type": "string",
      "enum": [
        "PUT_OBJECT",
        "GET_OBJECT",
        "DELETE_OBJECT",
        "HEAD_OBJECT",
        "LIST_OBJECTS",
        "COPY_OBJECT",
        "CREATE_BUCKET",
        "DELETE_BUCKET",
        "LIST_BUCKETS",
        "PRESIGN_URL"
      ],
      "default": "GET_OBJECT",
      "description": "S3 operation to perform"
    },
    "bucket": {
      "type": "string",
      "description": "S3 bucket name"
    },
    "key": {
      "type": "string",
      "description": "Object key/path (supports ${var} interpolation)"
    },
    "body": {
      "type": "string",
      "description": "Object body for PUT (supports ${var} interpolation)"
    },
    "contentType": {
      "type": "string",
      "description": "Content-Type for PUT (e.g. application/json, text/plain)"
    },
    "sourceBucket": {
      "type": "string",
      "description": "Source bucket for COPY_OBJECT"
    },
    "sourceKey": {
      "type": "string",
      "description": "Source key for COPY_OBJECT"
    },
    "prefix": {
      "type": "string",
      "description": "Key prefix filter for LIST_OBJECTS"
    },
    "maxKeys": {
      "type": "integer",
      "default": 1000,
      "minimum": 1,
      "maximum": 10000,
      "description": "Max keys to return for LIST_OBJECTS"
    },
    "delimiter": {
      "type": "string",
      "description": "Delimiter for LIST_OBJECTS (e.g. /)"
    },
    "presignExpireSeconds": {
      "type": "integer",
      "default": 3600,
      "minimum": 1,
      "maximum": 604800,
      "description": "Presigned URL expiration in seconds"
    },
    "forcePathStyle": {
      "type": "boolean",
      "default": false,
      "description": "Force path-style access (for MinIO/LocalStack)"
    },
    "credentials": {
      "type": "object",
      "description": "Extended credentials configuration",
      "properties": {
        "sessionToken": {
          "type": "string",
          "writeOnly": true,
          "description": "AWS session token for temporary credentials"
        },
        "profile": {
          "type": "string",
          "description": "AWS profile name"
        }
      }
    },
    "assertions": {
      "type": "array",
      "description": "Optional step-level assertions against the S3 operation result (see S3ConfigValidator). BODY is an alias for RESPONSE_BODY.",
      "items": {
        "$ref": "#/definitions/s3Assertion"
      }
    },
    "extractors": {
      "type": "array",
      "description": "Optional extractors from the S3 response (see S3ConfigValidator).",
      "items": {
        "$ref": "#/definitions/s3Extractor"
      }
    }
  },
  "required": [
    "action"
  ],
  "definitions": {
    "s3Assertion": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        },
        "type": {
          "type": "string",
          "enum": [
            "STATUS_CODE",
            "RESPONSE_TIME",
            "BODY_CONTAINS",
            "BODY_EQUALS",
            "BODY_JSON_PATH",
            "BODY_REGEX",
            "BODY_XPATH",
            "BODY_SIZE",
            "HEADER_EXISTS",
            "HEADER_VALUE",
            "NOT_NULL",
            "CUSTOM",
            "RESPONSE_BODY",
            "BODY"
          ]
        },
        "operator": {
          "type": "string",
          "enum": [
            "EQUALS",
            "NOT_EQUALS",
            "CONTAINS",
            "NOT_CONTAINS",
            "GREATER_THAN",
            "LESS_THAN",
            "GREATER_OR_EQUAL",
            "LESS_OR_EQUAL",
            "MATCHES_REGEX"
          ]
        },
        "expected": {
          "description": "Expected value for the assertion"
        },
        "expression": {
          "type": "string"
        },
        "enabled": {
          "type": "boolean"
        }
      },
      "required": [
        "type"
      ]
    },
    "s3Extractor": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "JSON_PATH",
            "REGEX",
            "RESPONSE_CODE",
            "RESPONSE_TIME"
          ]
        },
        "expression": {
          "type": "string"
        },
        "variable": {
          "type": "string"
        },
        "defaultValue": {
          "type": "string"
        }
      },
      "required": [
        "type",
        "variable"
      ],
      "allOf": [
        {
          "if": {
            "properties": {
              "type": {
                "enum": [
                  "JSON_PATH",
                  "REGEX"
                ]
              }
            }
          },
          "then": {
            "required": [
              "expression"
            ]
          }
        }
      ]
    }
  }
}
