{
  "jsonSchema": {
    "$schema": "http://json-schema.org/draft-07/schema#",
    "type": "object",
    "properties": {
      "update_every": {
        "title": "Update every",
        "description": "Data collection interval, measured in seconds.",
        "type": "integer",
        "minimum": 1,
        "default": 1
      },
      "path": {
        "title": "Log file",
        "description": "The file path to the Squid server log file.",
        "type": "string",
        "default": "/var/log/squid/access.log",
        "pattern": "^$|^/"
      },
      "exclude_path": {
        "title": "Exclude path",
        "description": "Pattern to exclude log files.",
        "type": "string",
        "default": "*.gz"
      },
      "log_type": {
        "title": "Log parser",
        "description": "Type of parser to use for parsing the Squid server log file.",
        "type": "string",
        "enum": [
          "csv",
          "regexp",
          "json",
          "ltsv"
        ],
        "default": "csv"
      }
    },
    "required": [
      "path",
      "log_type"
    ],
    "patternProperties": {
      "^name$": {}
    },
    "dependencies": {
      "log_type": {
        "oneOf": [
          {
            "properties": {
              "log_type": {
                "const": "csv"
              },
              "csv_config": {
                "title": "CSV parser configuration",
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "format": {
                    "title": "Format",
                    "description": "Log format.",
                    "type": "string",
                    "default": "$remote_addr - - [$time_local] \"$request\" $status $body_bytes_sent"
                  },
                  "delimiter": {
                    "title": "Delimiter",
                    "description": "Delimiter used to separate fields in the log file. Default: space (' ').",
                    "type": "string",
                    "default": " "
                  }
                },
                "required": [
                  "format",
                  "delimiter"
                ]
              }
            },
            "required": [
              "csv_config"
            ]
          },
          {
            "properties": {
              "log_type": {
                "const": "regexp"
              },
              "regexp_config": {
                "title": "Regular expression parser configuration",
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "pattern": {
                    "title": "Pattern with named groups",
                    "description": "Regular expression pattern with named groups. Use named groups for known fields.",
                    "type": "string",
                    "default": ""
                  }
                },
                "required": [
                  "pattern"
                ]
              }
            },
            "required": [
              "regexp_config"
            ]
          },
          {
            "properties": {
              "log_type": {
                "const": "json"
              },
              "json_config": {
                "title": "JSON parser configuration",
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "mapping": {
                    "title": "Field mapping",
                    "description": "Dictionary mapping fields in logs to known fields.",
                    "type": [
                      "object",
                      "null"
                    ],
                    "additionalProperties": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          {
            "properties": {
              "log_type": {
                "const": "ltsv"
              },
              "ltsv_config": {
                "title": "LTSV parser configuration",
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "field_delimiter": {
                    "title": "Field delimiter",
                    "description": "Delimiter used to separate fields in LTSV logs. Default: tab ('\\t').",
                    "type": "string",
                    "default": "\t"
                  },
                  "value_delimiter": {
                    "title": "Value delimiter",
                    "description": "Delimiter used to separate label-value pairs in LTSV logs.",
                    "type": "string",
                    "default": ":"
                  },
                  "mapping": {
                    "title": "Field mapping",
                    "description": "Dictionary mapping fields in logs to known fields.",
                    "type": [
                      "object",
                      "null"
                    ],
                    "additionalProperties": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        ]
      }
    }
  },
  "uiSchema": {
    "uiOptions": {
      "fullPage": true
    },
    "log_type": {
      "ui:widget": "radio",
      "ui:options": {
        "inline": true
      }
    },
    "ui:flavour": "tabs",
    "ui:options": {
      "tabs": [
        {
          "title": "Base",
          "fields": [
            "update_every",
            "path",
            "exclude_path"
          ]
        },
        {
          "title": "Parser",
          "fields": [
            "log_type",
            "csv_config",
            "ltsv_config",
            "regexp_config",
            "json_config"
          ]
        }
      ]
    }
  }
}
