{
  "$id": "https://schemas.fermihdi.io/hd/license_schema.json",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "FermiHDI HD License Schema",
  "description": "Schema for a FermiHDI HD License File",
  "type": "object",
  "properties": {
    "version": {
      "description": "The version of the license schema",
      "type": "integer"
    },
    "client": {
      "description": "A Client object",
      "type": "object",
      "properties": {
        "id": {
          "description": "A UID unique identifier for the dataset",
          "type": "string"
        },
        "name": {
          "description": "The name of the client",
          "type": "string"
        }
      },
      "required": ["id", "name"]
    },
    "licenses": {
      "description": "A FermiHDI license object",
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "versionNumber": {
            "description": "The version number of this license",
            "type": "integer"
          },
          "serialNumber": {
            "description": "The ID for this license",
            "type": "string"
          },
          "licenseType": {
            "description": "What this license is for",
            "type": "string",
            "enum": ["HD"]
          },
          "term": {
            "description": "When is the length of this license in seconds",
            "type": "integer"
          },
          "issue_date": {
            "description": "When was this license issued as a Unix Epoch timestamp (seconds)",
            "type": "integer"
          },
          "validity_date": {
            "description": "When will this license become valid as a Unix Epoch timestamp (seconds)",
            "type": "integer"
          },
          "expire_date": {
            "description": "When will this license expire as a Unix Epoch timestamp (seconds)",
            "type": "integer"
          },
          "elements": {
            "description": "The elements this license authorizes",
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "elementType": {
                  "description": "A licensed element",
                  "type": "string",
                  "enum": [
                    "HD_ANY",
                    "HD_INGEST",
                    "HD_SSC",
                    "HD_SN",
                    "HD_DP",
                    "HD_QP",
                    "HD_DMS",
                    "HD_PROXY",
                    "HD_CLIENT"
                  ]
                },
                "count": {
                  "description": "The number of units this license allows for this element",
                  "type": "integer"
                }
              }
            }
          },
          "dms": {
            "description": "Information about the client's DMS for which this license was issued",
            "type": "object",
            "properties": {
              "id": {
                "description": "The of ID such as hostname or IP address of the client's DMS for which this license was issued",
                "type": "string"
              },
              "certificate": {
                "description": "The x.509 Certificate issued to this client's DMS",
                "type": "string"
              }
            },
            "required": ["id", "certificate"]
          },
          "licenseVerification": {
            "description": "License verification",
            "type": "object",
            "properties": {
              "hashAlgorithm": {
                "description": "The hash Algorithm used, default to SHA256",
                "type": "string"
              },
              "signingCertificate": {
                "description": "The FermiHDI Licensing ICA's x.509 Certificate used to sign this license; it must have the FermiHDI Root CA as its issuer",
                "type": "string"
              },
              "signature": {
                "description": "The Base64 encoded and encrypted hash of this license without the 'licenses.dms' and 'licenses.licenseVerification' elements, stringified, and using the key referenced in this element",
                "type": "string"
              }
            },
            "required": ["hashAlgorithm", "fingerprint", "signature"]
          }
        },
        "required": [
          "versionNumber",
          "serialNumber",
          "licenseType",
          "term",
          "issue_date",
          "validity_date",
          "expire_date",
          "elements"
        ]
      }
    }
  }
}