{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Resources",
  "type": "object",
  "properties": {
    "basins": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/Basin"
      }
    }
  },
  "$defs": {
    "Basin": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        },
        "config": {
          "anyOf": [
            {
              "$ref": "#/$defs/BasinConfig"
            },
            {
              "type": "null"
            }
          ]
        },
        "streams": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Stream"
          }
        }
      },
      "additionalProperties": false,
      "required": [
        "name"
      ]
    },
    "BasinConfig": {
      "type": "object",
      "properties": {
        "default_stream_config": {
          "anyOf": [
            {
              "$ref": "#/$defs/StreamConfig"
            },
            {
              "type": "null"
            }
          ]
        },
        "stream_cipher": {
          "description": "Encryption algorithm to apply to newly created streams in the basin.",
          "anyOf": [
            {
              "$ref": "#/$defs/EncryptionAlgorithm"
            },
            {
              "type": "null"
            }
          ],
          "default": null
        },
        "create_stream_on_append": {
          "description": "Create stream on append if it doesn't exist, using the default stream configuration.",
          "type": [
            "boolean",
            "null"
          ],
          "default": null
        },
        "create_stream_on_read": {
          "description": "Create stream on read if it doesn't exist, using the default stream configuration.",
          "type": [
            "boolean",
            "null"
          ],
          "default": null
        }
      },
      "additionalProperties": false
    },
    "StreamConfig": {
      "type": "object",
      "properties": {
        "storage_class": {
          "description": "Storage class for recent writes.",
          "anyOf": [
            {
              "$ref": "#/$defs/StorageClass"
            },
            {
              "type": "null"
            }
          ],
          "default": null
        },
        "retention_policy": {
          "description": "Retention policy for the stream. If unspecified, the default is to retain records for 7\ndays.",
          "anyOf": [
            {
              "$ref": "#/$defs/RetentionPolicy"
            },
            {
              "type": "null"
            }
          ]
        },
        "timestamping": {
          "description": "Timestamping behavior.",
          "anyOf": [
            {
              "$ref": "#/$defs/Timestamping"
            },
            {
              "type": "null"
            }
          ]
        },
        "delete_on_empty": {
          "description": "Delete-on-empty configuration.",
          "anyOf": [
            {
              "$ref": "#/$defs/DeleteOnEmpty"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "additionalProperties": false
    },
    "StorageClass": {
      "description": "Storage class for recent writes.",
      "type": "string",
      "enum": [
        "standard",
        "express"
      ]
    },
    "RetentionPolicy": {
      "description": "Retain records unless explicitly trimmed (\"infinite\"), or automatically trim records older than the given duration (e.g. \"7days\", \"1week\").",
      "type": "string",
      "examples": [
        "infinite",
        "7days",
        "1week"
      ]
    },
    "Timestamping": {
      "type": "object",
      "properties": {
        "mode": {
          "description": "Timestamping mode for appends that influences how timestamps are handled.",
          "anyOf": [
            {
              "$ref": "#/$defs/TimestampingMode"
            },
            {
              "type": "null"
            }
          ],
          "default": null
        },
        "uncapped": {
          "description": "Allow client-specified timestamps to exceed the arrival time.\nIf this is `false` or not set, client timestamps will be capped at the arrival time.",
          "type": [
            "boolean",
            "null"
          ],
          "default": null
        }
      },
      "additionalProperties": false
    },
    "TimestampingMode": {
      "description": "Timestamping mode for appends that influences how timestamps are handled.",
      "type": "string",
      "enum": [
        "client-prefer",
        "client-require",
        "arrival"
      ]
    },
    "DeleteOnEmpty": {
      "type": "object",
      "properties": {
        "min_age": {
          "description": "Minimum age before an empty stream can be deleted.\nSet to 0 (default) to disable delete-on-empty (don't delete automatically).",
          "anyOf": [
            {
              "$ref": "#/$defs/HumanDuration"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "additionalProperties": false
    },
    "HumanDuration": {
      "description": "A duration string in humantime format, e.g. \"1day\", \"2h 30m\"",
      "type": "string",
      "examples": [
        "1day",
        "2h 30m"
      ]
    },
    "EncryptionAlgorithm": {
      "description": "Encryption algorithm to apply to newly created streams in the basin.",
      "type": "string",
      "enum": [
        "aegis-256",
        "aes-256-gcm"
      ]
    },
    "Stream": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        },
        "config": {
          "anyOf": [
            {
              "$ref": "#/$defs/StreamConfig"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "additionalProperties": false,
      "required": [
        "name"
      ]
    }
  }
}
