{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "anyOf": [
    {
      "type": "object",
      "properties": {
        "$schema": {
          "type": "string",
          "const": "https://eudiplo.dev/schemas/v1/TenantConfigFile.schema.json"
        },
        "metadata": {
          "type": "object",
          "properties": {
            "generation": {
              "type": "integer",
              "minimum": 1,
              "maximum": 9007199254740991
            },
            "ownership": {
              "type": "string",
              "enum": [
                "unmanaged",
                "file-managed"
              ]
            }
          },
          "additionalProperties": false
        },
        "spec": {
          "type": "object",
          "properties": {
            "name": {
              "default": "EUDIPLO",
              "description": "Display name of the tenant.",
              "type": "string",
              "minLength": 1
            },
            "description": {
              "description": "Optional tenant description.",
              "type": "string",
              "minLength": 1
            },
            "sessionConfig": {
              "description": "Optional tenant-specific session storage configuration.",
              "type": "object",
              "properties": {
                "ttlSeconds": {
                  "description": "Session time-to-live in seconds.",
                  "type": "integer",
                  "minimum": 60,
                  "maximum": 9007199254740991
                },
                "cleanupMode": {
                  "description": "Whether to fully delete or anonymize expired sessions.",
                  "type": "string",
                  "enum": [
                    "full",
                    "anonymize"
                  ]
                }
              },
              "additionalProperties": false
            },
            "statusListConfig": {
              "description": "Optional tenant-specific status list defaults.",
              "type": "object",
              "properties": {
                "capacity": {
                  "description": "Default status list capacity.",
                  "type": "integer",
                  "minimum": 100,
                  "maximum": 9007199254740991
                },
                "bits": {
                  "description": "Bits-per-status setting (1, 2, 4, or 8).",
                  "anyOf": [
                    {
                      "type": "number",
                      "const": 1
                    },
                    {
                      "type": "number",
                      "const": 2
                    },
                    {
                      "type": "number",
                      "const": 4
                    },
                    {
                      "type": "number",
                      "const": 8
                    }
                  ]
                },
                "ttl": {
                  "description": "JWT TTL for status list tokens in seconds.",
                  "type": "integer",
                  "minimum": 60,
                  "maximum": 9007199254740991
                },
                "immediateUpdate": {
                  "description": "Regenerate status list JWTs immediately after status updates.",
                  "type": "boolean"
                },
                "enableAggregation": {
                  "description": "Include aggregation_uri in generated status list JWTs.",
                  "type": "boolean"
                }
              },
              "additionalProperties": false
            }
          },
          "required": [
            "name"
          ],
          "additionalProperties": false,
          "description": "Payload used when importing tenant metadata from config files."
        }
      },
      "required": [
        "$schema",
        "metadata",
        "spec"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "name": {
          "default": "EUDIPLO",
          "description": "Display name of the tenant.",
          "type": "string",
          "minLength": 1
        },
        "description": {
          "description": "Optional tenant description.",
          "type": "string",
          "minLength": 1
        },
        "sessionConfig": {
          "description": "Optional tenant-specific session storage configuration.",
          "type": "object",
          "properties": {
            "ttlSeconds": {
              "description": "Session time-to-live in seconds.",
              "type": "integer",
              "minimum": 60,
              "maximum": 9007199254740991
            },
            "cleanupMode": {
              "description": "Whether to fully delete or anonymize expired sessions.",
              "type": "string",
              "enum": [
                "full",
                "anonymize"
              ]
            }
          },
          "additionalProperties": false
        },
        "statusListConfig": {
          "description": "Optional tenant-specific status list defaults.",
          "type": "object",
          "properties": {
            "capacity": {
              "description": "Default status list capacity.",
              "type": "integer",
              "minimum": 100,
              "maximum": 9007199254740991
            },
            "bits": {
              "description": "Bits-per-status setting (1, 2, 4, or 8).",
              "anyOf": [
                {
                  "type": "number",
                  "const": 1
                },
                {
                  "type": "number",
                  "const": 2
                },
                {
                  "type": "number",
                  "const": 4
                },
                {
                  "type": "number",
                  "const": 8
                }
              ]
            },
            "ttl": {
              "description": "JWT TTL for status list tokens in seconds.",
              "type": "integer",
              "minimum": 60,
              "maximum": 9007199254740991
            },
            "immediateUpdate": {
              "description": "Regenerate status list JWTs immediately after status updates.",
              "type": "boolean"
            },
            "enableAggregation": {
              "description": "Include aggregation_uri in generated status list JWTs.",
              "type": "boolean"
            }
          },
          "additionalProperties": false
        }
      },
      "required": [
        "name"
      ],
      "additionalProperties": false,
      "description": "Payload used when importing tenant metadata from config files."
    }
  ],
  "$id": "./TenantConfigFile.schema.json",
  "title": "TenantConfigFile",
  "description": "Configuration file identified by its $schema URL.",
  "oneOf": [
    {
      "type": "object",
      "properties": {
        "$schema": {
          "type": "string",
          "const": "https://eudiplo.dev/schemas/v1/TenantConfigFile.schema.json"
        },
        "metadata": {
          "type": "object",
          "properties": {
            "generation": {
              "type": "integer",
              "minimum": 1,
              "maximum": 9007199254740991
            },
            "ownership": {
              "type": "string",
              "enum": [
                "unmanaged",
                "file-managed"
              ]
            }
          },
          "additionalProperties": false
        },
        "spec": {
          "type": "object",
          "properties": {
            "name": {
              "default": "EUDIPLO",
              "description": "Display name of the tenant.",
              "type": "string",
              "minLength": 1
            },
            "description": {
              "description": "Optional tenant description.",
              "type": "string",
              "minLength": 1
            },
            "sessionConfig": {
              "description": "Optional tenant-specific session storage configuration.",
              "type": "object",
              "properties": {
                "ttlSeconds": {
                  "description": "Session time-to-live in seconds.",
                  "type": "integer",
                  "minimum": 60,
                  "maximum": 9007199254740991
                },
                "cleanupMode": {
                  "description": "Whether to fully delete or anonymize expired sessions.",
                  "type": "string",
                  "enum": [
                    "full",
                    "anonymize"
                  ]
                }
              },
              "additionalProperties": false
            },
            "statusListConfig": {
              "description": "Optional tenant-specific status list defaults.",
              "type": "object",
              "properties": {
                "capacity": {
                  "description": "Default status list capacity.",
                  "type": "integer",
                  "minimum": 100,
                  "maximum": 9007199254740991
                },
                "bits": {
                  "description": "Bits-per-status setting (1, 2, 4, or 8).",
                  "anyOf": [
                    {
                      "type": "number",
                      "const": 1
                    },
                    {
                      "type": "number",
                      "const": 2
                    },
                    {
                      "type": "number",
                      "const": 4
                    },
                    {
                      "type": "number",
                      "const": 8
                    }
                  ]
                },
                "ttl": {
                  "description": "JWT TTL for status list tokens in seconds.",
                  "type": "integer",
                  "minimum": 60,
                  "maximum": 9007199254740991
                },
                "immediateUpdate": {
                  "description": "Regenerate status list JWTs immediately after status updates.",
                  "type": "boolean"
                },
                "enableAggregation": {
                  "description": "Include aggregation_uri in generated status list JWTs.",
                  "type": "boolean"
                }
              },
              "additionalProperties": false
            }
          },
          "required": [
            "name"
          ],
          "additionalProperties": false,
          "description": "Payload used when importing tenant metadata from config files."
        }
      },
      "required": [
        "$schema",
        "metadata",
        "spec"
      ],
      "additionalProperties": false
    }
  ]
}
