{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "ResourcesSpec",
  "type": "object",
  "properties": {
    "basins": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/BasinSpec"
      }
    }
  },
  "$defs": {
    "BasinSpec": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        },
        "config": {
          "anyOf": [
            {
              "$ref": "#/$defs/BasinConfigSpec"
            },
            {
              "type": "null"
            }
          ]
        },
        "streams": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/StreamSpec"
          }
        }
      },
      "additionalProperties": false,
      "required": [
        "name"
      ]
    },
    "BasinConfigSpec": {
      "type": "object",
      "properties": {
        "default_stream_config": {
          "anyOf": [
            {
              "$ref": "#/$defs/StreamConfigSpec"
            },
            {
              "type": "null"
            }
          ]
        },
        "stream_cipher": {
          "description": "Encryption algorithm to apply to newly created streams in the basin.",
          "anyOf": [
            {
              "$ref": "#/$defs/EncryptionAlgorithmSpec"
            },
            {
              "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
    },
    "StreamConfigSpec": {
      "type": "object",
      "properties": {
        "storage_class": {
          "description": "Storage class for recent writes.",
          "anyOf": [
            {
              "$ref": "#/$defs/StorageClassSpec"
            },
            {
              "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/RetentionPolicySpec"
            },
            {
              "type": "null"
            }
          ]
        },
        "timestamping": {
          "description": "Timestamping behavior.",
          "anyOf": [
            {
              "$ref": "#/$defs/TimestampingSpec"
            },
            {
              "type": "null"
            }
          ]
        },
        "delete_on_empty": {
          "description": "Delete-on-empty configuration.",
          "anyOf": [
            {
              "$ref": "#/$defs/DeleteOnEmptySpec"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "additionalProperties": false
    },
    "StorageClassSpec": {
      "description": "Storage class for recent writes.",
      "type": "string",
      "enum": [
        "standard",
        "express"
      ]
    },
    "RetentionPolicySpec": {
      "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"
      ]
    },
    "TimestampingSpec": {
      "type": "object",
      "properties": {
        "mode": {
          "description": "Timestamping mode for appends that influences how timestamps are handled.",
          "anyOf": [
            {
              "$ref": "#/$defs/TimestampingModeSpec"
            },
            {
              "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
    },
    "TimestampingModeSpec": {
      "description": "Timestamping mode for appends that influences how timestamps are handled.",
      "type": "string",
      "enum": [
        "client-prefer",
        "client-require",
        "arrival"
      ]
    },
    "DeleteOnEmptySpec": {
      "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"
      ]
    },
    "EncryptionAlgorithmSpec": {
      "description": "Encryption algorithm to apply to newly created streams in the basin.",
      "type": "string",
      "enum": [
        "aegis-256",
        "aes-256-gcm"
      ]
    },
    "StreamSpec": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        },
        "config": {
          "anyOf": [
            {
              "$ref": "#/$defs/StreamConfigSpec"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "additionalProperties": false,
      "required": [
        "name"
      ]
    }
  }
}
