{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "title": "SIP workflow schema ",
    "description": "Schema for SIP workflow definition",
    "version": "1.0.0",
    "type": "object",
    "required": [
        "id",
        "version"
    ],
    "properties": {
        "id": {
            "description": "Workflow identifier",
            "type": "string"
        },
        "version": {
            "description": "Workflow version",
            "type": "string",
            "pattern": "^([0-9]{1,4}.[0-9]{1,4}.[0-9]{1,4})|(test)"
        },
        "stages": {
            "description": "Array of workflow stages",
            "type": "array",
            "items": {
                "description": "Workflow stage specification",
                "type": "object",
                "$ref": "#/definitions/workflow_stage"
            }
        }
    },
    "definitions": {
        "workflow_stage": {
            "required": [
                "id",
                "type",
                "version",
                "resources_required",
                "ee_config",
                "app_config"
            ],
            "properties": {
                "id": {
                    "description": "Workflow stage: identifier",
                    "type": "string"
                },
                "type": {
                    "description": "Workflow stage: type",
                    "enum": [
                        "emulator",
                        "setup",
                        "cleanup",
                        "processing",
                        "simulator"
                    ]
                },
                "version": {
                    "description": "Workflow stage version",
                    "type": "string",
                    "pattern": "^([0-9]{1,4}.[0-9]{1,4}.[0-9]{1,4})|(test)"
                },
                "dependencies": {
                    "description": "Workflow stage: dependencies",
                    "type": "array",
                    "items": {
                        "type": "object",
                        "$ref": "#/definitions/dependency"
                    }
                },
                "resources_required": {
                    "description": "Workflow stage: resources required",
                    "type": "array",
                    "items": {
                        "type": "object",
                        "$ref": "#/definitions/resources"
                    }
                },
                "ee_config": {
                    "description": "Execution Engine configuration",
                    "type": "object"
                },
                "app_config": {
                    "description": "Application configuration",
                    "type": "object"
                }
            }
        },
        "dependency": {
            "required": [
                "type",
                "value",
                "condition"
            ],
            "properties": {
                "type": {
                    "description": "Type of dependency",
                    "enum": [
                        "stage",
                        "buffer_object"
                    ]
                },
                "value": {
                    "description": "Value of the dependency",
                    "type": "string"
                },
                "condition": {
                    "description": "Dependency condition",
                    "enum": [
                        "complete",
                        "started",
                        "present"
                    ]
                },
                "parameters": {
                    "description": "Additional parameters describing the dependency",
                    "type": "object"
                }
            }
        },
        "resources": {
            "required": [
                "type",
                "value"
            ],
            "properties": {
                "type": {
                    "description": "Resource type",
                    "enum": [
                        "cpu",
                        "memory",
                        "node"
                    ]
                },
                "value": {
                    "description": "Value (amount) of the resource",
                    "anyOf": [
                        {
                            "type": "string"
                        },
                        {
                            "type": "number"
                        }
                    ]
                },
                "parameters": {
                    "description": "Additional parameters describing the resource",
                    "type": "object"
                }
            }
        }
    }
}