{
  "$id": "https://json.schemastore.org/azure-iot-edge-deployment-template-1.0.json",
  "$schema": "http://json-schema.org/draft-07/schema#",
  "definitions": {
    "moduleType": {
      "$ref": "https://json.schemastore.org/azure-iot-edge-deployment-1.0.json#/definitions/moduleType"
    },
    "status": {
      "$ref": "https://json.schemastore.org/azure-iot-edge-deployment-1.0.json#/definitions/status"
    },
    "restartPolicy": {
      "$ref": "https://json.schemastore.org/azure-iot-edge-deployment-1.0.json#/definitions/restartPolicy"
    },
    "moduleSettings": {
      "type": "object",
      "required": ["image"],
      "properties": {
        "image": {
          "type": "string",
          "examples": ["mcr.microsoft.com/azureiotedge-agent:1.0"]
        },
        "createOptions": {
          "$ref": "#/definitions/createOptions"
        }
      }
    },
    "env": {
      "$ref": "https://json.schemastore.org/azure-iot-edge-deployment-1.0.json#/definitions/env"
    },
    "createOptions": {
      "type": ["object", "string"],
      "contentMediaType": "application/json"
    }
  },
  "properties": {
    "modulesContent": {
      "type": "object",
      "title": "The configuration for all the modules.",
      "required": ["$edgeAgent", "$edgeHub"],
      "properties": {
        "$edgeAgent": {
          "type": "object",
          "title": "Configuration for the edgeAgent module",
          "required": ["properties.desired"],
          "properties": {
            "properties.desired": {
              "type": "object",
              "required": [
                "schemaVersion",
                "runtime",
                "systemModules",
                "modules"
              ],
              "properties": {
                "schemaVersion": {
                  "type": "string",
                  "examples": ["1.0"]
                },
                "runtime": {
                  "$ref": "https://json.schemastore.org/azure-iot-edge-deployment-1.0.json#/properties/modulesContent/properties/$edgeAgent/properties/properties.desired/properties/runtime"
                },
                "systemModules": {
                  "type": "object",
                  "required": ["edgeAgent", "edgeHub"],
                  "properties": {
                    "edgeAgent": {
                      "type": "object",
                      "required": ["type", "settings"],
                      "properties": {
                        "type": {
                          "$ref": "#/definitions/moduleType"
                        },
                        "settings": {
                          "$ref": "#/definitions/moduleSettings"
                        },
                        "env": {
                          "$ref": "#/definitions/env"
                        }
                      }
                    },
                    "edgeHub": {
                      "type": "object",
                      "title": "The Edgehub Schema",
                      "required": [
                        "type",
                        "settings",
                        "status",
                        "restartPolicy"
                      ],
                      "properties": {
                        "type": {
                          "$ref": "#/definitions/moduleType"
                        },
                        "settings": {
                          "$ref": "#/definitions/moduleSettings"
                        },
                        "env": {
                          "$ref": "#/definitions/env"
                        },
                        "status": {
                          "$ref": "#/definitions/status"
                        },
                        "restartPolicy": {
                          "$ref": "#/definitions/restartPolicy"
                        }
                      }
                    }
                  },
                  "additionalProperties": false
                },
                "modules": {
                  "type": "object",
                  "patternProperties": {
                    "^[a-zA-Z0-9_-]+$": {
                      "type": "object",
                      "required": [
                        "type",
                        "status",
                        "restartPolicy",
                        "settings"
                      ],
                      "properties": {
                        "version": {
                          "type": "string",
                          "examples": ["1.0"]
                        },
                        "type": {
                          "$ref": "#/definitions/moduleType"
                        },
                        "status": {
                          "$ref": "#/definitions/status"
                        },
                        "restartPolicy": {
                          "$ref": "#/definitions/restartPolicy"
                        },
                        "env": {
                          "$ref": "#/definitions/env"
                        },
                        "settings": {
                          "$ref": "#/definitions/moduleSettings"
                        }
                      }
                    }
                  },
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "$edgeHub": {
          "$ref": "https://json.schemastore.org/azure-iot-edge-deployment-1.0.json#/properties/modulesContent/properties/$edgeHub"
        }
      },
      "patternProperties": {
        "^[a-zA-Z0-9_-]+$": {
          "type": "object",
          "required": ["properties.desired"],
          "properties": {
            "properties.desired": {
              "type": "object"
            }
          }
        }
      },
      "additionalProperties": false
    }
  },
  "required": ["modulesContent"],
  "title": "JSON schema for Azure IoT Edge Deployment Template version 1.0",
  "type": "object"
}
