{
  "$schema": "http://json-schema.org/draft-04/schema#",

  "title": "Pool definition",

  "pool": {
    "description": "Definition of Pool of APPs",
    "type": "object",
    "properties": {
      "id": {
        "description": "Pool ID",
        "$ref": "definitions.json#/uint"
      },
      "name": {
        "description": "Pool's name",
        "$ref": "definitions.json#/string_nonempty"
      },
      "l2cbm": {
        "description": "L2 CAT cache bit mask",
        "$ref": "definitions.json#/string_hex"
      },
      "l2cbm_code": {
        "description": "L2 CAT cache code bit mask",
        "$ref": "definitions.json#/string_hex"
      },
      "l2cbm_data": {
        "description": "L2 CAT cache data bit mask",
        "$ref": "definitions.json#/string_hex"
      },
      "cbm": {
        "description": "L3 CAT cache bit mask (replaced by l3cbm)",
        "deprecated": true,
        "$ref": "definitions.json#/string_hex"
      },
      "l3cbm": {
        "description": "L3 CAT cache bit mask",
        "$ref": "definitions.json#/string_hex"
      },
      "l3cbm_code": {
        "description": "L3 CAT cache code bit mask",
        "$ref": "definitions.json#/string_hex"
      },
      "l3cbm_data": {
        "description": "L3 CAT cache data bit mask",
        "$ref": "definitions.json#/string_hex"
      },
      "mba": {
        "description": "MBA rate %",
        "$ref": "definitions.json#/percentage_nonzero"
      },
      "mba_bw": {
        "description": "MBA rate MBps",
        "$ref": "definitions.json#/mbps_nonzero"
      },
      "power_profile" : {
        "description": "Power profile ID",
        "$ref": "definitions.json#/uint"
      },
      "cores": {
        "description": "POOL cores",
        "$ref": "definitions.json#/uint_uniq_nonempty_array"
      },
      "apps": {
        "description": "APPs assigned to that pool",
        "$ref": "definitions.json#/uint_uniq_array"
      }
    },
    "dependencies": {
      "mba": {
        "type": "object",
        "not": { "required": [ "mba_bw" ] }
      }
    }
  },

  "pool_cfg": {
    "allOf": [
      { "$ref": "#pool" },
      { "properties": {
          "name": {},
          "cores": {},
          "l2cbm":{},
          "l2cbm_data": {},
          "l2cbm_code": {},
          "cbm": {},
          "l3cbm": {},
          "l3cbm_data": {},
          "l3cbm_code": {},
          "mba": {},
          "mba_bw": {},
          "id": {},
          "apps": {},
          "power_profile": {}
        },
        "anyOf": [
          { "required": ["cbm"] },
          { "required": ["l3cbm"] },
          { "required": ["l3cbm_code"] },
          { "required": ["l3cbm_data"] },
          { "required": ["l2cbm"] },
          { "required": ["l2cbm_code"] },
          { "required": ["l2cbm_data"] },
          { "required": ["mba"] },
          { "required": ["mba_bw"] },
          { "required": ["power_profile"] }
        ],
        "dependencies": {
          "l3cbm_data": {
            "type": "object",
            "anyOf": [
              { "required": ["l3cbm"] },
              { "required": ["l3cbm_code"] }
            ]
          },
          "l3cbm_code": {
            "type": "object",
            "anyOf": [
              { "required": ["l3cbm"] },
              { "required": ["l3cbm_data"] }
            ]
          },
          "l2cbm_data": {
            "type": "object",
            "anyOf": [
              { "required": ["l2cbm"] },
              { "required": ["l2cbm_code"] }
            ]
          },
          "l2cbm_code": {
            "type": "object",
            "anyOf": [
              { "required": ["l2cbm"] },
              { "required": ["l2cbm_data"] }
            ]
          }
        },
        "required": ["cores", "id"],
        "additionalProperties": false
      }
    ]
  },

  "pool_api_get": {
    "allOf": [
      { "$ref": "#/pool" }
    ]
  },

  "pool_api_post": {
    "allOf": [
      { "$ref": "#pool" },
      { "properties": {
          "name": {},
          "cores": {},
          "l2cbm": {},
          "l2cbm_data": {},
          "l2cbm_code": {},
          "cbm": {},
          "l3cbm": {},
          "l3cbm_data": {},
          "l3cbm_code": {},
          "mba": {},
          "mba_bw": {},
          "power_profile" : {},
          "verify": {
              "description": "Power Profiles Admission Control",
              "type": "boolean"
          }
        },
        "anyOf": [
          { "required": ["cbm"] },
          { "required": ["l3cbm"] },
          { "required": ["l3cbm_code"] },
          { "required": ["l3cbm_data"] },
          { "required": ["l2cbm"] },
          { "required": ["l2cbm_code"] },
          { "required": ["l2cbm_data"] },
          { "required": ["mba"] },
          { "required": ["mba_bw"] },
          { "required": ["power_profile"] }
        ],
        "required": ["cores"],
        "additionalProperties": false
      }
    ]
  },

  "pool_api_put": {
    "allOf": [
      { "$ref": "#/pool" },
      { "properties": {
          "name": {},
          "cores": {},
          "l2cbm": {},
          "l2cbm_data": {},
          "l2cbm_code": {},
          "cbm": {},
          "l3cbm": {},
          "l3cbm_code": {},
          "l3cbm_data": {},
          "mba": {},
          "mba_bw": {},
          "power_profile" : {},
          "apps": {},
          "verify": {
              "description": "Power Profiles Admission Control",
              "type": "boolean"
          }
        },
        "anyOf": [
          { "required": ["name"] },
          { "required": ["l2cbm"] },
          { "required": ["l2cbm_code"] },
          { "required": ["l2cbm_data"] },
          { "required": ["cbm"] },
          { "required": ["l3cbm"] },
          { "required": ["l3cbm_code"] },
          { "required": ["l3cbm_data"] },
          { "required": ["mba"] },
          { "required": ["mba_bw"] },
          { "required": ["cores"] },
          { "required": ["apps"] },
          { "required": ["power_profile"] }
        ],
        "additionalProperties": false
      }
    ]
  }
}
