Packages

Elixir client for the Incus (linuxcontainers.org) REST API

Current section

Files

Jump to
ex_incus lib ex_incus server.ex
Raw

lib/ex_incus/server.ex

defmodule ExIncus.Server do
@moduledoc """
Server-level information and configuration (the `/1.0` endpoint).
{:ok, info} = ExIncus.Server.info(client)
info["environment"]["server_version"]
"""
alias ExIncus.{Client, Error}
@type result :: {:ok, term()} | {:error, Error.t()}
@doc "Fetches server information: API version, auth status, environment, config."
@spec info(Client.t(), keyword()) :: result()
def info(client, opts \\ []) do
Client.request(client, :get, "/1.0", project: opts[:project])
end
@doc ~S"""
Replaces the server configuration (`PUT` with `%{"config" => %{...}}`).
"""
@spec update(Client.t(), map(), keyword()) :: result()
def update(client, params, opts \\ []) do
Client.request(client, :put, "/1.0", json: params, project: opts[:project])
end
@doc "Partially updates the server configuration (`PATCH`)."
@spec patch(Client.t(), map(), keyword()) :: result()
def patch(client, params, opts \\ []) do
Client.request(client, :patch, "/1.0", json: params, project: opts[:project])
end
@doc "Fetches hardware resource information (CPU, memory, disks, network cards)."
@spec resources(Client.t(), keyword()) :: result()
def resources(client, opts \\ []) do
Client.request(client, :get, "/1.0/resources", project: opts[:project])
end
end