{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/open-government-portugal/json-schema/open-government-portugal-harvest-job-schema.json",
  "title": "HarvestJob",
  "x-generated": "2026-11-11",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/open-government-portugal-harvest-api-openapi.yml#/components/schemas/HarvestJob",
  "properties": {
    "created": {
      "description": "The job creation date",
      "format": "date-time",
      "type": "string"
    },
    "ended": {
      "description": "The job end date",
      "format": "date-time",
      "type": "string"
    },
    "errors": {
      "description": "The job initialization errors",
      "items": {
        "$ref": "#/$defs/HarvestError"
      },
      "type": "array"
    },
    "id": {
      "description": "The job execution ID",
      "type": "string"
    },
    "items": {
      "description": "The job collected items",
      "items": {
        "$ref": "#/$defs/HarvestItem"
      },
      "type": "array"
    },
    "source": {
      "description": "The source owning the job",
      "type": "string"
    },
    "started": {
      "description": "The job start date",
      "format": "date-time",
      "type": "string"
    },
    "status": {
      "description": "The job status",
      "enum": [
        "pending",
        "initializing",
        "initialized",
        "processing",
        "done",
        "done-errors",
        "failed"
      ],
      "type": "string"
    }
  },
  "required": [
    "created",
    "id",
    "source",
    "status"
  ],
  "type": "object",
  "$defs": {
    "BaseReference": {
      "properties": {
        "class": {
          "description": "The object class",
          "type": "string"
        },
        "id": {
          "description": "The object unique identifier",
          "type": "string"
        }
      },
      "required": [
        "class",
        "id"
      ],
      "type": "object"
    },
    "DataserviceReference": {
      "allOf": [
        {
          "$ref": "#/$defs/BaseReference"
        },
        {
          "properties": {
            "self_api_url": {
              "description": "Link to the API endpoint for this dataservice",
              "readOnly": true,
              "type": "string"
            },
            "self_web_url": {
              "description": "Link to the udata web page for this dataservice",
              "readOnly": true,
              "type": "string"
            },
            "title": {
              "type": "string"
            }
          },
          "required": [
            "title"
          ],
          "type": "object"
        }
      ]
    },
    "DatasetReference": {
      "allOf": [
        {
          "$ref": "#/$defs/BaseReference"
        },
        {
          "properties": {},
          "type": "object"
        }
      ]
    },
    "HarvestError": {
      "properties": {
        "level": {
          "type": "string"
        },
        "message": {
          "type": "string"
        }
      },
      "required": [
        "level",
        "message"
      ],
      "type": "object"
    },
    "HarvestItem": {
      "properties": {
        "args": {
          "default": [],
          "description": "The item positional arguments",
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        "created": {
          "description": "The item creation date",
          "format": "date-time",
          "type": "string"
        },
        "dataservice": {
          "allOf": [
            {
              "$ref": "#/$defs/DataserviceReference"
            }
          ],
          "description": "The processed dataservice"
        },
        "dataset": {
          "allOf": [
            {
              "$ref": "#/$defs/DatasetReference"
            }
          ],
          "description": "The processed dataset"
        },
        "ended": {
          "description": "The item end date",
          "format": "date-time",
          "type": "string"
        },
        "errors": {
          "description": "The item errors",
          "items": {
            "$ref": "#/$defs/HarvestError"
          },
          "type": "array"
        },
        "kwargs": {
          "default": {},
          "description": "The item keyword arguments",
          "type": "object"
        },
        "logs": {
          "description": "The item logs",
          "items": {
            "$ref": "#/$defs/HarvestError"
          },
          "type": "array"
        },
        "remote_id": {
          "description": "The item remote ID to process",
          "type": "string"
        },
        "remote_url": {
          "description": "The item remote url (if available)",
          "type": "string"
        },
        "started": {
          "description": "The item start date",
          "format": "date-time",
          "type": "string"
        },
        "status": {
          "description": "The item status",
          "enum": [
            "pending",
            "started",
            "done",
            "failed",
            "skipped",
            "archived"
          ],
          "type": "string"
        }
      },
      "required": [
        "created",
        "remote_id",
        "status"
      ],
      "type": "object"
    }
  }
}