{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "definitions": {
        "assigned_resources": {
            "description": "Resource assigned for the processing block",
            "properties": {
                "status": {
                    "description": "Status of the resource assigned",
                    "type": "string"
                }
            },
            "type": "object"
        },
        "processing_blocks": {
            "description": "Array of processing blocks associated with this scheduling block",
            "items": {
                "description": "Processing block specification - description of required processing",
                "properties": {
                    "assigned_resources": {
                        "$ref": "#/definitions/assigned_resources"
                    },
                    "id": {
                        "description": "[project]-[type][id] for the processing block",
                        "pattern": "^[a-z]+-[a-z]+[0-9]+$",
                        "type": "string"
                    },
                    "priority": {
                        "description": "The Priority of the processing block",
                        "type": "number"
                    },
                    "resource_requirement": {
                        "$ref": "#/definitions/resources_requirement"
                    },
                    "status": {
                        "description": "Status of the processing block",
                        "type": "string"
                    },
                    "type": {
                        "description": "Type of the processing block",
                        "type": "string"
                    },
                    "workflow": {
                        "$ref": "#/definitions/workflow"
                    }
                },
                "required": [
                    "id",
                    "resources_requirement",
                    "workflow"
                ],
                "type": "object"
            },
            "type": "array"
        },
        "resources_requirement": {
            "description": "Resources required for the processing block",
            "properties": {
                "storage_type": {
                    "description": "Hot or cold buffer storage type",
                    "type": "string"
                }
            },
            "type": "object"
        },
        "workflow": {
            "description": "Workflow stages",
            "properties": {
                "status": {
                    "description": "Status of the workflow stage",
                    "type": "string"
                }
            },
            "type": "object"
        }
    },
    "description": "Schema for an SKA Scheduling Block Instance",
    "properties": {
        "date": {
            "description": "YYYYmmdd for the date",
            "pattern": "^[0-9]{8}$",
            "type": "string"
        },
        "id": {
            "description": "[date]-[project]-[type][id] for the scheduling block instance id",
            "pattern": "^[0-9]{8}-[\\w\\d]+-sbi[0-9]{3}$",
            "type": "string"
        },
        "name": {
            "description": "Optional name string",
            "type": "string"
        },
        "processing_blocks": {
            "$ref": "#/definitions/processing_blocks"
        },
        "project": {
            "description": "Project of the scheduling block instance",
            "type": "string"
        },
        "sched_block_id": {
            "description": "[date]-[project]-[type][id] for the scheduling block id",
            "pattern": "^[0-9]{8}-[\\w|\\d]+-sb[0-9]{3}$",
            "type": "string"
        },
        "status": {
            "description": "Status of the scheduling block instance",
            "type": "string"
        },
        "sub_array_id": {
            "description": "[type][id] for the sub array id",
            "pattern": "^subarray-0[0-9]|subarray-1[0-5]$",
            "type": "string"
        },
        "type": {
            "description": "Type of scheduling block",
            "type": "string"
        },
        "version": {
            "description": "Version of the scheduling block instance",
            "type": "string"
        }
    },
    "required": [
        "id",
        "sched_block_id",
        "sub_array_id",
        "processing_blocks"
    ],
    "title": "Scheduling Block Instance",
    "type": "object"
}