{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "properties": {
    "apiVersion": {
      "type": "string"
    },
    "kind": {
      "type": "string"
    },
    "metadata": {
      "type": "object"
    },
    "spec": {
      "properties": {
        "allowCrossNamespaceImport": {
          "default": false,
          "type": "boolean"
        },
        "editable": {
          "type": "boolean",
          "x-kubernetes-validations": [
            {
              "message": "Value is immutable",
              "rule": "self == oldSelf"
            }
          ]
        },
        "folderRef": {
          "type": "string",
          "x-kubernetes-validations": [
            {
              "message": "Value is immutable",
              "rule": "self == oldSelf"
            }
          ]
        },
        "folderUID": {
          "type": "string",
          "x-kubernetes-validations": [
            {
              "message": "Value is immutable",
              "rule": "self == oldSelf"
            }
          ]
        },
        "instanceSelector": {
          "properties": {
            "matchExpressions": {
              "items": {
                "properties": {
                  "key": {
                    "type": "string"
                  },
                  "operator": {
                    "type": "string"
                  },
                  "values": {
                    "items": {
                      "type": "string"
                    },
                    "type": "array",
                    "x-kubernetes-list-type": "atomic"
                  }
                },
                "required": [
                  "key",
                  "operator"
                ],
                "type": "object"
              },
              "type": "array",
              "x-kubernetes-list-type": "atomic"
            },
            "matchLabels": {
              "additionalProperties": {
                "type": "string"
              },
              "type": "object"
            }
          },
          "type": "object",
          "x-kubernetes-map-type": "atomic",
          "x-kubernetes-validations": [
            {
              "message": "spec.instanceSelector is immutable",
              "rule": "self == oldSelf"
            }
          ]
        },
        "interval": {
          "format": "duration",
          "pattern": "^([0-9]+(\\.[0-9]+)?(ns|us|\u00b5s|ms|s|m|h))+$",
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "resyncPeriod": {
          "pattern": "^([0-9]+(\\.[0-9]+)?(ns|us|\u00b5s|ms|s|m|h))+$",
          "type": "string"
        },
        "rules": {
          "items": {
            "properties": {
              "annotations": {
                "additionalProperties": {
                  "type": "string"
                },
                "type": "object"
              },
              "condition": {
                "type": "string"
              },
              "dashboardUid": {
                "type": "string"
              },
              "data": {
                "items": {
                  "properties": {
                    "datasourceUid": {
                      "type": "string"
                    },
                    "model": {
                      "x-kubernetes-preserve-unknown-fields": true
                    },
                    "queryType": {
                      "type": "string"
                    },
                    "refId": {
                      "type": "string"
                    },
                    "relativeTimeRange": {
                      "properties": {
                        "from": {
                          "format": "int64",
                          "type": "integer"
                        },
                        "to": {
                          "format": "int64",
                          "type": "integer"
                        }
                      },
                      "type": "object"
                    }
                  },
                  "type": "object"
                },
                "type": "array"
              },
              "execErrState": {
                "enum": [
                  "OK",
                  "Alerting",
                  "Error",
                  "KeepLast"
                ],
                "type": "string"
              },
              "for": {
                "default": "0s",
                "pattern": "^([0-9]+(\\.[0-9]+)?(s|m|h|d|w))+$",
                "type": "string"
              },
              "isPaused": {
                "type": "boolean"
              },
              "keepFiringFor": {
                "format": "duration",
                "pattern": "^([0-9]+(\\.[0-9]+)?(ns|us|\u00b5s|ms|s|m|h))+$",
                "type": "string"
              },
              "labels": {
                "additionalProperties": {
                  "type": "string"
                },
                "type": "object"
              },
              "missingSeriesEvalsToResolve": {
                "format": "int64",
                "type": "integer"
              },
              "noDataState": {
                "enum": [
                  "Alerting",
                  "NoData",
                  "OK",
                  "KeepLast"
                ],
                "type": "string"
              },
              "notificationSettings": {
                "properties": {
                  "active_time_intervals": {
                    "items": {
                      "type": "string"
                    },
                    "type": "array"
                  },
                  "group_by": {
                    "items": {
                      "type": "string"
                    },
                    "type": "array"
                  },
                  "group_interval": {
                    "type": "string"
                  },
                  "group_wait": {
                    "type": "string"
                  },
                  "mute_time_intervals": {
                    "items": {
                      "type": "string"
                    },
                    "type": "array"
                  },
                  "receiver": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "repeat_interval": {
                    "type": "string"
                  }
                },
                "required": [
                  "receiver"
                ],
                "type": "object"
              },
              "panelId": {
                "type": "integer"
              },
              "record": {
                "properties": {
                  "from": {
                    "type": "string"
                  },
                  "metric": {
                    "type": "string"
                  },
                  "targetDatasourceUid": {
                    "type": "string"
                  }
                },
                "required": [
                  "from",
                  "metric"
                ],
                "type": "object"
              },
              "title": {
                "example": "Always firing",
                "maxLength": 190,
                "minLength": 1,
                "type": "string"
              },
              "uid": {
                "maxLength": 40,
                "pattern": "^[a-zA-Z0-9-_]+$",
                "type": "string"
              }
            },
            "required": [
              "condition",
              "data",
              "execErrState",
              "for",
              "noDataState",
              "title",
              "uid"
            ],
            "type": "object"
          },
          "minItems": 1,
          "type": "array"
        },
        "suspend": {
          "type": "boolean"
        }
      },
      "required": [
        "instanceSelector",
        "interval",
        "rules"
      ],
      "type": "object",
      "x-kubernetes-validations": [
        {
          "message": "Only one of FolderUID or FolderRef can be set and one must be defined",
          "rule": "(has(self.folderUID) && !(has(self.folderRef))) || (has(self.folderRef) && !(has(self.folderUID)))"
        },
        {
          "message": "spec.editable is immutable",
          "rule": "((!has(oldSelf.editable) && !has(self.editable)) || (has(oldSelf.editable) && has(self.editable)))"
        },
        {
          "message": "spec.folderUID is immutable",
          "rule": "((!has(oldSelf.folderUID) && !has(self.folderUID)) || (has(oldSelf.folderUID) && has(self.folderUID)))"
        },
        {
          "message": "spec.folderRef is immutable",
          "rule": "((!has(oldSelf.folderRef) && !has(self.folderRef)) || (has(oldSelf.folderRef) && has(self.folderRef)))"
        },
        {
          "message": "disabling spec.allowCrossNamespaceImport requires a recreate to ensure desired state",
          "rule": "!oldSelf.allowCrossNamespaceImport || (oldSelf.allowCrossNamespaceImport && self.allowCrossNamespaceImport)"
        }
      ]
    },
    "status": {
      "properties": {
        "conditions": {
          "items": {
            "properties": {
              "lastTransitionTime": {
                "format": "date-time",
                "type": "string"
              },
              "message": {
                "maxLength": 32768,
                "type": "string"
              },
              "observedGeneration": {
                "format": "int64",
                "minimum": 0,
                "type": "integer"
              },
              "reason": {
                "maxLength": 1024,
                "minLength": 1,
                "pattern": "^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$",
                "type": "string"
              },
              "status": {
                "enum": [
                  "True",
                  "False",
                  "Unknown"
                ],
                "type": "string"
              },
              "type": {
                "maxLength": 316,
                "pattern": "^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$",
                "type": "string"
              }
            },
            "required": [
              "lastTransitionTime",
              "message",
              "reason",
              "status",
              "type"
            ],
            "type": "object"
          },
          "type": "array"
        },
        "lastResync": {
          "format": "date-time",
          "type": "string"
        }
      },
      "type": "object"
    }
  },
  "required": [
    "spec"
  ],
  "type": "object"
}
