{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://json.schemastore.org/azure-deviceupdate-import-manifest-5.0.json",
  "definitions": {
    "instructions": {
      "type": "object",
      "title": "Installation instructions",
      "description": "Update installation instructions.",
      "properties": {
        "steps": {
          "type": "array",
          "title": "Installation steps",
          "items": {
            "anyOf": [
              {
                "$ref": "#/definitions/inlineStep"
              },
              {
                "$ref": "#/definitions/referenceStep"
              }
            ]
          },
          "minItems": 1,
          "maxItems": 10
        }
      },
      "additionalProperties": false,
      "required": ["steps"]
    },
    "stepDescription": {
      "type": "string",
      "title": "Step description",
      "description": "Optional instruction step description.",
      "minLength": 1,
      "maxLength": 64
    },
    "inlineStep": {
      "type": "object",
      "title": "Inline installation step",
      "description": "Installation instruction step that performs code execution.",
      "properties": {
        "type": {
          "$ref": "azure-deviceupdate-manifest-definitions-5.0.json#/definitions/inlineStepType"
        },
        "description": {
          "$ref": "#/definitions/stepDescription"
        },
        "handler": {
          "$ref": "azure-deviceupdate-manifest-definitions-5.0.json#/definitions/inlineStepHandler"
        },
        "files": {
          "type": "array",
          "title": "Step update files",
          "description": "Names of update files that agent will pass to handler.",
          "items": {
            "$ref": "azure-deviceupdate-manifest-definitions-5.0.json#/definitions/filename"
          },
          "minItems": 1,
          "maxItems": 10
        },
        "handlerProperties": {
          "$ref": "azure-deviceupdate-manifest-definitions-5.0.json#/definitions/inlineStepHandlerProperties"
        }
      },
      "additionalProperties": false,
      "required": ["handler", "files"]
    },
    "referenceStep": {
      "type": "object",
      "title": "Reference installation step",
      "description": "Installation instruction step that installs another update.",
      "properties": {
        "type": {
          "$ref": "azure-deviceupdate-manifest-definitions-5.0.json#/definitions/referenceStepType"
        },
        "description": {
          "$ref": "#/definitions/stepDescription"
        },
        "updateId": {
          "$ref": "azure-deviceupdate-manifest-definitions-5.0.json#/definitions/updateId"
        }
      },
      "additionalProperties": false,
      "required": ["type", "updateId"]
    }
  },
  "description": "Schema for import manifest used for importing an update to Device Update for IoT Hub.",
  "examples": [
    {
      "updateId": {
        "provider": "Microsoft",
        "name": "Toaster",
        "version": "1.0"
      },
      "description": "Example update",
      "compatibility": [
        {
          "deviceManufacturer": "Microsoft",
          "deviceModel": "Toaster"
        }
      ],
      "instructions": {
        "steps": [
          {
            "description": "pre-install script",
            "handler": "microsoft/script:1",
            "handlerProperties": {
              "arguments": "--pre-install"
            },
            "files": ["configure.sh"]
          },
          {
            "type": "reference",
            "updateId": {
              "provider": "Microsoft",
              "name": "Sensor",
              "version": "1.0"
            }
          }
        ]
      },
      "files": [
        {
          "filename": "configure.sh",
          "sizeInBytes": 718,
          "hashes": {
            "sha256": "mcB5SexMU4JOOzqmlJqKbue9qMskWY3EI/iVjJxCtAs="
          },
          "relatedFiles": [
            {
              "filename": "in1_in2_deltaupdate.dat",
              "sizeInBytes": 102910752,
              "hashes": {
                "sha256": "2MIldV8LkdKenjJasgTHuYi+apgtNQ9FeL2xsV3ikHY="
              },
              "properties": {
                "microsoft.sourceFileHashAlgorithm": "sha256",
                "microsoft.sourceFileHash": "YmFYwnEUddq2nZsBAn5v7gCRKdHx+TUntMz5tLwU+24="
              }
            }
          ],
          "downloadHandler": {
            "id": "microsoft/delta:1"
          }
        }
      ],
      "manifestVersion": "5.0",
      "createdDateTime": "2020-10-02T22:18:04.9446744Z"
    }
  ],
  "properties": {
    "$schema": {
      "type": "string",
      "description": "JSON schema reference."
    },
    "updateId": {
      "$ref": "azure-deviceupdate-manifest-definitions-5.0.json#/definitions/updateId"
    },
    "description": {
      "type": "string",
      "title": "Update description",
      "description": "Optional update description.",
      "minLength": 1,
      "maxLength": 512
    },
    "compatibility": {
      "$ref": "azure-deviceupdate-manifest-definitions-5.0.json#/definitions/compatibility"
    },
    "instructions": {
      "$ref": "#/definitions/instructions"
    },
    "files": {
      "type": "array",
      "title": "Update files",
      "description": "List of update payload files. Sum of all file sizes may not exceed 2 GB. May be empty or null if all instruction steps are reference steps.",
      "items": {
        "$ref": "azure-deviceupdate-manifest-definitions-5.0.json#/definitions/file"
      },
      "minItems": 0,
      "maxItems": 10
    },
    "manifestVersion": {
      "type": "string",
      "title": "Import manifest schema version",
      "description": "Import manifest schema version. Must be 5.0.",
      "const": "5.0"
    },
    "createdDateTime": {
      "type": "string",
      "title": "Created date & time",
      "description": "Date & time import manifest was created in ISO 8601 format.",
      "examples": ["2020-10-02T22:18:04.9446744Z"]
    }
  },
  "required": [
    "updateId",
    "compatibility",
    "instructions",
    "manifestVersion",
    "createdDateTime"
  ],
  "title": "JSON Schema for Azure Device Update for IoT Hub 'Import Manifest' version 5.0",
  "type": "object"
}
