Created
July 24, 2013 03:17
-
-
Save klen/6067836 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Push payload scheme | |
// JSON schema: http://json-schema.org/ | |
{ | |
"$schema": "http://json-schema.org/draft-04/schema#", | |
"description": "Push payload specification", | |
"type": "object", | |
"oneOf": [ | |
{ | |
"$ref": "#/definitions/ping", | |
"$ref": "#/definitions/control", | |
"$ref": "#/definitions/state", | |
"$ref": "#/definitions/event", | |
"$ref": "#/definitions/message", | |
} | |
], | |
"definitions": { | |
// Ping signal (no params) | |
// { | |
// "type": "ping", | |
// "created_at": "2012-12-12 00:00" | |
// } | |
"ping": { | |
"required": ["type", "created_at"], | |
"properties": { | |
"type": { | |
"enum": ["ping"] | |
}, | |
"created_at": { | |
"type": "string", | |
"description": "A datetime in ISO format" | |
} | |
} | |
}, | |
// Control signal (new release, maintaince) | |
// { | |
// "type": "control", | |
// "params": { "mode": "maintance", "seconds": 3600 }, | |
// "created_at": "2012-12-12 00:00" | |
// } | |
// | |
"control": { | |
"required": ["type", "created_at", "params"], | |
"properties": { | |
"type": { | |
"enum": ["control"], | |
}, | |
"created_at": { | |
"type": "string", | |
"description": "A datetime in ISO format" | |
}, | |
"params": { | |
"type": "object", | |
"required": [ "mode" ], | |
"properties": { | |
"mode": { | |
"enum": ["release", "maintaince" ], | |
} | |
} | |
} | |
} | |
}, | |
// DB changes | |
// | |
// Object updated | |
// { | |
// "type": "state", | |
// "created_at": "2012-12-12 00:00", | |
// "params": { | |
// "model": "keyword", | |
// "pk": "1", | |
// "mode": "update" | |
// } | |
// } | |
// | |
// Object created | |
// { | |
// "type": "state", | |
// "created_at": "2012-12-12 00:00", | |
// "params": { | |
// "model": "ad", | |
// "pk": "100", | |
// "mode": "create" | |
// } | |
// } | |
"state": { | |
"required": ["type", "created_at", "params"], | |
"properties": { | |
"type": { | |
"enum": ["state"], | |
}, | |
"created_at": { | |
"type": "string", | |
"description": "A datetime in ISO format" | |
}, | |
"params": { | |
"type": "object" | |
"required": ["model", "id", "mode"], | |
"properties": { | |
"model": { | |
"type": "string", | |
}, | |
"id": { | |
"type": "string" | |
}, | |
"mode": { | |
"enum": ["create", "update", "delete" ], | |
}, | |
} | |
} | |
} | |
} | |
// Server events. By example analytics data has been loaded | |
// | |
// { | |
// "type": "event", | |
// "created_at": "2012-12-12 00:00", | |
// "params": { | |
// "listener": "some-control" | |
// } | |
// } | |
"event": { | |
"required": ["type", "created_at", "params"], | |
"type": { | |
"enum": ["event"], | |
}, | |
"created_at": { | |
"type": "string", | |
"description": "A datetime in ISO format" | |
}, | |
"params": { | |
"type": "object" | |
"required": ["listener"], | |
"properties": { | |
"listener": { | |
"type": "string" | |
} | |
} | |
} | |
} | |
"message": { | |
"required": ["type", "created_at", "params"], | |
"type": { | |
"enum": ["message"], | |
}, | |
"created_at": { | |
"type": "string", | |
"description": "A datetime in ISO format" | |
}, | |
"params": { | |
"type": "object" | |
"required": ["mode", "text"], | |
"properties": { | |
"mode": { | |
"enum": ["info", "warning", "error" ], | |
}, | |
"text": { | |
"type": "string" | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment