Files
notifications-api/app/v2/broadcast/broadcast_schemas.py
Chris Hill-Scott e8a79f5413 Don’t accept cancel or update via broadcast API
We don’t support these methods at the moment. Instead we were just
ignoring the `msgType` field, so issuing one of these commands would
cause a new alert to be broadcast 🙃

We might want to support `Cancel` in the future, but for now let’s
reject anything that isn’t `Alert` (CAP terminology for the initial
broadcast).
2021-02-15 09:32:33 +00:00

111 lines
2.7 KiB
Python

post_broadcast_schema = {
"$schema": "http://json-schema.org/draft-07/schema",
"type": "object",
"required": [
"msgType",
"reference",
"category",
"content",
"areas",
],
"additionalProperties": False,
"properties": {
"reference": {
"type": [
"string",
"null",
],
},
"category": {
"type": "string",
"enum": [
"Geo",
"Met",
"Safety",
"Security",
"Rescue",
"Fire",
"Health",
"Env",
"Transport",
"Infra",
"CBRNE",
"Other",
],
},
"expires": {
"type": "string",
"format": "date-time",
},
"content": {
"type": "string",
"minLength": 1,
"maxLength": 1395,
},
"web": {
"type": "string",
"format": "uri",
},
"areas": {
"type": "array",
"minItems": 1,
"items": {
"$ref": "#/definitions/area",
},
},
"msgType": {
"type": "string",
"enum": [
"Alert",
# The following are valid CAP but not supported by our
# API at the moment
# "Update",
# "Cancel",
# "Ack",
# "Error",
],
}
},
"definitions": {
"area": {
"type": "object",
"required": [
"name",
"polygons",
],
"additionalProperties": False,
"properties": {
"name": {
"type": "string",
},
"polygons": {
"type": "array",
"minItems": 1,
"items": {
"oneOf": [
{
"$ref": "#/definitions/polygon",
},
],
},
},
},
},
"polygon": {
"type": "array",
"minItems": 4,
"items": {
"$ref": "#/definitions/coordinatePair",
},
},
"coordinatePair": {
"type": "array",
"items": {
"type": "number"
},
"minItems": 2,
"maxItems": 2,
},
},
}