{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://catalog.lintel.tools/schemas/schemastore/azure-device-update-for-iot-hub-update-manifest/versions/4.json",
  "title": "JSON Schema for Azure Device Update for IoT Hub 'Update Manifest' version 4.0",
  "description": "JSON schema of update manifest sent by Device Update for IoT Hub to device agent during deployment.",
  "x-lintel": {
    "source": "https://www.schemastore.org/azure-deviceupdate-update-manifest-4.json",
    "sourceSha256": "79c7a50e57962de74162c01082fdf2d40e1abcc00f44c56b128667c0a55d057c",
    "fileMatch": [
      "*.updatemanifest.json"
    ],
    "parsers": [
      "json"
    ]
  },
  "type": "object",
  "properties": {
    "$schema": {
      "type": "string",
      "description": "JSON schema reference"
    },
    "updateId": {
      "$ref": "https://catalog.lintel.tools/schemas/schemastore/azure-device-update-for-iot-hub-update-manifest/_shared/4--azure-deviceupdate-manifest-definitions-4.0.json#/$defs/updateId"
    },
    "manifestVersion": {
      "type": "string",
      "title": "Update manifest schema version",
      "const": "4"
    }
  },
  "examples": [
    {
      "manifestVersion": "4",
      "updateId": {
        "provider": "Microsoft",
        "name": "Toaster",
        "version": "1.0"
      },
      "compatibility": [
        {
          "deviceManufacturer": "Microsoft",
          "deviceModel": "Toaster"
        }
      ],
      "instructions": {
        "steps": [
          {
            "handler": "microsoft/script:1",
            "handlerProperties": {
              "arguments": "--pre-install"
            },
            "files": [
              "fileId0"
            ]
          },
          {
            "type": "reference",
            "detachedManifestFileId": "fileId1"
          }
        ]
      },
      "files": {
        "fileId0": {
          "filename": "configure.sh",
          "sizeInBytes": 718,
          "hashes": {
            "sha256": "mcB5SexMU4JOOzqmlJqKbue9qMskWY3EI/iVjJxCtAs="
          }
        },
        "fileId1": {
          "filename": "microsoft.sensor.1.0.updatemanifest.json",
          "sizeInBytes": 2048,
          "hashes": {
            "sha256": "789s9PDfX4uA9wFUubyC30BWkLFbgmpkpmz1fEdqo2U="
          }
        }
      },
      "createdDateTime": "2021-09-28T18:32:01.8404544Z"
    }
  ],
  "$defs": {
    "miniUpdateManifest": {
      "type": "object",
      "title": "Mini update manifest",
      "description": "Manifest containing metadata of the detached, downloadable, complete update manifest.",
      "properties": {
        "detachedManifestFileId": {
          "$ref": "#/$defs/fileId"
        },
        "files": {
          "type": "object",
          "title": "Update manifest file",
          "description": "Map of '#/definitions/fileId' to file metadata.",
          "maxProperties": 1,
          "minProperties": 1,
          "additionalProperties": {
            "$ref": "https://catalog.lintel.tools/schemas/schemastore/azure-device-update-for-iot-hub-update-manifest/_shared/4--azure-deviceupdate-manifest-definitions-4.0.json#/$defs/file"
          }
        }
      },
      "required": [
        "detachedManifestFileId",
        "files"
      ]
    },
    "fullUpdateManifest": {
      "type": "object",
      "title": "Complete update manifest.",
      "description": "Full update manifest containing metadata of the update being deployed.",
      "properties": {
        "compatibility": {
          "$ref": "https://catalog.lintel.tools/schemas/schemastore/azure-device-update-for-iot-hub-update-manifest/_shared/4--azure-deviceupdate-manifest-definitions-4.0.json#/$defs/compatibility"
        },
        "instructions": {
          "type": "object",
          "title": "Installation instructions",
          "properties": {
            "steps": {
              "type": "array",
              "title": "Installation steps",
              "items": {
                "anyOf": [
                  {
                    "$ref": "#/$defs/inlineStep"
                  },
                  {
                    "$ref": "#/$defs/referenceStep"
                  }
                ]
              },
              "minItems": 1,
              "maxItems": 10
            }
          },
          "required": [
            "steps"
          ]
        },
        "files": {
          "type": "object",
          "title": "Update files",
          "description": "Map of '#/definitions/fileId' to file metadata.",
          "maxProperties": 20,
          "minProperties": 1,
          "additionalProperties": {
            "$ref": "https://catalog.lintel.tools/schemas/schemastore/azure-device-update-for-iot-hub-update-manifest/_shared/4--azure-deviceupdate-manifest-definitions-4.0.json#/$defs/file"
          }
        },
        "createdDateTime": {
          "type": "string",
          "title": "Created date & time",
          "description": "Date & time update was created in ISO 8601 format.",
          "examples": [
            "2020-10-02T22:18:04.9446744Z"
          ]
        }
      },
      "required": [
        "compatibility",
        "instructions",
        "files",
        "createdDateTime"
      ]
    },
    "fileId": {
      "type": "string",
      "title": "Update file id",
      "description": "Server generated file identifier to be used for retrieving file metadata and download URL.",
      "minLength": 1
    },
    "inlineStep": {
      "type": "object",
      "title": "Inline installation step",
      "description": "Installation instruction step that performs code execution.",
      "properties": {
        "type": {
          "$ref": "https://catalog.lintel.tools/schemas/schemastore/azure-device-update-for-iot-hub-update-manifest/_shared/4--azure-deviceupdate-manifest-definitions-4.0.json#/$defs/inlineStepType"
        },
        "handler": {
          "$ref": "https://catalog.lintel.tools/schemas/schemastore/azure-device-update-for-iot-hub-update-manifest/_shared/4--azure-deviceupdate-manifest-definitions-4.0.json#/$defs/inlineStepHandler"
        },
        "files": {
          "type": "array",
          "title": "Step update files",
          "description": "'fileId' of update files that agent will pass to handler.",
          "items": {
            "$ref": "#/$defs/fileId"
          },
          "minItems": 1,
          "maxItems": 10
        },
        "handlerProperties": {
          "$ref": "https://catalog.lintel.tools/schemas/schemastore/azure-device-update-for-iot-hub-update-manifest/_shared/4--azure-deviceupdate-manifest-definitions-4.0.json#/$defs/inlineStepHandlerProperties"
        }
      },
      "required": [
        "handler",
        "files"
      ],
      "additionalProperties": false
    },
    "referenceStep": {
      "type": "object",
      "title": "Reference installation step",
      "description": "Installation instruction step that installs another update.",
      "properties": {
        "type": {
          "$ref": "https://catalog.lintel.tools/schemas/schemastore/azure-device-update-for-iot-hub-update-manifest/_shared/4--azure-deviceupdate-manifest-definitions-4.0.json#/$defs/referenceStepType"
        },
        "detachedManifestFileId": {
          "$ref": "#/$defs/fileId"
        }
      },
      "required": [
        "type",
        "detachedManifestFileId"
      ],
      "additionalProperties": false
    }
  },
  "oneOf": [
    {
      "$ref": "#/$defs/miniUpdateManifest"
    },
    {
      "$ref": "#/$defs/fullUpdateManifest"
    }
  ],
  "required": [
    "updateId",
    "manifestVersion"
  ]
}
