{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "TR-181 Permissions Schema",
  "type": "object",
  "properties": {
    "tr181": {
      "type": "object",
      "required": ["name", "instance", "secure_role", "permission"],
      "properties": {
        "name": {
          "type": "string",
          "description": "Name of the TR-181 profile or configuration"
        },
        "instance": {
          "type": "integer",
          "description": "Instance identifier"
        },
        "secure_role": {
          "type": "boolean",
          "description": "Whether this role is secure"
        },
        "permission": {
          "type": "array",
          "description": "List of TR-181 permissions by object path",
          "items": {
            "type": "object",
            "required": ["object", "perm"],
            "properties": {
              "object": {
                "type": "string",
                "description": "TR-181 object path or parameter name"
              },
              "perm": {
                "type": "array",
                "description": "List of permissions for the given object",
                "items": {
                  "type": "string",
                  "enum": [
                    "PERMIT_NONE",
                    "PERMIT_ALL",
                    "PERMIT_GET",
                    "PERMIT_GET_INST",
                    "PERMIT_OBJ_INFO",
                    "PERMIT_CMD_INFO",
                    "PERMIT_SET",
                    "PERMIT_ADD",
                    "PERMIT_DEL",
                    "PERMIT_OPER",
                    "PERMIT_SUBS_VAL_CHANGE",
                    "PERMIT_SUBS_OBJ_ADD",
                    "PERMIT_SUBS_OBJ_DEL",
                    "PERMIT_SUBS_EVT_OPER_COMP"
                  ]
                },
                "uniqueItems": true
              }
            },
            "additionalProperties": false
          },
          "minItems": 1
        }
      },
      "additionalProperties": false
    }
  },
  "required": ["tr181"],
  "additionalProperties": false
}
