{
   "$schema": "http://json-schema.org/draft-07/schema#",
   "$ref":"#/definitions/DomainConnectTemplate",
   "definitions":{
      "DomainConnectTemplate":{
         "title":"DomainConnectTemplate",
         "type":"object",
         "properties":{
            "providerId":{
               "type":"string"
            },
            "providerName":{
               "type":"string"
            },
            "serviceId":{
               "type":"string"
            },
            "serviceName":{
               "type":"string"
            },
            "version":{
               "type":"integer"
            },
            "logoUrl":{
               "type":"string",
               "qt-uri-protocols":[
                  "http",
                  "https"
               ],
               "qt-uri-extensions":[
                  ".jpg",
                  ".png",
                  ".svg"
               ]
            },
            "description":{
               "type":"string"
            },
            "variableDescription":{
               "type":"string"
            },
            "syncBlock":{
               "type":"boolean"
            },
            "shared":{
               "type":"boolean"
            },
            "sharedProviderName":{
               "type":"boolean"
            },
            "sharedServiceName":{
               "type":"boolean"
            },
            "syncRedirectDomain":{
               "type":"string"
            },
            "syncPubKeyDomain":{
               "type":"string"
            },
            "multiInstance":{
               "type":"boolean"
            },
            "warnPhishing":{
               "type":"boolean"
            },
            "hostRequired":{
               "type":"boolean"
            },
            "records":{
               "type":"array",
               "items":{
                  "$ref":"#/definitions/Record"
               }
            }
         },
         "required":[
            "providerId",
            "providerName",
            "serviceId",
            "serviceName",
            "records"
         ],
         "anyOf":[
            {
               "not":{
                  "$ref":"#/definitions/DomainConnectTemplateWithHostRequired"
               }
            },
            {
               "properties":{
                  "hostRequired":{
                     "type":"boolean",
                     "const":true
                  }
               },
               "required":[
                  "hostRequired"
               ]
            }
         ]
      },
      "DomainConnectTemplateWithHostRequired":{
         "properties":{
            "records":{
               "contains":{
                  "properties":{
                     "type":{
                        "enum":[
                           "NS",
                           "CNAME"
                        ]
                     },
                     "host":{
                        "enum":[
                           "@",
                           ""
                        ]
                     }
                  }
               }
            }
         },
         "title":"DomainConnectTemplate with required host"
      },
      "Record":{
         "anyOf":[
            {
               "$ref":"#/definitions/Record-A"
            },
            {
               "$ref":"#/definitions/Record-AAAA"
            },
            {
               "$ref":"#/definitions/Record-CNAME"
            },
            {
               "$ref":"#/definitions/Record-NS"
            },
            {
               "$ref":"#/definitions/Record-TXT"
            },
            {
               "$ref":"#/definitions/Record-MX"
            },
            {
               "$ref":"#/definitions/Record-SPFM"
            },
            {
               "$ref":"#/definitions/Record-SRV"
            },
            {
               "$ref":"#/definitions/Record-ANY"
            },
            {
               "$ref":"#/definitions/Record-REDIR301"
            },
            {
               "$ref":"#/definitions/Record-REDIR302"
            },
            {
               "$ref":"#/definitions/Record-APEXCNAME"
            }
         ]
      },
      "Record-All":{
         "type":"object",
         "properties":{
            "groupId":{
               "type":"string"
            },
            "essential":{
               "type":"string"
            }
         },
         "title":"All Records"
      },
      "Record-A":{
         "allOf":[
            {
               "$ref":"#/definitions/Record-All"
            },
            {
               "properties":{
                  "type":{
                     "type":"string",
                     "const":"A"
                  },
                  "host":{
                     "type":"string"
                  },
                  "pointsTo":{
                     "type":"string"
                  },
                  "ttl":{
                     "$ref":"#/definitions/Number_or_NumberInString_or_Variable"
                  }
               },
               "required":[
                  "type",
                  "host",
                  "pointsTo",
                  "ttl"
               ],
               "title":"A Record"
            }
         ]
      },
      "Record-AAAA":{
         "allOf":[
            {
               "$ref":"#/definitions/Record-All"
            },
            {
               "properties":{
                  "type":{
                     "type":"string",
                     "const":"AAAA"
                  },
                  "host":{
                     "type":"string"
                  },
                  "pointsTo":{
                     "type":"string"
                  },
                  "ttl":{
                     "$ref":"#/definitions/Number_or_NumberInString_or_Variable"
                  }
               },
               "required":[
                  "type",
                  "host",
                  "pointsTo",
                  "ttl"
               ],
               "title":"AAAA Record"
            }
         ]
      },
      "Record-CNAME":{
         "allOf":[
            {
               "$ref":"#/definitions/Record-All"
            },
            {
               "properties":{
                  "type":{
                     "type":"string",
                     "const":"CNAME"
                  },
                  "host":{
                     "type":"string"
                  },
                  "pointsTo":{
                     "type":"string"
                  },
                  "ttl":{
                     "$ref":"#/definitions/Number_or_NumberInString_or_Variable"
                  }
               },
               "required":[
                  "type",
                  "host",
                  "pointsTo",
                  "ttl"
               ],
               "title":"CNAME Record"
            }
         ]
      },
      "Record-NS":{
         "allOf":[
            {
               "$ref":"#/definitions/Record-All"
            },
            {
               "properties":{
                  "type":{
                     "type":"string",
                     "const":"NS"
                  },
                  "host":{
                     "type":"string"
                  },
                  "pointsTo":{
                     "type":"string"
                  },
                  "ttl":{
                     "$ref":"#/definitions/Number_or_NumberInString_or_Variable"
                  }
               },
               "required":[
                  "type",
                  "host",
                  "pointsTo",
                  "ttl"
               ],
               "title":"NS Record"
            }
         ]
      },
      "Record-TXT":{
         "allOf":[
            {
               "$ref":"#/definitions/Record-All"
            },
            {
               "properties":{
                  "type":{
                     "type":"string",
                     "const":"TXT"
                  },
                  "host":{
                     "type":"string"
                  },
                  "ttl":{
                     "$ref":"#/definitions/Number_or_NumberInString_or_Variable"
                  },
                  "data":{
                     "type":"string"
                  },
                  "txtConflictMatchingMode":{
                     "type":"string"
                  },
                  "txtConflictMatchingPrefix":{
                     "type":"string"
                  }
               },
               "required":[
                  "type",
                  "host",
                  "data",
                  "ttl"
               ],
               "title":"TXT Record"
            }
         ]
      },
      "Record-ANY":{
         "allOf":[
            {
               "$ref":"#/definitions/Record-All"
            },
            {
                "not": {
                    "properties":{
                        "type":{
                            "type":"string",
                            "enum": ["A", "AAAA", "CNAME", "NS", "TXT", "MX", "SRV", "SPFM", "APEXCNAME", "REDIR301", "REDIR302"]
                        }
                    }
                }
            },
            {
               "properties":{
                  "type":{
                     "type":"string"
                  },
                  "host":{
                     "type":"string"
                  },
                  "ttl":{
                     "$ref":"#/definitions/Number_or_NumberInString_or_Variable"
                  },
                  "data":{
                     "type":"string"
                  }
               },
               "required":[
                  "type",
                  "host",
                  "data",
                  "ttl"
               ],
               "title":"ANY Record"
            }
         ]
      },
      "Record-MX":{
         "allOf":[
            {
               "$ref":"#/definitions/Record-All"
            },
            {
               "properties":{
                  "type":{
                     "type":"string",
                     "const":"MX"
                  },
                  "host":{
                     "type":"string"
                  },
                  "pointsTo":{
                     "type":"string"
                  },
                  "ttl":{
                     "$ref":"#/definitions/Number_or_NumberInString_or_Variable"
                  },
                  "priority":{
                     "$ref":"#/definitions/Number_or_NumberInString_or_Variable"
                  }
               },
               "required":[
                  "type",
                  "host",
                  "pointsTo",
                  "priority",
                  "ttl"
               ],
               "title":"MX Record"
            }
         ]
      },
      "Record-SPFM":{
         "allOf":[
            {
               "$ref":"#/definitions/Record-All"
            },
            {
               "properties":{
                  "type":{
                     "type":"string",
                     "const":"SPFM"
                  },
                  "host":{
                     "type":"string"
                  },
                  "spfRules":{
                     "type":"string"
                  }
               },
               "required":[
                  "type",
                  "host",
                  "spfRules"
               ],
               "title":"SPFM Record"
            }
         ]
      },
      "Record-SRV":{
         "allOf":[
            {
               "$ref":"#/definitions/Record-All"
            },
            {
               "properties":{
                  "type":{
                     "type":"string",
                     "const":"SRV"
                  },
                  "name":{
                     "type":"string"
                  },
                  "target":{
                     "type":"string"
                  },
                  "ttl":{
                     "$ref":"#/definitions/Number_or_NumberInString_or_Variable"
                  },
                  "priority":{
                     "$ref":"#/definitions/Number_or_NumberInString_or_Variable"
                  },
                  "protocol":{
                     "type":"string"
                  },
                  "service":{
                     "type":"string"
                  },
                  "weight":{
                     "$ref":"#/definitions/Number_or_NumberInString_or_Variable"
                  },
                  "port":{
                     "$ref":"#/definitions/Number_or_NumberInString_or_Variable"
                  }
               },
               "required":[
                  "type",
                  "name",
                  "target",
                  "priority",
                  "protocol",
                  "service",
                  "weight",
                  "port",
                  "ttl"
               ],
               "title":"SRV Record"
            }
         ]
      },
      "Record-REDIR301":{
         "allOf":[
            {
               "$ref":"#/definitions/Record-All"
            },
            {
               "properties":{
                  "type":{
                     "type":"string",
                     "const":"REDIR301"
                  },
                  "host":{
                     "type":"string"
                  },
                  "target":{
                     "type":"string"
                  }
               },
               "required":[
                  "type",
                  "target"
               ],
               "title":"REDIR301 Record"
            }
         ]
      },
      "Record-REDIR302":{
         "allOf":[
            {
               "$ref":"#/definitions/Record-All"
            },
            {
               "properties":{
                  "type":{
                     "type":"string",
                     "const":"REDIR302"
                  },
                  "host":{
                     "type":"string"
                  },
                  "target":{
                     "type":"string"
                  }
               },
               "required":[
                  "type",
                  "target"
               ],
               "title":"REDIR302 Record"
            }
         ]
      },
      "Record-APEXCNAME":{
         "allOf":[
            {
               "$ref":"#/definitions/Record-All"
            },
            {
               "properties":{
                  "type":{
                     "type":"string",
                     "const":"APEXCNAME"
                  },
                  "pointsTo":{
                     "type":"string"
                  },
                  "ttl":{
                     "$ref":"#/definitions/Number_or_NumberInString_or_Variable"
                  }
               },
               "required":[
                  "type",
                  "pointsTo",
                  "ttl"
               ],
               "title":"APEXCNAME Record"
            }
         ]
      },
      "Number_or_NumberInString_or_Variable":{
         "oneOf":[
            {
               "type":"integer"
            },
            {
               "type":"string",
               "pattern":"\\d"
            },
            {
               "type":"string",
               "pattern":"%[^%]+%"
            }
         ],
         "title":"Number or Number as String or Variable as String"
      }
   }
}