{
  "$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.",
  "type": "object",
  "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"
        },
        "reflink": {
          "description": "Track references between OIDs of an external ZODB.",
          "additionalProperties": false,
          "required": [
            "zurl"
          ],
          "properties": {
            "zurl": {
              "description": "ZODB to track.",
              "type": "string"
            },
            "_ca": {
              "type": "string"
            },
            "_cert": {
              "type": "string"
            },
            "_key": {
              "type": "string"
            },
            "max-txn-size": {
              "description": "Maximum number of OIDs to delete per transaction.",
              "default": 2097151,
              "type": "integer"
            },
            "commit-interval": {
              "description": "Commit every SECONDS of work.",
              "default": 10,
              "type": "integer"
            },
            "period": {
              "description": "Age of the historical revision at which a GC is performed (this can be seen as a grace period). See --period option.",
              "default": 86400,
              "type": "integer"
            },
            "no-gc": {
              "description": "Only track references.",
              "default": false,
              "type": "boolean"
            }
          },
          "type": "object"
        },
        "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. A node can be removed by requesting it without any admin, master and storage.",
          "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": "Admin port, 0 to disable. Default to 2050 if the node has a master, 0 otherwise.",
              "type": "integer"
            },
            "master": {
              "description": "Master port, 0 to disable.",
              "default": 2051,
              "type": "integer"
            },
            "monitor": {
              "description": "Monitor port, 0 to disable. Unless explicitly set by a node, the first one with an admin gets a monitor at port 2052.",
              "type": "integer"
            },
            "storage-count": {
              "description": "Number of storage nodes to deploy. One master and one admin node is deployed with each storage. 0 to disable.",
              "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"
            },
            "disable-pack": {
              "description": "Set the --disable-pack option for storage nodes.",
              "default": false,
              "type": "boolean"
            },
            "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"
            },
            "test-binding-list": {
              "description": "List of bindings to test when running the test suite.",
              "type": "array"
            },
            "storage-type": {
              "description": "Storage type. Required when several types are configured and you select which one to use via 'node!' parameter. Defaults to whatever is configured ('sqlite' or 'mysql'), else MySQL if available, else SQLite. SQLite is recommended for a reflink DB.",
              "enum": [
                "MySQL",
                "SQLite"
              ],
              "type": "string"
            },
            "sqlite": {
              "description": "Storage backend configuration.",
              "properties": {
                "relaxed-writes": {
                  "description": "When enabled, sets synchronous = OFF and journal_mode = MEMORY - RTFM, those options are dangerous.",
                  "default": false,
                  "type": "boolean"
                },
                "cksumvfs": {
                  "description": "See https://www.sqlite.org/cksumvfs.html. It can be safely disabled if the underlying storage layer is already checksumming, e.g. Btrfs (on this FS, you should also set journal_mode=TRUNCATE).",
                  "default": 1,
                  "type": "integer",
                  "enum": [
                    0,
                    1
                  ]
                }
              },
              "additionalProperties": {
                "description": "See NEO documentation for the list of supported settings.",
                "type": [
                  "number",
                  "string"
                ]
              },
              "type": "object"
            },
            "mysql": {
              "description": "MariaDB server configuration.",
              "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 parameters like innodb_buffer_pool_size, rocksdb_block_cache_size, etc.",
                "type": [
                  "number",
                  "string"
                ]
              },
              "type": "object"
            },
            "engine": {
              "description": "[MySQL only] For NEO, this is a creation-time parameter and it defaults to NEO's default. For mysqld, this sets plugins to load and it defaults to load all.",
              "enum": [
                "InnoDB",
                "RocksDB"
              ],
              "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"
      ]
    }
  ]
}
