{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "contract": {
      "type": "string",
      "const": "managed-classification-v1"
    },
    "binding": {
      "type": "object",
      "properties": {
        "workspaceId": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "projectId": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        }
      },
      "required": [
        "workspaceId",
        "projectId"
      ],
      "additionalProperties": false
    },
    "available": {
      "type": "boolean"
    },
    "reason": {
      "anyOf": [
        {
          "type": "string",
          "description": "Recorded explanation; null when no explanation applies."
        },
        {
          "type": "null"
        }
      ],
      "description": "Recorded explanation; null when no explanation applies."
    },
    "enabled": {
      "type": "boolean"
    },
    "preference": {
      "type": "string",
      "enum": [
        "on",
        "off"
      ]
    },
    "revision": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991,
      "description": "Optimistic concurrency revision; supply it as expectedRevision on the next write."
    },
    "enrolled": {
      "type": "boolean"
    },
    "allowance": {
      "type": "object",
      "properties": {
        "contract": {
          "type": "string",
          "const": "classification-allowance-v1"
        },
        "unit": {
          "type": "string",
          "const": "classification-assessment-v1"
        },
        "scope": {
          "type": "object",
          "properties": {
            "kind": {
              "type": "string",
              "const": "workspace"
            },
            "workspaceId": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            },
            "sharedAcrossWebsites": {
              "type": "boolean",
              "const": true
            }
          },
          "required": [
            "kind",
            "workspaceId",
            "sharedAcrossWebsites"
          ],
          "additionalProperties": false
        },
        "state": {
          "type": "string",
          "enum": [
            "unavailable",
            "not_entitled",
            "exhausted",
            "available"
          ],
          "description": "Saved lifecycle or evidence state, as enumerated for this record."
        },
        "limit": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            {
              "type": "null"
            }
          ]
        },
        "reserved": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            {
              "type": "null"
            }
          ]
        },
        "used": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            {
              "type": "null"
            }
          ]
        },
        "remaining": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991,
              "description": "Check units still available after consumed and reserved units; null if the limit is unknown."
            },
            {
              "type": "null"
            }
          ],
          "description": "Check units still available after consumed and reserved units; null if the limit is unknown."
        },
        "period": {
          "anyOf": [
            {
              "type": "object",
              "properties": {
                "key": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 200,
                  "description": "Saved lookup identifier within this record."
                },
                "startsAt": {
                  "type": "string",
                  "format": "date-time",
                  "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
                },
                "endsAt": {
                  "type": "string",
                  "format": "date-time",
                  "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
                }
              },
              "required": [
                "key",
                "startsAt",
                "endsAt"
              ],
              "additionalProperties": false
            },
            {
              "type": "null"
            }
          ]
        },
        "resetAt": {
          "anyOf": [
            {
              "type": "string",
              "format": "date-time",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "contract",
        "unit",
        "scope",
        "state",
        "limit",
        "reserved",
        "used",
        "remaining",
        "period",
        "resetAt"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "contract",
    "binding",
    "available",
    "reason",
    "enabled",
    "preference",
    "revision",
    "enrolled",
    "allowance"
  ],
  "additionalProperties": false
}
