// Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
// All rights reserved. This file is part of cc-backend.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.

package config

var configSchema = `
{
  "type": "object",
  "properties": {
    "addr": {
      "description": "Address where the http (or https) server will listen on (for example: 'localhost:80').",
      "type": "string"
    },
    "api-allowed-ips": {
      "description": "Addresses from which secured API endpoints can be reached",
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "user": {
      "description": "Drop root permissions once the config was read and the port was taken. Only applicable if using privileged port.",
      "type": "string"
    },
    "group": {
      "description": "Drop root permissions once the config was read and the port was taken. Only applicable if using privileged port.",
      "type": "string"
    },
    "disable-authentication": {
      "description": "Disable authentication (for everything: API, Web-UI, ...).",
      "type": "boolean"
    },
    "embed-static-files": {
      "description": "If all files in web/frontend/public should be served from within the binary itself (they are embedded) or not.",
      "type": "boolean"
    },
    "static-files": {
      "description": "Folder where static assets can be found, if embed-static-files is false.",
      "type": "string"
    },
    "db": {
      "description": "Path to SQLite database file (e.g., './var/job.db')",
      "type": "string"
    },
    "enable-job-taggers": {
      "description": "Turn on automatic application and jobclass taggers",
      "type": "boolean"
    },
    "validate": {
      "description": "Validate all input json documents against json schema.",
      "type": "boolean"
    },
    "session-max-age": {
      "description": "Specifies for how long a session shall be valid  as a string parsable by time.ParseDuration(). If 0 or empty, the session/token does not expire!",
      "type": "string"
    },
    "https-cert-file": {
      "description": "Filepath to SSL certificate. If also https-key-file is set use HTTPS using those certificates.",
      "type": "string"
    },
    "https-key-file": {
      "description": "Filepath to SSL key file. If also https-cert-file is set use HTTPS using those certificates.",
      "type": "string"
    },
    "redirect-http-to": {
      "description": "If not the empty string and addr does not end in :80, redirect every request incoming at port 80 to that url.",
      "type": "string"
    },
    "stop-jobs-exceeding-walltime": {
      "description": "If not zero, automatically mark jobs as stopped running X seconds longer than their walltime. Only applies if walltime is set for job.",
      "type": "integer"
    },
    "short-running-jobs-duration": {
      "description": "Do not show running jobs shorter than X seconds.",
      "type": "integer"
    },
    "emission-constant": {
      "description": "Energy mix CO2 emission constant [g/kWh]. If set, displays estimated CO2 emission for jobs.",
      "type": "integer"
    },
    "machine-state-dir": {
      "description": "Where to store MachineState files.",
      "type": "string"
    },
    "systemd-unit": {
      "description": "Systemd unit name for log viewer (default: 'clustercockpit').",
      "type": "string"
    },
    "resampling": {
      "description": "Enable dynamic zoom in frontend metric plots.",
      "type": "object",
      "properties": {
        "default-policy": {
          "description": "Default resample policy when no user preference is set.",
          "type": "string",
          "enum": ["low", "medium", "high"]
        },
        "default-algo": {
          "description": "Default resample algorithm when no user preference is set. Default and recommended: 'average' (RRDTool-style interval averaging).",
          "type": "string",
          "enum": ["lttb", "average", "simple"]
        }
      }
    },
    "api-subjects": {
      "description": "NATS subjects configuration for subscribing to job and node events.",
      "type": "object",
      "properties": {
        "subject-job-event": {
          "description": "NATS subject for job events (start_job, stop_job)",
          "type": "string"
        },
        "subject-node-state": {
          "description": "NATS subject for node state updates",
          "type": "string"
        },
        "job-concurrency": {
          "description": "Number of concurrent worker goroutines for processing job events (default: 8).",
          "type": "integer"
        },
        "node-concurrency": {
          "description": "Number of concurrent worker goroutines for processing node state events (default: 2).",
          "type": "integer"
        }
      },
      "required": ["subject-job-event", "subject-node-state"]
    },
    "footer-links": {
      "description": "Optional footer links for legal pages (imprint/privacy). Each value may be an internal path or an external URL.",
      "type": "object",
      "properties": {
        "imprint": {
          "description": "Target URL/path for the footer imprint link.",
          "type": "string"
        },
        "privacy": {
          "description": "Target URL/path for the footer privacy link.",
          "type": "string"
        }
      }
    },
    "nodestate-retention": {
      "description": "Node state retention configuration for cleaning up old node_state rows.",
      "type": "object",
      "properties": {
        "policy": {
          "description": "Retention policy: 'delete' to remove old rows, 'move' to archive to Parquet then delete.",
          "type": "string",
          "enum": ["delete", "move"]
        },
        "age": {
          "description": "Retention age in hours (default: 24).",
          "type": "integer"
        },
        "target-kind": {
          "description": "Target kind for parquet archiving: 'file' or 's3'.",
          "type": "string",
          "enum": ["file", "s3"]
        },
        "target-path": {
          "description": "Filesystem path for parquet file target.",
          "type": "string"
        },
        "target-endpoint": {
          "description": "S3 endpoint URL.",
          "type": "string"
        },
        "target-bucket": {
          "description": "S3 bucket name.",
          "type": "string"
        },
        "target-access-key": {
          "description": "S3 access key.",
          "type": "string"
        },
        "target-secret-key": {
          "description": "S3 secret key.",
          "type": "string"
        },
        "target-region": {
          "description": "S3 region.",
          "type": "string"
        },
        "target-use-path-style": {
          "description": "Use path-style S3 addressing.",
          "type": "boolean"
        },
        "max-file-size-mb": {
          "description": "Maximum parquet file size in MB (default: 128).",
          "type": "integer"
        }
      },
      "required": ["policy"]
    },
    "db-config": {
      "description": "SQLite database tuning configuration.",
      "type": "object",
      "properties": {
        "cache-size-mb": {
          "description": "SQLite page cache size per connection in MB (default: 2048).",
          "type": "integer"
        },
        "soft-heap-limit-mb": {
          "description": "Process-wide SQLite soft heap limit in MB (default: 16384).",
          "type": "integer"
        },
        "max-open-connections": {
          "description": "Maximum number of open database connections (default: 4).",
          "type": "integer"
        },
        "max-idle-connections": {
          "description": "Maximum number of idle database connections (default: 4).",
          "type": "integer"
        },
        "max-idle-time-minutes": {
          "description": "Maximum idle time for a connection in minutes (default: 10).",
          "type": "integer"
        },
        "busy-timeout-ms": {
          "description": "SQLite busy timeout in milliseconds. When a write is blocked, SQLite retries with backoff for up to this duration before returning SQLITE_BUSY (default: 60000).",
          "type": "integer"
        }
      }
    }
  }
}`
