{
  "$id": "https://opendatafabric.org/schemas/tasks/v1alpha1/TaskOutcome",
  "$schema": "https://opendatafabric.org/schemas/resources/v1alpha1/meta/ResourceCondition",
  "description": "Result of the execution of a task.",
  "$defs": {
    "Success": {
      "description": "Task completed successfully.",
      "type": "object",
      "patternProperties": {
        ".*": {}
      }
    },
    "Failed": {
      "description": "Task failed.",
      "type": "object",
      "required": [
        "message",
        "recoverable"
      ],
      "properties": {
        "message": {
          "type": "string",
          "description": "Human-readable description of the failure."
        },
        "recoverable": {
          "type": "boolean",
          "description": "Whether retrying the task could succeed, e.g. after a network error. An unrecoverable failure, such as an invalid query, would fail the same way again."
        },
        "error": {
          "$ref": "https://opendatafabric.org/schemas/tasks/v1alpha1/TaskError",
          "description": "Type-specific details of the failure.",
          "unevaluatedProperties": false
        }
      }
    },
    "NoOp": {
      "description": "Task completed with no work done (e.g. no new data to process).",
      "type": "object",
      "required": [],
      "properties": {}
    },
    "Cancelled": {
      "description": "Task was cancelled before completion.",
      "type": "object",
      "required": [],
      "properties": {}
    }
  },
  "oneOf": [
    {
      "allOf": [
        { "properties": { "kind": { "type": "string", "const": "Success" } }, "required": ["kind"] },
        { "$ref": "#/$defs/Success" }
      ]
    },
    {
      "allOf": [
        { "properties": { "kind": { "type": "string", "const": "Failed" } }, "required": ["kind"] },
        { "$ref": "#/$defs/Failed" }
      ]
    },
    {
      "allOf": [
        { "properties": { "kind": { "type": "string", "const": "NoOp" } }, "required": ["kind"] },
        { "$ref": "#/$defs/NoOp" }
      ]
    },
    {
      "allOf": [
        { "properties": { "kind": { "type": "string", "const": "Cancelled" } }, "required": ["kind"] },
        { "$ref": "#/$defs/Cancelled" }
      ]
    }
  ]
}
