{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Rule",
"type": "object",
"properties": {
"id": {
"type": "string"
},
"tags": {
"type": "array",
"items": {
"type": "string"
}
},
"priority": {
"type": "number",
"default": 0
},
"destination": {
"type": "string"
},
"match": {
"type": "object",
"properties": {
"all": {
"type": "array",
"minItems": 1,
"items": {
"$ref": "#/definitions/match"
}
},
"any": {
"type": "array",
"minItems": 1,
"items": {
"$ref": "#/definitions/match"
}
},
"none": {
"type": "array",
"minItems": 1,
"items": {
"$ref": "#/definitions/match"
}
},
"source": {
"$ref": "#/definitions/source"
},
"headers": {
"$ref": "#/definitions/headers"
}
},
"additionalProperties": false,
"minProperties": 1
},
"route": {
"$ref": "#/definitions/route"
},
"actions": {
"type": "array",
"minItems": 1,
"items": {
"anyOf": [
{
"$ref": "#/definitions/delayAction"
},
{
"$ref": "#/definitions/abortAction"
},
{
"$ref": "#/definitions/traceAction"
}
]
}
}
},
"additionalFields": false,
"required": ["destination"],
"oneOf": [
{
"title": "Route rule",
"required": ["route"]
},
{
"title": "Action rule",
"required": ["actions"]
}
],
"definitions": {
"tags": {
"title": "Tags",
"description": "An array of one or more unique service tags.",
"type": "array",
"items": {
"type": "string"
},
"uniqueItems": true,
"minItems": 1
},
"source": {
"title": "Source",
"description": "Microservice where request originated from",
"type": "object",
"properties": {
"name": {
"type": "string"
},
"tags": {
"$ref": "#/definitions/tags"
}
},
"required": [
"name"
],
"additionalProperties": false
},
"headers": {
"title": "Headers",
"description": "Header key/value pairs",
"type": "object",
"additionalProperties": {
"title": "Header",
"type": "string"
},
"minProperties": 1
},
"match": {
"title": "Match",
"description": "Conditions that must be true to apply the action or routing",
"type": "object",
"properties": {
"source": {
"$ref": "#/definitions/source"
},
"headers": {
"$ref": "#/definitions/headers"
}
},
"additionalProperties": false,
"minProperties": 1
},
"basicBackend": {
"title": "Basic Backend",
"description": "Basic backend to route to",
"type": "object",
"properties": {
"name": {
"title": "Service name",
"description": "The service name",
"type": "string"
},
"tags": {
"$ref": "#/definitions/tags"
}
},
"required": [
"tags"
],
"additionalProperties": false
},
"backend": {
"title": "Backend",
"description": "Backend to route to",
"type": "object",
"properties": {
"name": {
"title": "Service name",
"description": "The service name",
"type": "string"
},
"tags": {
"$ref": "#/definitions/tags"
},
"weight": {
"title": "Traffic weight",
"description": "Percentage of traffic to route to this backend.",
"type": "number",
"minimum": 0,
"maximum": 1,
"exclusiveMinimum": true,
"default": 1
},
"timeout": {
"description": "Request timeout or read/write timeout on the pipe in seconds",
"type": "number",
"minimum": 0,
"exclusiveMinimum": true
}
},
"required": [
"tags"
],
"additionalProperties": false
},
"route": {
"type": "object",
"properties": {
"backends": {
"type": "array",
"minItems": 1,
"items": {
"$ref": "#/definitions/backend"
}
}
},
"required": ["backends"],
"additionalProperties": false
},
"probability": {
"title": "Probability",
"description": "Probability of executing action",
"type": "number",
"minimum": 0,
"maximum": 1,
"exclusiveMinimum": true,
"default": 1
},
"action": {
"title": "Action",
"description": "Action to apply to matching requests",
"type": "object",
"properties": {
"action": {
"type": "string"
}
},
"required": ["action"]
},
"delayAction": {
"title": "Delay",
"description": "Conditionally delay the request",
"properties": {
"action": {
"enum": ["delay"]
},
"probability": {
"$ref": "#/definitions/probability"
},
"tags": {
"$ref": "#/definitions/tags"
},
"duration": {
"type": "number",
"description": "Duration of delay in seconds",
"minimum": 0,
"exclusiveMinimum": true
}
},
"required": [
"duration"
],
"additionalProperties": false,
"allOf": [
{
"$ref": "#/definitions/action"
}
]
},
"abortAction": {
"title": "Abort",
"description": "Conditionally abort the request",
"properties": {
"action": {
"enum": ["abort"]
},
"probability": {
"$ref": "#/definitions/probability"
},
"tags": {
"$ref": "#/definitions/tags"
},
"return_code": {
"type": "number",
"description": "Return code",
"minimum": -5,
"maximum": 599
}
},
"required": ["return_code"],
"additionalProperties": false,
"allOf": [
{
"$ref": "#/definitions/action"
}
]
},
"traceAction": {
"title": "Trace",
"description": "Trace request",
"properties": {
"action": {
"enum": ["trace"]
},
"tags": {
"$ref": "#/definitions/tags"
},
"log_key": {
"type": "string",
"default": "trace"
},
"log_value": {
"type": "string"
}
},
"additionalProperties": false,
"allOf": [
{
"$ref": "#/definitions/action"
}
]
}
}
}