{
    "$schema": "http://json-schema.org/schema#",
    "type": "object",
    "properties": {
        "type": {
            "type": "string",
            "description": "The service type (should always be SNS)",
            "pattern": "^sns$",
            "errorMessage": "Must equal 'sns'"
        },
        "subscriptions": {
            "type": "array",
            "description": "An optional list of one or more topic subscriptions to add",
            "errorMessage": "Must contain one or more subscription objects", 
            "items": {
                "type": "object",
                "properties": {
                    "endpoint": {
                        "type": "string",
                        "errorMessage": "Must be a string"
                    },
                    "protocol": {
                        "type": "string",
                        "pattern": "^(http|https|email|email-json|sms)$",
                        "errorMessage": "Must be one of the following values: http, https, email, email-json, sms"
                    }
                },
                "additionalProperties": false,
                "required": ["endpoint", "protocol"],
                "errorMessage": {
                    "type": "Each subscription must be an object containing the 'endpoint' and 'protocol' properties",
                    "additionalProperties": "Invalid property specified",
                    "required": {
                        "endpoint": "The 'endpoint' parameter is required",
                        "protocol": "The 'protocol' parameter is required"
                    }
                }
            }
        },
        "event_consumers": {
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "service_name": {
                        "type": "string",
                        "errorMessage": "Must be a string"
                    }
                },
                "errorMessage": "Must contain an array of objects with the 'service_name' and 'event_input' properties",
                "additionalProperties": false
            }
        },
        "tags": {
            "type": "object",
            "description": "An arbitrary list of key/value pairs to be added as tags to the service",
            "patternProperties": {
                "^.*$": {
                    "anyOf": [
                        {"type": "string"},
                        {"type": "number"}
                    ]
                }
            },
            "errorMessage": "Must contain 1 or more simple key/value pairs where the values are strings or numbers",
            "additionalProperties": false
        }
    },
    "required": ["type"],
    "additionalProperties": false,
    "errorMessage": {
        "additionalProperties": "Invalid/unknown property specified",
        "required": {
            "type": "The top-level 'type' field is required"
        }
    }
}