# UpCloud Provider Configuration Schema

let defaults = import "./upcloud-defaults.ncl" in

{
  # Contract definitions

  UpCloudAuth = {
    interface | String,  # API or CLI
  },

  UpCloudPaths = {
    base | String,
    cache | String,
    state | String,
  },

  UpCloudAPI = {
    url | String,
    timeout | Number,
  },

  UpCloudProvider = {
    name | String,
    enabled | Bool,
    workspace | String,
    auth | UpCloudAuth,
    paths | UpCloudPaths,
    api | UpCloudAPI,
  },

  # Hybrid interface
  defaults = defaults,

  make_auth | not_exported = fun o =>
    defaults.auth & o,

  make_paths | not_exported = fun o =>
    defaults.paths & o,

  make_api | not_exported = fun o =>
    defaults.api & o,

  make_upcloud | not_exported = fun o =>
    defaults.upcloud & o,

  # Default instances
  DefaultAuth = defaults.auth,
  DefaultPaths = defaults.paths,
  DefaultAPI = defaults.api,
  DefaultUpCloudProvider = defaults.upcloud,
}
