{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://catalog.lintel.tools/schemas/schemastore/azure-device-update-for-iot-hub-update-manifest/_shared/latest--azure-deviceupdate-manifest-definitions-5.0.json",
  "title": "JSON Schema Definitions for Azure Device Update for IoT Hub Manifests version 5.0",
  "description": "Shared schema definitions for 'Import Manifest' and 'Update Manifest'.",
  "x-lintel": {
    "source": "https://www.schemastore.org/azure-deviceupdate-manifest-definitions-5.0.json",
    "sourceSha256": "b32651d630a996773a2705e0de4dd768952320c5c12426b5fff65d8231d160b7"
  },
  "type": "object",
  "$defs": {
    "updateId": {
      "type": "object",
      "title": "Update identity",
      "description": "Unique update identifier.",
      "properties": {
        "provider": {
          "type": "string",
          "title": "Update provider",
          "description": "Entity who is creating or directly responsible for the update. It can be a company name.",
          "minLength": 1,
          "maxLength": 64,
          "pattern": "^[a-zA-Z0-9.-]+$"
        },
        "name": {
          "type": "string",
          "title": "Update name",
          "description": "Identifier for a class of update. It can be a device class or model name.",
          "minLength": 1,
          "maxLength": 64,
          "pattern": "^[a-zA-Z0-9.-]+$"
        },
        "version": {
          "type": "string",
          "title": "Update version",
          "description": "Two to four part dot separated numerical version numbers. Each part must be a number between 0 and 2147483647 and leading zeroes will be dropped.",
          "pattern": "^\\d+(?:\\.\\d+)+$",
          "examples": [
            "1.0",
            "2021.11.8"
          ]
        }
      },
      "required": [
        "provider",
        "name",
        "version"
      ],
      "additionalProperties": false
    },
    "compatibility": {
      "type": "array",
      "title": "Update compatibility",
      "description": "List of device property sets this update is compatible with.",
      "items": {
        "$ref": "https://catalog.lintel.tools/schemas/schemastore/azure-device-update-for-iot-hub-update-manifest/_shared/latest--azure-deviceupdate-manifest-definitions-5.0.json#/$defs/compatibilityInfo"
      },
      "minItems": 1,
      "maxItems": 10
    },
    "compatibilityInfo": {
      "type": "object",
      "title": "Update compatibility info",
      "description": "Properties of a device this update is compatible with.",
      "maxProperties": 5,
      "minProperties": 1,
      "additionalProperties": {
        "type": "string",
        "minLength": 1,
        "maxLength": 64,
        "propertyNames": {
          "minLength": 1,
          "maxLength": 32
        }
      }
    },
    "baseFile": {
      "type": "object",
      "title": "Basic update file information",
      "description": "Update payload file, e.g. binary, firmware, script, etc. Must be unique within update.",
      "properties": {
        "filename": {
          "$ref": "https://catalog.lintel.tools/schemas/schemastore/azure-device-update-for-iot-hub-update-manifest/_shared/latest--azure-deviceupdate-manifest-definitions-5.0.json#/$defs/filename"
        },
        "sizeInBytes": {
          "type": "number",
          "title": "File size",
          "description": "File size in number of bytes.",
          "minimum": 1,
          "maximum": 2147483648
        },
        "hashes": {
          "$ref": "https://catalog.lintel.tools/schemas/schemastore/azure-device-update-for-iot-hub-update-manifest/_shared/latest--azure-deviceupdate-manifest-definitions-5.0.json#/$defs/fileHashes"
        },
        "properties": {
          "type": "object",
          "description": "Optional file properties (not consumed by service but pass-through to device).",
          "additionalProperties": true
        }
      },
      "required": [
        "filename",
        "sizeInBytes",
        "hashes"
      ]
    },
    "file": {
      "type": "object",
      "title": "Update file",
      "description": "Update payload file, e.g. binary, firmware, script, etc. Must be unique within update.",
      "allOf": [
        {
          "$ref": "#/$defs/baseFile"
        }
      ],
      "properties": {
        "relatedFiles": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/baseFile"
          },
          "minItems": 0,
          "maxItems": 4,
          "description": "Optional related files metadata used together with DownloadHandler metadata to download payload file."
        },
        "downloadHandler": {
          "$ref": "#/$defs/fileDownloadHandler",
          "description": "Optional download handler for utilizing related files to download payload file."
        }
      }
    },
    "filename": {
      "type": "string",
      "title": "Update file name",
      "description": "Update payload file name.",
      "minLength": 1,
      "maxLength": 255
    },
    "fileHashes": {
      "type": "object",
      "title": "File hashes",
      "description": "Base64-encoded file hashes with algorithm name as key. At least SHA-256 algorithm must be specified, and additional algorithm may be specified if supported by agent.",
      "properties": {
        "sha256": {
          "type": "string",
          "title": "SHA-256 hash value",
          "description": "Base64-encoded file hash value using SHA-256 algorithm."
        }
      },
      "required": [
        "sha256"
      ],
      "maxProperties": 2,
      "additionalProperties": {
        "type": "string",
        "propertyNames": {
          "maxLength": 10
        }
      }
    },
    "fileDownloadHandler": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "Download handler identifier.",
          "pattern": "^\\S+/\\S+:\\d{1,5}$",
          "minLength": 5,
          "maxLength": 32,
          "examples": [
            "microsoft/delta:1"
          ]
        }
      },
      "required": [
        "id"
      ],
      "description": "Download handler for utilizing related files to download payload file."
    },
    "referenceStepType": {
      "type": "string",
      "title": "'Reference' step type",
      "description": "Instruction step type that installs another update.",
      "const": "reference"
    },
    "inlineStepType": {
      "type": "string",
      "title": "'Inline' step type",
      "description": "Instruction step type that performs code execution.",
      "const": "inline"
    },
    "inlineStepHandler": {
      "type": "string",
      "title": "Step handler",
      "description": "Identity of handler on device that can execute this step.",
      "pattern": "^\\S+/\\S+:\\d{1,5}$",
      "minLength": 5,
      "maxLength": 32,
      "examples": [
        "microsoft/script:1",
        "microsoft/swupdate:1",
        "microsoft/apt:1"
      ]
    },
    "inlineStepHandlerProperties": {
      "type": "object",
      "title": "Handler properties",
      "description": "JSON object that agent will pass to handler as arguments.",
      "additionalProperties": true
    }
  }
}
