{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "description": "Parameters to instantiate a NEO cluster. See https://lab.nexedi.com/nexedi/neoppod/blob/master/neo.conf for more information.",
  "definitions": {
    "neo-cluster": {
      "additionalProperties": false,
      "properties": {
        "cluster": {
          "description": "Cluster unique identifier. Your last line of defense against mixing up NEO clusters and corrupting your data. Choose a unique value for each of your cluster. Space not allowed.",
          "type": "string"
        },
        "partitions": {
          "description": "Number of partitions. You cannot change this value once you created a cluster.",
          "default": 12,
          "type": "integer"
        },
        "replicas": {
          "description": "Number of replicates.",
          "default": 0,
          "type": "integer"
        },
        "upstream-cluster": {
          "description": "Identifier of the cluster to backup.",
          "type": "string"
        },
        "upstream-masters": {
          "description": "Master nodes in the cluster to backup.",
          "type": "string"
        },
        "monitor": {
          "description": "Parameters for monitoring.",
          "properties": {
            "backup": {
              "description": "List of cluster names that are expected to backup this cluster.",
              "type": "array",
              "items": {
                "type": "string"
              },
              "uniqueItems": true
            },
            "periodicity": {
              "description": "Periodicity in minutes at which the cluster health is checked.",
              "default": 10,
              "type": "number"
            }
          },
          "type": "object"
        },
        "sla-dict": {
          "description": "[NEO SR only] Where to request instances. Each key is a query string for criterions (e.g. \"computer_guid=foo\"), and each value is a list of partition references ('node-0', 'node-1', ...). The prefix 'node-' is mandatory and the number must start from 0. The total number of nodes here must be equal to the length of node-list.",
          "additionalProperties": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "uniqueItems": true
          },
          "type": "object"
        },
        "ssl": {
          "description": "Enable SSL. All nodes look for 3 files in ~/etc: ca.crt, neo.crt, neo.key. Waiting that SlapOS provides a way to manage certificates, the user must deploy them manually, or use the temporary _ca/_cert/_key parameters.",
          "default": true,
          "type": "boolean"
        },
        "_ca": {
          "type": "string"
        },
        "_cert": {
          "type": "string"
        },
        "_key": {
          "type": "string"
        },
        "node-count": {
          "description": "Number of nodes to deploy.",
          "default": 1,
          "type": "integer"
        },
        "node": {
          "description": "Default node parameters.",
          "default": {},
          "additionalProperties": false,
          "properties": {
            "admin": {
              "description": "Port of admin node. 0 to disable.",
              "default": 2050,
              "type": "integer"
            },
            "master": {
              "description": "Port of master node. 0 to disable.",
              "default": 2051,
              "type": "integer"
            },
            "storage-count": {
              "description": "Number of storage nodes to deploy. One master and one admin node is deployed with each storage.",
              "default": 1,
              "type": "integer"
            },
            "data-deduplication": {
              "description": "Set the --dedup option for storage nodes.",
              "default": false,
              "type": "boolean"
            },
            "disable-drop-partitions": {
              "description": "Set the --disable-drop-partitions option for storage nodes.",
              "default": false,
              "type": "boolean"
            },
            "storage-type": {
              "description": "Storage type. Defaults to MySQL if available, else SQLite.",
              "enum": [
                "MySQL",
                "SQLite"
              ],
              "type": "string"
            },
            "private-tmpfs": {
              "description": "Size of private tmpfs mount to store the database. See filesystems/tmpfs.txt in Linux documentation. Use only for testing.",
              "type": "string"
            },
            "mysql": {
              "description": "Dictionary containing parameters for MySQL.",
              "default": {},
              "properties": {
                "relaxed-writes": {
                  "description": "When enabled, sets innodb_flush_log_at_trx_commit = 0, innodb_flush_method = nosync, innodb_doublewrite = 0 and sync_frm = 0 - RTFM, those options are dangerous",
                  "default": false,
                  "type": "boolean"
                }
              },
              "additionalProperties": {
                "description": "To configure important parameters like innodb_buffer_pool_size, tokudb_cache_size, etc.",
                "type": "string"
              },
              "type": "object"
            },
            "engine": {
              "description": "Configures storage engine, currently only InnoDB, RocksDB and TokuDB are supported. Defaults to NEO's default.",
              "type": "string"
            }
          },
          "type": "object"
        },
        "node!": {
          "description": "Node parameters are overridden by the value of the first item whose partition reference matches against the pattern.",
          "items": {
            "items": [
              {
                "description": "Override pattern (Python regular expression).",
                "type": "string"
              },
              {
                "allOf": [
                  {
                    "$ref": "#/definitions/neo-cluster/properties/node"
                  },
                  {
                    "description": "Override value (parameters for maching nodes)."
                  }
                ]
              }
            ],
            "type": "array"
          },
          "type": "array"
        }
      },
      "type": "object"
    }
  },
  "allOf": [
    {
      "$ref": "#/definitions/neo-cluster"
    },
    {
      "required": [
        "cluster"
      ]
    }
  ]
}
