ExIncus (ex_incus v1.0.0)

Copy Markdown

Elixir client for the Incus REST API.

Quick start

# Local Unix socket (default: /var/lib/incus/unix.socket)
client = ExIncus.connect()

# Or a remote server with TLS client certificate auth
client =
  ExIncus.connect(
    base_url: "https://incus.example.net:8443",
    certfile: "client.crt",
    keyfile: "client.key"
  )

# Create + start a container from images.linuxcontainers.org
{:ok, _} = ExIncus.launch(client, "web1", "debian/12")

{:ok, result} = ExIncus.exec(client, "web1", ["hostname"])

{:ok, _} =
  ExIncus.push_file(client, "web1", "/etc/resolv.conf",
    "nameserver 10.140.100.1\n", mode: 0o644)

{:ok, _} = ExIncus.stop(client, "web1")
{:ok, _} = ExIncus.delete_instance(client, "web1")

This module only hosts shortcuts for the most common instance operations; the full API surface lives in the resource modules:

Conventions

Every call takes the client first and returns {:ok, result} or {:error, %ExIncus.Error{}}. State-changing calls are waited on by default; pass wait: false for fire-and-forget (you get the ExIncus.Operation back) or timeout: seconds | :infinity to control the wait. Endpoints not wrapped yet are reachable via ExIncus.Client.request/4.

Summary

Functions

connect(opts \\ [])

Builds a client. See ExIncus.Client.new/1 for options.

create_instance(client, params, opts \\ [])

Creates an instance from a params map. See ExIncus.Instances.create/3.

delete_instance(client, name, opts \\ [])

Deletes an instance. See ExIncus.Instances.delete/3.

exec(client, name, command, opts \\ [])

Runs a command in an instance. See ExIncus.Instances.exec/4.

get_instance(client, name, opts \\ [])

Fetches an instance. See ExIncus.Instances.get/3.

import_image(client, path, opts \\ [])

Imports an image tarball from disk. See ExIncus.Images.import_file/3.

launch(client, name, image, opts \\ [])

Creates and starts an instance from an image. See ExIncus.Instances.launch/4.

list_instances(client, opts \\ [])

Lists instances. See ExIncus.Instances.list/2.

pull_file(client, name, path, opts \\ [])

Reads a file from an instance. See ExIncus.Instances.pull_file/4.

push_file(client, name, path, content, opts \\ [])

Writes a file into an instance. See ExIncus.Instances.push_file/5.

restart(client, name, opts \\ [])

Restarts an instance. See ExIncus.Instances.restart/3.

server_info(client, opts \\ [])

Fetches server information. See ExIncus.Server.info/2.

start(client, name, opts \\ [])

Starts an instance. See ExIncus.Instances.start/3.

stop(client, name, opts \\ [])

Stops an instance. See ExIncus.Instances.stop/3.