{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "title": "Services",
  "type": "object",
  "definitions": {
    "locations": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "name": {
      "type": "string"
    },
    "checkType": {
      "type": "string",
      "enum": [
        "http",
        "tcp"
      ]
    },
    "timeout": {
      "type": "number"
    },
    "slowThreshold": {
      "type": "number"
    },
    "tags": {
      "type": [
        "array",
        "null"
      ],
      "items": {
        "type": "string",
        "format": "mongoId"
      }
    },
    "group": {
      "type": [
        "string",
        "null"
      ]
    },
    "auth": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "username": {
          "type": "string"
        },
        "password": {
          "type": "string"
        }
      }
    },
    "tcp": {
      "type": "object",
      "properties": {
        "name": {
          "$ref": "#/definitions/name"
        },
        "checkType": {
          "type": "string",
          "enum": [
            "tcp"
          ]
        },
        "timeout": {
          "$ref": "#/definitions/timeout"
        },
        "checkLocations": {
          "$ref": "#/definitions/locations"
        },
        "slowThreshold": {
          "$ref": "#/definitions/slowThreshold"
        },
        "tags": {
          "$ref": "#/definitions/tags"
        },
        "group": {
          "$ref": "#/definitions/group"
        },
        "auth": {
          "$ref": "#/definitions/auth"
        },
        "host": {
          "type": "string"
        },
        "port": {
          "type": "string"
        },
        "data": {
          "type": "string"
        }
      },
      "required": [
        "name",
        "checkType",
        "timeout",
        "checkLocations",
        "host",
        "port",
        "data"
      ]
    },
    "http": {
      "type": "object",
      "properties": {
        "name": {
          "$ref": "#/definitions/name"
        },
        "checkType": {
          "type": "string",
          "enum": [
            "http"
          ]
        },
        "timeout": {
          "$ref": "#/definitions/timeout"
        },
        "checkLocations": {
          "$ref": "#/definitions/locations"
        },
        "slowThreshold": {
          "$ref": "#/definitions/slowThreshold"
        },
        "tags": {
          "$ref": "#/definitions/tags"
        },
        "group": {
          "$ref": "#/definitions/group"
        },
        "auth": {
          "$ref": "#/definitions/auth"
        },
        "checkMethod": {
          "type": "string",
          "enum": [
            "GET",
            "POST",
            "PUT",
            "DELETE"
          ]
        },
        "checkUrl": {
          "type": "string"
        },
        "body": {
          "type": "string"
        },
        "validateCert": {
          "type": "boolean"
        },
        "headers": {
          "type": [
            "array",
            "null"
          ]
        }
      },
      "required": [
        "name",
        "checkType",
        "timeout",
        "checkUrl",
        "checkLocations",
        "checkMethod",
        "slowThreshold"
      ]
    }
  },
  "oneOf": [
    {
      "$ref": "#/definitions/http"
    },
    {
      "$ref": "#/definitions/tcp"
    }
  ]
}