{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://json.schemastore.org/metaschema-draft-07-unofficial-strict.json",
  "additionalProperties": true,
  "properties": {
    "type": {
      "title": "Type",
      "type": "string",
      "default": "BIGCONFIG_FILE",
      "anyOf": [
        {
          "const": "BIGCONFIG_FILE"
        }
      ]
    },
    "auto_apply_on_indexing": {
      "title": "Auto Apply On Indexing",
      "default": true,
      "type": "boolean"
    },
    "tag_definitions": {
      "title": "Tag Definitions",
      "type": "array",
      "items": {
        "$ref": "#/definitions/TagDefinition"
      }
    },
    "row_creation_times": {
      "title": "Row Creation Times",
      "default": {
        "tag_ids": [],
        "column_selectors": []
      },
      "allOf": [
        {
          "$ref": "#/definitions/RowCreationTimes"
        }
      ]
    },
    "saved_metric_definitions": {
      "$ref": "#/definitions/SavedMetricDefinitions"
    },
    "tag_deployments": {
      "title": "Tag Deployments",
      "type": "array",
      "items": {
        "$ref": "#/definitions/TagDeploymentSuite"
      }
    },
    "table_deployments": {
      "title": "Table Deployments",
      "type": "array",
      "items": {
        "$ref": "#/definitions/TableDeploymentSuite"
      }
    }
  },
  "type": "object",
  "title": "Bigconfig",
  "description": "Bigconfig is a yaml-based declarative monitoring as code solution. Data engineers can deploy Bigeye metrics from the command-line for convenient and scalable data quality monitoring.",
  "required": ["type"],
  "definitions": {
    "SimpleFieldType": {
      "title": "SimpleFieldType",
      "enum": [
        "UNSPECIFIED",
        "STRING",
        "UUID",
        "BINARY",
        "NUMERIC",
        "DATE_LIKE",
        "TIMESTAMP_LIKE",
        "ANY",
        "BOOLEAN",
        "UNKNOWN",
        "ARRAY",
        "STRUCT"
      ],
      "type": "string"
    },
    "ColumnSelector": {
      "title": "ColumnSelector",
      "type": "object",
      "default": {
        "name": "*.*.*.*"
      },
      "properties": {
        "name": {
          "title": "Name",
          "type": "string",
          "default": "*.*.*.*"
        },
        "type": {
          "$ref": "#/definitions/SimpleFieldType"
        },
        "exclude": {
          "title": "Exclude",
          "type": "string"
        },
        "regex": {
          "title": "Regex",
          "type": "string"
        }
      }
    },
    "TagDefinition": {
      "title": "TagDefinition",
      "type": "object",
      "default": {
        "tag_id": "TAG_ID"
      },
      "properties": {
        "tag_id": {
          "title": "Tag Id",
          "type": "string"
        },
        "column_selectors": {
          "title": "Column Selectors",
          "type": "array",
          "default": [
            {
              "name": "*.*.*.*"
            }
          ],
          "items": {
            "$ref": "#/definitions/ColumnSelector"
          }
        }
      },
      "required": ["tag_id", "column_selectors"]
    },
    "RowCreationTimes": {
      "title": "RowCreationTimes",
      "type": "object",
      "properties": {
        "tag_ids": {
          "title": "Tag Ids",
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "column_selectors": {
          "title": "Column Selectors",
          "type": "array",
          "items": {
            "$ref": "#/definitions/ColumnSelector"
          }
        }
      }
    },
    "NotificationChannels": {
      "title": "Notification Channels",
      "type": "object",
      "properties": {
        "slack": {
          "type": "string"
        },
        "email": {
          "type": "string"
        },
        "webhook": {
          "type": "string"
        },
        "webhook_header_key": {
          "type": "string"
        },
        "webhook_header_value": {
          "type": "string"
        }
      }
    },
    "MetricParameters": {
      "title": "Metric Parameters",
      "type": "object",
      "properties": {
        "key": {
          "type": "string"
        },
        "string_value": {
          "type": "string"
        },
        "column_name": {
          "type": "string"
        },
        "number_value": {
          "type": "number"
        }
      }
    },
    "SimpleMetricDefinition": {
      "title": "SimpleMetricDefinition",
      "type": "object",
      "properties": {
        "saved_metric_id": {
          "title": "Saved Metric id",
          "type": "string"
        },
        "metric_type": {
          "title": "Metric Type",
          "type": "object",
          "properties": {
            "predefined_metric": {
              "title": "Predefined Metric",
              "enum": [
                "PERCENT_NULL",
                "COUNT_NULL",
                "PERCENT_EMPTY_STRING",
                "COUNT_EMPTY_STRING",
                "PERCENT_UNIQUE",
                "PERCENT_VALUE_IN_LIST",
                "AVERAGE",
                "MIN",
                "MAX",
                "SUM",
                "COUNT_ROWS",
                "COUNT_DISTINCT",
                "HOURS_SINCE_MAX_DATE",
                "HOURS_SINCE_MAX_TIMESTAMP",
                "COUNT_TRUE",
                "PERCENT_TRUE",
                "COUNT_FALSE",
                "PERCENT_FALSE",
                "COUNT_USA_PHONE",
                "PERCENT_USA_PHONE",
                "COUNT_USA_ZIP_CODE",
                "PERCENT_USA_ZIP_CODE",
                "PERCENT_UUID",
                "COUNT_TIMESTAMP_STRING",
                "PERCENT_TIMESTAMP_STRING",
                "COUNT_DUPLICATES",
                "COUNT_USA_STATE_CODE",
                "PERCENT_USA_STATE_CODE",
                "VARIANCE",
                "SKEW",
                "KURTOSIS",
                "GEOMETRIC_MEAN",
                "HARMONIC_MEAN",
                "COUNT_UUID",
                "COUNT_CUSIP",
                "PERCENT_CUSIP",
                "COUNT_SEDOL",
                "PERCENT_SEDOL",
                "COUNT_ISIN",
                "PERCENT_ISIN",
                "COUNT_LEI",
                "PERCENT_LEI",
                "COUNT_FIGI",
                "PERCENT_FIGI",
                "COUNT_PERM_ID",
                "PERCENT_PERM_ID",
                "COUNT_NAN",
                "PERCENT_NAN",
                "COUNT_LONGITUDE",
                "PERCENT_LONGITUDE",
                "COUNT_LATITUDE",
                "PERCENT_LATITUDE",
                "COUNT_NOT_IN_FUTURE",
                "PERCENT_NOT_IN_FUTURE",
                "COUNT_DATE_NOT_IN_FUTURE",
                "PERCENT_DATE_NOT_IN_FUTURE",
                "MEDIAN",
                "PERCENTILE",
                "COUNT_NOT_NULL",
                "STRING_LENGTH_AVERAGE",
                "STRING_LENGTH_MIN",
                "STRING_LENGTH_MAX",
                "COUNT_SSN",
                "PERCENT_SSN",
                "COUNT_EMAIL",
                "PERCENT_EMAIL",
                "ROWS_INSERTED",
                "HOURS_SINCE_LAST_LOAD",
                "COUNT_READ_QUERIES",
                "PERCENT_NOT_NULL",
                "FRESHNESS",
                "VOLUME"
              ]
            },
            "type": {
              "type": "string",
              "enum": ["PREDEFINED", "TEMPLATE"]
            },
            "template_id": {
              "type": "number"
            },
            "aggregation_type": {
              "type": "string",
              "enum": ["COUNT", "PERCENT"]
            }
          },
          "required": ["predefined_metric"]
        },
        "metric_name": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "schedule_frequency": {
          "type": "object",
          "default": {
            "interval_type": "HOURS",
            "interval_value": 24
          },
          "properties": {
            "interval_type": {
              "enum": ["HOURS", "MINUTES"],
              "default": "HOURS"
            },
            "interval_value": {
              "type": "number",
              "default": 24
            }
          },
          "required": ["interval_type", "interval_value"]
        },
        "conditions": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "group_by": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "threshold": {
          "type": "object",
          "properties": {
            "type": {
              "enum": ["AUTO", "RELATIVE", "STDDEV", "CONSTANT"]
            },
            "sensitivity": {
              "description": "Only valid for autothreshold metrics",
              "enum": ["NARROW", "MEDIUM", "WIDE", "XWIDE"]
            },
            "upper_bound": {
              "description": "Only valid for constant, relative, and standard deviation metrics",
              "type": "number"
            },
            "lower_bound": {
              "description": "Only valid for constant, relative, and standard deviation metrics",
              "type": "number"
            },
            "upper_bound_only": {
              "description": "Only valid for autothreshold metrics",
              "type": "boolean"
            },
            "lower_bound_only": {
              "description": "Only valid for autothreshold metrics",
              "type": "boolean"
            },
            "reference_point": {
              "type": "object",
              "description": "Only valid for relative and standard deviation metrics",
              "properties": {
                "interval_type": {
                  "enum": ["DAYS"]
                },
                "interval_value": {
                  "type": "number"
                }
              },
              "required": ["interval_type", "interval_value"]
            }
          },
          "required": ["type"]
        },
        "notification_channels": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/NotificationChannels"
          }
        },
        "parameters": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/MetricParameters"
          }
        },
        "lookback": {
          "type": "object",
          "properties": {
            "lookback_type": {
              "enum": ["DATA_TIME", "METRIC_TIME", "CLOCK_TIME"]
            },
            "lookback_window": {
              "type": "object",
              "properties": {
                "interval_type": {
                  "enum": ["DAYS"]
                },
                "interval_value": {
                  "type": "number"
                }
              },
              "required": ["interval_type", "interval_value"]
            },
            "bucket_size": {
              "description": "Only valid for data time window metrics",
              "enum": ["DAY", "HOUR"]
            }
          },
          "required": ["lookback_type", "lookback_window"]
        },
        "metric_schedule": {
          "type": "object",
          "properties": {
            "named_schedule": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "cron": {
                  "type": "string"
                },
                "id": {
                  "type": "number"
                }
              },
              "required": ["name"]
            }
          },
          "required": ["named_schedule"]
        }
      }
    },
    "SavedMetricDefinitions": {
      "title": "SavedMetricDefinitions",
      "type": "object",
      "properties": {
        "metrics": {
          "title": "Metrics",
          "type": "array",
          "items": {
            "$ref": "#/definitions/SimpleMetricDefinition"
          }
        }
      },
      "required": ["metrics"]
    },
    "TagDeployment": {
      "title": "TagDeployment",
      "type": "object",
      "properties": {
        "column_selectors": {
          "title": "Column Selectors",
          "type": "array",
          "items": {
            "$ref": "#/definitions/ColumnSelector"
          }
        },
        "metrics": {
          "title": "Metrics",
          "type": "array",
          "items": {
            "$ref": "#/definitions/SimpleMetricDefinition"
          }
        },
        "tag_id": {
          "title": "Tag Id",
          "type": "string"
        }
      },
      "required": ["metrics"]
    },
    "SimpleCollection": {
      "title": "SimpleCollection",
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "notification_channels": {
          "$ref": "#/definitions/NotificationChannels"
        }
      },
      "required": ["name", "description"]
    },
    "TagDeploymentSuite": {
      "title": "TagDeploymentSuite",
      "type": "object",
      "properties": {
        "collection": {
          "$ref": "#/definitions/SimpleCollection"
        },
        "deployments": {
          "title": "Deployments",
          "type": "array",
          "items": {
            "$ref": "#/definitions/TagDeployment"
          }
        }
      }
    },
    "ColumnMetricDeployment": {
      "title": "ColumnMetricDeployment",
      "type": "object",
      "properties": {
        "column_name": {
          "title": "Column Name",
          "type": "string"
        },
        "metrics": {
          "title": "Metrics",
          "type": "array",
          "items": {
            "$ref": "#/definitions/SimpleMetricDefinition"
          }
        }
      },
      "required": ["column_name", "metrics"]
    },
    "TableDeployment": {
      "title": "TableDeployment",
      "type": "object",
      "properties": {
        "fq_table_name": {
          "title": "Fq Table Name",
          "type": "string"
        },
        "columns": {
          "title": "Columns",
          "type": "array",
          "items": {
            "$ref": "#/definitions/ColumnMetricDeployment"
          }
        },
        "table_metrics": {
          "title": "Table Metrics",
          "type": "array",
          "items": {
            "$ref": "#/definitions/SimpleMetricDefinition"
          }
        },
        "row_creation_time": {
          "title": "Row Creation Time",
          "type": "string"
        }
      },
      "required": ["fq_table_name"]
    },
    "TableDeploymentSuite": {
      "title": "TableDeploymentSuite",
      "type": "object",
      "properties": {
        "collection": {
          "$ref": "#/definitions/SimpleMetricDefinition"
        },
        "deployments": {
          "title": "Deployments",
          "type": "array",
          "items": {
            "$ref": "#/definitions/TableDeployment"
          }
        }
      },
      "required": ["deployments"]
    }
  }
}
