{
    "$schema": "http://json-schema.org/draft-06/schema#",
    "$id": "https://github.com/apache/trafficserver/tree/master/configs/strategies.schema.json",
    "$ref": "#/definitions/Strategies",
    "definitions": {
        "Strategies": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
                "hosts": {
                    "type": "array",
                    "description": "An array of hosts assigned to a group",
                    "items": {
                        "$ref": "#/definitions/Host"
                    }
                },
                "groups": {
                    "type": "array",
                    "description": "A group otherwise known as a ring, is a collection of hosts",
                    "items": {
                        "type": "array",
                        "items": {
                            "$ref": "#/definitions/Group"
                        }
                    }
                },
                "strategies": {
                    "type": "array",
                    "description": "A next hop selection strategy definition",
                    "items": {
                        "$ref": "#/definitions/Strategy"
                    }
                }
            },
            "required": [
                "groups",
                "hosts",
                "strategies"
            ],
            "title": "Trafficserver Strategies"
        },
        "Group": {
            "type": "object",
            "additionalProperties": false,
            "description": "A host member within a group or ring",
            "properties": {
                "host": {
                    "type": "string",
                    "description": "The hosts fully qualified hostname or IP address"
                },
                "protocol": {
                    "type": "array",
                    "description": "The set of protocols supported on this host",
                    "items": {
                        "$ref": "#/definitions/Protocol"
                    }
                },
                "weight": {
                    "type": "number",
                    "description": "The optional weighting to apply for this host within a ring"
                }
            },
            "required": [
                "host",
                "protocol"
            ],
            "title": "Group"
        },
        "Protocol": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
                "scheme": {
                    "$ref": "#/definitions/Scheme"
                },
                "port": {
                    "type": "integer",
                    "description": "the protocol port number",
                    "minimum": 80,
                    "maximum": 65534
                },
                "health_check_url": {
                    "type": "string",
                    "description": "the optional url that may be used for a health checking system",
                    "format": "uri",
                    "qt-uri-protocols": [
                        "http",
                        "https",
                        "tcp"
                    ]
                }
            },
            "required": [
                "port",
                "scheme"
            ],
            "title": "Protocol"
        },
        "Host": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
                "host": {
                    "type": "string",
                    "description": "The fully qualified host name or IP address of the host"
                },
                "protocol": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/Protocol"
                    }
                }
            },
            "required": [
                "host",
                "protocol"
            ],
            "title": "Host"
        },
        "Strategy": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
                "strategy": {
                    "type": "string",
                    "description": "the name assigned to this strategy"
                },
                "policy": {
                    "type": "string",
                    "description": "the host selection algorithm for the strategy",
                    "enum": [
                      "rr_ip",
                      "rr_strict",
                      "first_live",
                      "latched",
                      "consistent_hash"
                    ]
                },
                "hash_key": {
                  "type": "string",
                  "description": "when using consistent_hash, this specifies the chosen key used for the hash",
                  "enum": [
                    "hostname",
                    "path",
                    "path+query",
                    "path+fragment",
                    "cache_key",
                    "url"
                  ]
                },
                "go_direct": {
                    "type": "boolean",
                    "description": "wether, true/false, users of the strategy may bypass parents and go directly to the origin"
                },
                "parent_is_proxy": {
                    "type": "boolean",
                    "description": "all the hosts assigned to the strategy are all caching proxy servers"
                },
                "cache_peer_result": {
                    "type": "boolean",
                    "description": "cache or do not cache proxy peer responses when using a peering ring mode and consistent hashing"
                },
                "groups": {
                    "type": "array",
                    "description": "the groups of hosts assigned to the strategy",
                    "items": {
                        "type": "array",
                        "items": {
                            "$ref": "#/definitions/Group"
                        }
                    }
                },
                "scheme": {
                    "$ref": "#/definitions/Scheme"
                },
                "failover": {
                    "$ref": "#/definitions/Failover"
                }
            },
            "required": [
                "groups",
                "policy",
                "scheme",
                "strategy"
            ],
            "title": "Strategy"
        },
        "Failover": {
            "type": "object",
            "description": "failover configuration for the strategy",
            "additionalProperties": false,
            "properties": {
                "max_simple_retries": {
                    "type": "integer",
                    "description": "the maximum number of retries for a transaction when using simple retry",
                    "minimum": 0,
                    "maximum": 5
                },
                "max_unavailable_retries": {
                    "type": "integer",
                    "description": "the maximum number of retries for a transaction when using unavailable server retry",
                    "minimum": 0,
                    "maximum": 5
                },
                "ring_mode": {
                    "type": "string",
                    "description": "the ring host selection mode",
                    "enum": [
                      "exhaust_ring",
                      "alternate_ring",
                      "peering_ring"
                    ]
                },
                "response_codes": {
                    "type": "array",
                    "description": "list of simple retry http response codes",
                    "items": {
                        "type": "integer",
                        "minimum": 400,
                        "maximum": 599
                    }
                },
                "markdown_codes": {
                    "type": "array",
                    "description": "list of unavailable server  retry http response codes",
                    "items": {
                        "type": "integer",
                        "minimum": 400,
                        "maximum": 599
                    }
                },
                "health_check": {
                    "type": "array",
                    "description": "the health checking mode used for the strategy",
                    "items": {
                        "type": "string",
                        "enum": [
                          "active",
                          "passive"
                        ]
                    }
                }
            },
            "title": "Failover"
        },
        "Scheme": {
            "type": "string",
            "description": "the supported protocols used within the strategy",
            "enum": [
                "http",
                "https"
            ],
            "title": "Scheme"
        }
    }
}
