"""Validation schema for request body.""" from transcoding.constants import field_const, transcoding as transcoding_constants post_transcoding_schema = { "$schema": "http://json-schema.org/draft-04/schema#", "title": "Request Body Schema", "type": "object", "properties": { field_const.INPUT: { "type": "object", "properties": { field_const.BUCKET: { "type": "string", }, field_const.KEY: { "type": "string", }, }, "required": [field_const.BUCKET, field_const.KEY], }, field_const.OUTPUT: { "type": "object", "properties": { field_const.BUCKET: { "type": "string", }, field_const.TRANSCODING: { "type": "array", "items": { "type": "object", "properties": { field_const.CONTAINER: { "type": ["string", "null"], "enum": [None, *field_const.ALLOWED_CONTAINERS], }, field_const.CHANNELS: { "type": ["integer", "null"], "enum": [1, 2, None], }, field_const.CODEC: { "type": ["string", "null"], "enum": [None, *field_const.ALLOWED_CODECS], }, field_const.SAMPLE_RATE: { "type": ["integer", "null"], "enum": [ *field_const.ALLOWED_BIT_SAMPLE_RATE[24], None, ], }, field_const.BIT_RATE: {"type": ["integer", "null"]}, field_const.BIT_DEPTH: { "type": ["integer", "null"], "enum": [16, 24, None], }, }, "required": [ field_const.CONTAINER, field_const.CHANNELS, field_const.SAMPLE_RATE, field_const.BIT_RATE, field_const.BIT_DEPTH, field_const.CODEC, ], }, }, }, "required": [field_const.BUCKET, field_const.TRANSCODING], }, field_const.STATUS_TOPIC_ALIAS: {"type": ["string", "null"]}, }, "required": [field_const.INPUT, field_const.OUTPUT], "additionalProperties": False, } post_transcoding_by_preset_schema = { "$schema": "http://json-schema.org/draft-04/schema#", "title": "Request Body Schema", "type": "object", "properties": { field_const.INPUT: { "type": "object", "properties": { field_const.BUCKET: { "type": "string", }, field_const.KEY: { "type": "string", }, field_const.METADATA: { "type": "object", "properties": { field_const.CHANNELS: {"type": "integer"}, field_const.CODEC: {"type": "string"}, field_const.CONTAINER: {"type": "string"}, field_const.SAMPLE_RATE: {"type": "integer"}, field_const.BIT_DEPTH: {"type": "integer"}, field_const.BIT_RATE: {"type": "integer"}, }, "required": [ field_const.CHANNELS, field_const.CODEC, field_const.CONTAINER, field_const.SAMPLE_RATE, field_const.BIT_DEPTH, field_const.BIT_RATE, ], }, }, "required": [field_const.BUCKET, field_const.KEY], }, field_const.STATUS_TOPIC_ALIAS: {"type": ["string", "null"]}, }, "required": [field_const.INPUT], "additionalProperties": False, } post_transcoding_job_status_schema = { "$schema": "http://json-schema.org/draft-04/schema#", "title": "Post transcoding job status schema", "type": "object", "properties": { field_const.STATUS: { "type": "string", "enum": transcoding_constants.INCOMING_TRANSCODING_STATUSES, }, field_const.STATUS_DESCRIPTION: {"type": ["string", "null"]}, field_const.DURATION: {"type": ["integer", "null"]}, field_const.METADATA: {"type": ["object", "null"]}, }, "required": [field_const.STATUS], "additionalProperties": False, }