sans-io implementation of the Proxmox VE API
proxmox sans-io gleam
Gleam 99%
Nix 1%
Shell <1%

README.md

proxmox_api #

Add it to your gleam.toml as a git dependency

proxmox_api = { git = "git@knot.ollie.earth:ollie.earth/proxmox_api", ref = "main" }
import proxmox_api

// -----------------------------------------------------------------------------

type MyError {
  ApiError(proxmox.Error)
  RequestFailed(httpc.HttpError)
}

pub fn main() {
  let credentials = proxmox.Credentials("my-user", "my-api-token")

  let resp =
    request.new()
    |> request.set_host(host)
    |> request.set_port(8006)
    |> request.set_scheme(http.Https)
    |> proxmox.nodes(credentials:)
    |> httpc.send
  
  // If you dont have proper tls set up for your proxmox node, you may need to
  // do this: 
  // httpc.configure()
  // |> httpc.verify_tls(False) 
  // |> httpc.dispatch(req)
  // you should really set up a proper tls cert 👀

  case resp {
    //                   vv - always `request_name`_response
    Ok(resp) -> proxmox.nodes_response(req) |> result.map_error(ApiError)
    Error(error) -> Error(RequestFailed(error))
  }
}