{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://asterisk.coop/taco/spec/extensions/instrument/v1.0.0/schema.json",
  "title": "Instrument",
  "description": "Instrument and band metadata for each file.",
  "type": "object",
  "required": [
    "taco:extensions",
    "taco:metadata",
    "instrument:files",
    "instrument:instruments",
    "instrument:catalogue"
  ],
  "properties": {
    "taco:extensions": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "contains": {
        "const": "https://asterisk.coop/taco/spec/extensions/instrument/v1.0.0/schema.json"
      }
    },
    "taco:metadata": {
      "type": "object",
      "additionalProperties": {
        "$ref": "#/$defs/level"
      }
    },
    "instrument:files": {
      "type": "object",
      "minProperties": 1,
      "propertyNames": {
        "minLength": 1,
        "pattern": "\\S"
      },
      "additionalProperties": {
        "type": "object",
        "required": [
          "instruments",
          "bands"
        ],
        "properties": {
          "instruments": {
            "type": "array",
            "minItems": 1,
            "uniqueItems": true,
            "items": {
              "type": "string",
              "minLength": 1,
              "pattern": "\\S"
            }
          },
          "bands": {
            "type": "array",
            "minItems": 1,
            "uniqueItems": true,
            "items": {
              "type": "string",
              "minLength": 1,
              "pattern": "\\S"
            }
          }
        },
        "additionalProperties": false
      }
    },
    "instrument:instruments": {
      "type": "object",
      "minProperties": 1,
      "propertyNames": {
        "minLength": 1,
        "pattern": "\\S"
      },
      "additionalProperties": {
        "type": "object",
        "required": [
          "name",
          "type",
          "bands"
        ],
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "pattern": "\\S"
          },
          "type": {
            "type": "string",
            "minLength": 1,
            "pattern": "\\S"
          },
          "bands": {
            "type": "object",
            "minProperties": 1,
            "propertyNames": {
              "minLength": 1,
              "pattern": "\\S"
            },
            "additionalProperties": {
              "type": "object",
              "required": [
                "center_wavelength",
                "bandwidth"
              ],
              "properties": {
                "center_wavelength": {
                  "type": "number",
                  "exclusiveMinimum": 0
                },
                "bandwidth": {
                  "type": "number",
                  "exclusiveMinimum": 0
                }
              }
            }
          }
        }
      }
    },
    "instrument:catalogue": {
      "type": "object",
      "required": [
        "name",
        "version",
        "link"
      ],
      "properties": {
        "name": {
          "type": "string"
        },
        "version": {
          "type": "string"
        },
        "link": {
          "type": "string"
        }
      },
      "additionalProperties": false
    }
  },
  "propertyNames": {
    "anyOf": [
      {
        "not": {
          "pattern": "^instrument:"
        }
      },
      {
        "enum": [
          "instrument:files",
          "instrument:instruments",
          "instrument:catalogue"
        ]
      }
    ]
  },
  "$defs": {
    "level": {
      "type": "object",
      "propertyNames": {
        "not": {
          "pattern": "^instrument:"
        }
      }
    }
  }
}
