{
    "title": "job (volatile part)",
    "id": "schemas/job/job_v",
    "$schema": "http://json-schema.org/draft-04/schema#",
    "javaType": "com.sos.joc.model.job.JobV",
    "type": "object",
    "oneOf": [
        {
            "description": "as child of nodes only path and state are required; only configurationStatus is optional",
            "required": [
                "path",
                "state"
            ]
        },
        {
            "description": "parameter compact=true; only locks and configurationStatus are optional",
            "required": [
                "surveyDate",
                "path",
                "name",
                "state",
                "stateText",
                "ordersSummary",
                "numOfRunningTasks",
                "numOfQueuedTasks",
                "runTimeIsTemporary"
            ]
        },
        {
            "description": "parameter compact=false or undefined; all other fields below are optional",
            "required": [
                "surveyDate",
                "path",
                "name",
                "state",
                "stateText",
                "ordersSummary",
                "numOfRunningTasks",
                "numOfQueuedTasks",
                "runTimeIsTemporary",
                "allTasks",
                "allSteps"
            ]
        }
    ],
    "properties": {
        "surveyDate": {
            "id": "schemas/common/surveyDate_v",
            "description": "Current date of the JobScheduler Master/Agent. Value is UTC timestamp in ISO 8601 YYYY-MM-DDThh:mm:ss.sZ",
            "type": "string",
            "format": "date-time"
        },
        "path": {
            "id": "schemas/common/path",
            "description": "absolute path based on live folder of a JobScheduler object.",
            "type": "string",
            "pattern": "/([^/]+/)*[^/]+"
        },
        "name": {
            "type": "string"
        },
        "orderQueue": {
            "description": "Only for /job/orderQueue",
            "type": "array",
            "items": {
                "id": "schemas/order/order_v",
                "javaType": "com.sos.joc.model.order.OrderV",
                "type": "object",
                "allOf": [
                    {
                        "description": "compact=true then ONLY path, id, jobChain, _type, surveyDate, state, processingState, runTimeIsTemporary, job(except blacklisted orders) are required and only title, processedBy, configurationStatus are optional",
                        "required": [
                            "path",
                            "orderId",
                            "jobChain",
                            "surveyDate",
                            "state",
                            "processingState",
                            "_type",
                            "runTimeIsTemporary"
                        ]
                    },
                    {
                        "oneOf": [
                            {
                                "description": "pending order",
                                "required": [
                                    "nextStartTime"
                                ]
                            },
                            {
                                "description": "running order",
                                "required": [
                                    "historyId",
                                    "startedAt",
                                    "taskId",
                                    "inProcessSince"
                                ]
                            },
                            {
                                "description": "suspended, waitingForResource, blacklist order",
                                "required": [
                                    "historyId",
                                    "startedAt"
                                ]
                            },
                            {
                                "description": "setback order",
                                "required": [
                                    "historyId",
                                    "startedAt",
                                    "setback"
                                ]
                            }
                        ]
                    }
                ],
                "properties": {
                    "path": {
                        "id": "schemas/common/path",
                        "description": "absolute path based on live folder of a JobScheduler object.",
                        "type": "string",
                        "pattern": "/([^/]+/)*[^/]+"
                    },
                    "orderId": {
                        "type": "string"
                    },
                    "jobChain": {
                        "id": "schemas/common/path",
                        "description": "absolute path based on live folder of a JobScheduler object.",
                        "type": "string",
                        "pattern": "/([^/]+/)*[^/]+"
                    },
                    "priority": {
                        "id": "schemas/common/nonNegativeInteger",
                        "type": "integer",
                        "minimum": 0
                    },
                    "params": {
                        "id": "schemas/common/nameValuePairs",
                        "type": "array",
                        "items": {
                            "javaType": "com.sos.joc.model.common.NameValuePair",
                            "type": "object",
                            "required": [
                                "name",
                                "value"
                            ],
                            "properties": {
                                "name": {
                                    "type": "string"
                                },
                                "value": {
                                    "type": "string"
                                }
                            }
                        }
                    },
                    "_type": {
                        "id": "schemas/order/orderType",
                        "javaType": "com.sos.joc.model.order.OrderType",
                        "type": "string",
                        "description": "the type of the order",
                        "enum": [
                            "PERMANENT",
                            "AD_HOC",
                            "FILE_ORDER"
                        ]
                    },
                    "surveyDate": {
                        "id": "schemas/common/surveyDate_v",
                        "description": "Current date of the JobScheduler Master/Agent. Value is UTC timestamp in ISO 8601 YYYY-MM-DDThh:mm:ss.sZ",
                        "type": "string",
                        "format": "date-time"
                    },
                    "state": {
                        "description": "the name of the node",
                        "type": "string"
                    },
                    "title": {
                        "type": "string"
                    },
                    "job": {
                        "id": "schemas/common/path",
                        "description": "absolute path based on live folder of a JobScheduler object.",
                        "type": "string",
                        "pattern": "/([^/]+/)*[^/]+"
                    },
                    "stateText": {
                        "type": "string"
                    },
                    "configurationStatus": {
                        "id": "schemas/common/configurationStatus",
                        "javaType": "com.sos.joc.model.common.ConfigurationState",
                        "type": "object",
                        "required": [
                            "severity",
                            "_text"
                        ],
                        "properties": {
                            "severity": {
                                "description": "4=ok; 5=replacement_is_standing_by,removing_delayed; 2=error_in_configuration_file,changed_file_not_loaded,resource_is_missing",
                                "type": "integer"
                            },
                            "_text": {
                                "id": "schemas/common/configurationStatusText",
                                "javaType": "com.sos.joc.model.common.ConfigurationStateText",
                                "type": "string",
                                "enum": [
                                    "ERROR_IN_CONFIGURATION_FILE",
                                    "CHANGED_FILE_NOT_LOADED",
                                    "REMOVING_DELAYED",
                                    "RESOURCE_IS_MISSING",
                                    "REPLACEMENT_IS_STANDING_BY",
                                    "OK"
                                ]
                            },
                            "message": {
                                "description": "contains e.g. error message",
                                "type": "string"
                            }
                        }
                    },
                    "endState": {
                        "description": "the name of the end node",
                        "type": "string"
                    },
                    "processingState": {
                        "id": "schemas/jobChain/jobChainState",
                        "javaType": "com.sos.joc.model.order.OrderState",
                        "type": "object",
                        "required": [
                            "severity",
                            "_text"
                        ],
                        "properties": {
                            "severity": {
                                "description": "0=running, 4=active, 3=initialized, 2=under_construction/stopped/not_initialized",
                                "type": "integer"
                            },
                            "_text": {
                                "id": "schemas/order/orderProcessingStateText",
                                "javaType": "com.sos.joc.model.order.OrderStateText",
                                "type": "string",
                                "enum": [
                                    "PENDING",
                                    "RUNNING",
                                    "SUSPENDED",
                                    "SETBACK",
                                    "BLACKLIST",
                                    "JOB_NOT_IN_PERIOD",
                                    "NODE_DELAY",
                                    "WAITING_FOR_LOCK",
                                    "WAITING_FOR_PROCESS",
                                    "WAITING_FOR_AGENT",
                                    "JOB_CHAIN_STOPPED",
                                    "NODE_STOPPED",
                                    "JOB_STOPPED",
                                    "WAITING_FOR_TASK"
                                ]
                            },
                            "manually": {
                                "type": "boolean"
                            }
                        }
                    },
                    "nextStartTime": {
                        "id": "schemas/common/timestamp",
                        "description": "Value is UTC timestamp in ISO 8601 YYYY-MM-DDThh:mm:ss.sZ or empty",
                        "type": "string",
                        "format": "date-time"
                    },
                    "nextStartNever": {
                        "type": "boolean"
                    },
                    "historyId": {
                        "description": "for all orders except pending orders",
                        "type": "string"
                    },
                    "startedAt": {
                        "id": "schemas/common/timestamp",
                        "description": "Value is UTC timestamp in ISO 8601 YYYY-MM-DDThh:mm:ss.sZ or empty",
                        "type": "string",
                        "format": "date-time"
                    },
                    "processedBy": {
                        "description": "ONLY for running or blacklist order, contains Host/port of an active cluster member or URL of a JobScheduler Agent",
                        "type": "string"
                    },
                    "taskId": {
                        "description": "ONLY for running order",
                        "type": "string"
                    },
                    "inProcessSince": {
                        "id": "schemas/common/timestamp",
                        "description": "Value is UTC timestamp in ISO 8601 YYYY-MM-DDThh:mm:ss.sZ or empty",
                        "type": "string",
                        "format": "date-time"
                    },
                    "setback": {
                        "id": "schemas/common/timestamp",
                        "description": "Value is UTC timestamp in ISO 8601 YYYY-MM-DDThh:mm:ss.sZ or empty",
                        "type": "string",
                        "format": "date-time"
                    },
                    "lock": {
                        "id": "schemas/common/path",
                        "description": "absolute path based on live folder of a JobScheduler object.",
                        "type": "string",
                        "pattern": "/([^/]+/)*[^/]+"
                    },
                    "processClass": {
                        "id": "schemas/common/path",
                        "description": "absolute path based on live folder of a JobScheduler object.",
                        "type": "string",
                        "pattern": "/([^/]+/)*[^/]+"
                    },
                    "runTimeIsTemporary": {
                        "type": "boolean",
                        "default": false
                    },
                    "documentation": {
                        "id": "schemas/common/path",
                        "description": "absolute path based on live folder of a JobScheduler object.",
                        "type": "string",
                        "pattern": "/([^/]+/)*[^/]+"
                    }
                }
            }
        },
        "allTasks": {
            "id": "schemas/common/nonNegativeInteger",
            "type": "integer",
            "minimum": 0
        },
        "allSteps": {
            "id": "schemas/common/nonNegativeInteger",
            "type": "integer",
            "minimum": 0
        },
        "state": {
            "id": "schemas/job/jobState",
            "javaType": "com.sos.joc.model.job.JobState",
            "type": "object",
            "required": [
                "severity",
                "_text"
            ],
            "properties": {
                "severity": {
                    "description": "0=running; 1=pending; 2=not_initialized/waiting_for_agent/stopping/stopped/error, 3=initialized/loaded/waiting_for_process/waiting_for_lock/waiting_for_task/not_in_period, 4=disabled/unknown",
                    "type": "integer"
                },
                "_text": {
                    "id": "schemas/job/jobStateText",
                    "javaType": "com.sos.joc.model.job.JobStateText",
                    "type": "string",
                    "enum": [
                        "INITIALIZED",
                        "NOT_INITIALIZED",
                        "LOADED",
                        "PENDING",
                        "RUNNING",
                        "WAITING_FOR_PROCESS",
                        "WAITING_FOR_LOCK",
                        "WAITING_FOR_AGENT",
                        "WAITING_FOR_TASK",
                        "NOT_IN_PERIOD",
                        "STOPPING",
                        "STOPPED",
                        "DISABLED",
                        "ERROR",
                        "UNKNOWN"
                    ]
                },
                "manually": {
                    "type": "boolean"
                }
            }
        },
        "stateText": {
            "type": "string"
        },
        "locks": {
            "id": "schemas/job/locks_v",
            "type": "array",
            "items": {
                "javaType": "com.sos.joc.model.job.LockUseV",
                "type": "object",
                "required": [
                    "path",
                    "exclusive",
                    "available"
                ],
                "properties": {
                    "path": {
                        "id": "schemas/common/path",
                        "description": "absolute path based on live folder of a JobScheduler object.",
                        "type": "string",
                        "pattern": "/([^/]+/)*[^/]+"
                    },
                    "available": {
                        "type": "boolean"
                    },
                    "exclusive": {
                        "type": "boolean"
                    }
                }
            }
        },
        "temporary": {
            "type": "boolean"
        },
        "numOfRunningTasks": {
            "id": "schemas/common/nonNegativeInteger",
            "type": "integer",
            "minimum": 0
        },
        "runningTasks": {
            "type": "array",
            "items": {
                "id": "schemas/job/runningTask",
                "type": "object",
                "javaType": "com.sos.joc.model.job.RunningTask",
                "description": "task object of an order job which is running",
                "required": [
                    "taskId",
                    "startedAt"
                ],
                "properties": {
                    "taskId": {
                        "type": "string"
                    },
                    "pid": {
                        "type": "integer"
                    },
                    "startedAt": {
                        "id": "schemas/common/timestamp",
                        "description": "Value is UTC timestamp in ISO 8601 YYYY-MM-DDThh:mm:ss.sZ or empty",
                        "type": "string",
                        "format": "date-time"
                    },
                    "enqueued": {
                        "id": "schemas/common/timestamp",
                        "description": "Value is UTC timestamp in ISO 8601 YYYY-MM-DDThh:mm:ss.sZ or empty",
                        "type": "string",
                        "format": "date-time"
                    },
                    "idleSince": {
                        "id": "schemas/common/timestamp",
                        "description": "Value is UTC timestamp in ISO 8601 YYYY-MM-DDThh:mm:ss.sZ or empty",
                        "type": "string",
                        "format": "date-time"
                    },
                    "steps": {
                        "type": "integer"
                    },
                    "_cause": {
                        "id": "schemas/job/taskCause",
                        "description": "For order jobs only cause=order possible",
                        "javaType": "com.sos.joc.model.job.TaskCause",
                        "type": "string",
                        "enum": [
                            "NONE",
                            "MIN_TASKS",
                            "PERIOD_ONCE",
                            "PERIOD_SINGLE",
                            "PERIOD_REPEAT",
                            "QUEUE",
                            "QUEUE_AT",
                            "DIRECTORY",
                            "DELAY_AFTER_ERROR",
                            "ORDER"
                        ]
                    },
                    "order": {
                        "id": "schemas/job/orderOfTask",
                        "description": "Only relevant for order jobs; cause=order resp.",
                        "javaType": "com.sos.joc.model.job.OrderOfTask",
                        "type": "object",
                        "required": [
                            "path",
                            "orderId",
                            "jobChain",
                            "state"
                        ],
                        "properties": {
                            "path": {
                                "id": "schemas/common/path",
                                "description": "absolute path based on live folder of a JobScheduler object.",
                                "type": "string",
                                "pattern": "/([^/]+/)*[^/]+"
                            },
                            "orderId": {
                                "type": "string"
                            },
                            "jobChain": {
                                "id": "schemas/common/path",
                                "description": "absolute path based on live folder of a JobScheduler object.",
                                "type": "string",
                                "pattern": "/([^/]+/)*[^/]+"
                            },
                            "title": {
                                "type": "string"
                            },
                            "state": {
                                "description": "name of the current node",
                                "type": "string"
                            },
                            "inProcessSince": {
                                "id": "schemas/common/timestamp",
                                "description": "Value is UTC timestamp in ISO 8601 YYYY-MM-DDThh:mm:ss.sZ or empty",
                                "type": "string",
                                "format": "date-time"
                            }
                        }
                    }
                }
            }
        },
        "numOfQueuedTasks": {
            "id": "schemas/common/nonNegativeInteger",
            "type": "integer",
            "minimum": 0
        },
        "taskQueue": {
            "type": "array",
            "items": {
                "id": "schemas/job/queuedTask",
                "javaType": "com.sos.joc.model.job.QueuedTask",
                "type": "object",
                "required": [
                    "taskId",
                    "enqueued"
                ],
                "properties": {
                    "taskId": {
                        "type": "string"
                    },
                    "enqueued": {
                        "id": "schemas/common/timestamp",
                        "description": "Value is UTC timestamp in ISO 8601 YYYY-MM-DDThh:mm:ss.sZ or empty",
                        "type": "string",
                        "format": "date-time"
                    },
                    "plannedStart": {
                        "id": "schemas/common/timestamp",
                        "description": "Value is UTC timestamp in ISO 8601 YYYY-MM-DDThh:mm:ss.sZ or empty",
                        "type": "string",
                        "format": "date-time"
                    }
                }
            }
        },
        "params": {
            "id": "schemas/common/nameValuePairs",
            "type": "array",
            "items": {
                "javaType": "com.sos.joc.model.common.NameValuePair",
                "type": "object",
                "required": [
                    "name",
                    "value"
                ],
                "properties": {
                    "name": {
                        "type": "string"
                    },
                    "value": {
                        "type": "string"
                    }
                }
            }
        },
        "configurationStatus": {
            "id": "schemas/common/configurationStatus",
            "javaType": "com.sos.joc.model.common.ConfigurationState",
            "type": "object",
            "required": [
                "severity",
                "_text"
            ],
            "properties": {
                "severity": {
                    "description": "4=ok; 5=replacement_is_standing_by,removing_delayed; 2=error_in_configuration_file,changed_file_not_loaded,resource_is_missing",
                    "type": "integer"
                },
                "_text": {
                    "id": "schemas/common/configurationStatusText",
                    "javaType": "com.sos.joc.model.common.ConfigurationStateText",
                    "type": "string",
                    "enum": [
                        "ERROR_IN_CONFIGURATION_FILE",
                        "CHANGED_FILE_NOT_LOADED",
                        "REMOVING_DELAYED",
                        "RESOURCE_IS_MISSING",
                        "REPLACEMENT_IS_STANDING_BY",
                        "OK"
                    ]
                },
                "message": {
                    "description": "contains e.g. error message",
                    "type": "string"
                }
            }
        },
        "error": {
            "id": "schemas/common/error",
            "javaType": "com.sos.joc.model.common.Err",
            "type": "object",
            "required": [
                "code",
                "message"
            ],
            "properties": {
                "code": {
                    "type": "string"
                },
                "message": {
                    "type": "string"
                }
            }
        },
        "ordersSummary": {
            "id": "schemas/order/ordersSummary",
            "description": "only relevant for order jobs and is empty if job's order queue is empty",
            "javaType": "com.sos.joc.model.order.OrdersSummary",
            "type": "object",
            "properties": {
                "pending": {
                    "id": "schemas/common/nonNegativeInteger",
                    "type": "integer",
                    "minimum": 0
                },
                "running": {
                    "id": "schemas/common/nonNegativeInteger",
                    "type": "integer",
                    "minimum": 0
                },
                "suspended": {
                    "id": "schemas/common/nonNegativeInteger",
                    "type": "integer",
                    "minimum": 0
                },
                "setback": {
                    "id": "schemas/common/nonNegativeInteger",
                    "type": "integer",
                    "minimum": 0
                },
                "waitingForResource": {
                    "id": "schemas/common/nonNegativeInteger",
                    "type": "integer",
                    "minimum": 0
                },
                "blacklist": {
                    "id": "schemas/common/nonNegativeInteger",
                    "type": "integer",
                    "minimum": 0
                }
            }
        },
        "nextStartTime": {
            "id": "schemas/common/timestamp",
            "description": "Value is UTC timestamp in ISO 8601 YYYY-MM-DDThh:mm:ss.sZ or empty",
            "type": "string",
            "format": "date-time"
        },
        "nextStartNever": {
            "type": "boolean"
        },
        "delayUntil": {
            "id": "schemas/common/timestamp",
            "description": "Value is UTC timestamp in ISO 8601 YYYY-MM-DDThh:mm:ss.sZ or empty",
            "type": "string",
            "format": "date-time"
        },
        "runTimeIsTemporary": {
            "type": "boolean",
            "default": false
        }
    }
}