{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://catalog.lintel.tools/schemas/schemastore/azure-iot-edge-deployment-template/_shared/latest--azure-iot-edgehub-deployment-1.2.json",
  "title": "JSON schema for Azure IoT EdgeHub Deployment version 1.2",
  "x-lintel": {
    "source": "https://json.schemastore.org/azure-iot-edgehub-deployment-1.2.json",
    "sourceSha256": "6556504630fe6b742dc7708d6833fbb92453636a870e1fb81d976bebba17ce1c"
  },
  "type": "object",
  "properties": {
    "$edgeHub": {
      "type": "object",
      "title": "Configuration for the edgeHub module",
      "required": [
        "properties.desired"
      ],
      "properties": {
        "properties.desired": {
          "type": "object",
          "required": [
            "schemaVersion",
            "routes"
          ],
          "properties": {
            "schemaVersion": {
              "type": "string",
              "pattern": "1.2"
            },
            "routes": {
              "type": "object",
              "additionalProperties": false,
              "patternProperties": {
                "^[^\\.\\$# ]+$": {
                  "anyOf": [
                    {
                      "type": "object",
                      "required": [
                        "route"
                      ],
                      "properties": {
                        "route": {
                          "type": "string",
                          "examples": [
                            "FROM /* INTO $upstream"
                          ],
                          "pattern": "^.+$"
                        },
                        "priority": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 9
                        },
                        "timeToLiveSecs": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 4294967295
                        }
                      },
                      "additionalProperties": false
                    },
                    {
                      "type": "string",
                      "examples": [
                        "FROM /* INTO $upstream"
                      ],
                      "pattern": "^.+$"
                    }
                  ]
                }
              }
            },
            "storeAndForwardConfiguration": {
              "type": "object",
              "required": [
                "timeToLiveSecs"
              ],
              "properties": {
                "timeToLiveSecs": {
                  "type": "integer",
                  "examples": [
                    7200
                  ]
                }
              },
              "additionalProperties": false
            },
            "mqttBroker": {
              "type": "object",
              "properties": {
                "bridges": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "endpoint": {
                        "type": "string",
                        "pattern": "\\$upstream"
                      },
                      "settings": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "direction": {
                              "type": "string",
                              "pattern": "^in$|^out$"
                            },
                            "topic": {
                              "type": "string",
                              "pattern": "^.*$"
                            },
                            "inPrefix": {
                              "type": "string",
                              "pattern": "^.*$"
                            },
                            "outPrefix": {
                              "type": "string",
                              "pattern": "^.*$"
                            }
                          },
                          "additionalProperties": false
                        }
                      }
                    },
                    "additionalProperties": false
                  }
                },
                "authorizations": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "identities": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "pattern": "^.+$",
                          "examples": [
                            "{{iot:identity}}",
                            "contoso.azure-devices.net/MyLeafDevice1",
                            "contoso.azure-devices.net/MyEdgeDevice/MyModule"
                          ]
                        }
                      },
                      "allow": {
                        "$ref": "#/$defs/policy"
                      },
                      "deny": {
                        "$ref": "#/$defs/policy"
                      }
                    },
                    "additionalProperties": false
                  }
                }
              },
              "additionalProperties": false
            }
          },
          "additionalProperties": false
        }
      },
      "additionalProperties": false
    }
  },
  "required": [
    "$edgeHub"
  ],
  "$defs": {
    "policy": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "operations": {
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^mqtt:connect$|^mqtt:subscribe$|^mqtt:publish$"
            }
          },
          "resources": {
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^.+$",
              "examples": [
                "$iothub/clients/+/twin/res/#",
                "events/alerts"
              ]
            }
          }
        },
        "additionalProperties": false
      }
    }
  },
  "additionalProperties": false,
  "id": "https://json.schemastore.org/azure-iot-edgehub-deployment-1.2.json"
}
