ExIncus (ex_incus v1.0.0)
Copy MarkdownElixir 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:
ExIncus.Instances- lifecycle, state, config/devices, exec, filesExIncus.EventListener- live event stream (websocket), for dashboardsExIncus.Snapshots- instance snapshotsExIncus.Networks- networks and DHCP leasesExIncus.Profiles- profilesExIncus.Images- images and aliasesExIncus.Projects- projectsExIncus.StoragePools/ExIncus.StorageVolumes- storageExIncus.Certificates- trust storeExIncus.Server- server info and configurationExIncus.Operations- background operationsExIncus.Client- connection handling and raw requests
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
Builds a client. See ExIncus.Client.new/1 for options.
Creates an instance from a params map. See ExIncus.Instances.create/3.
Deletes an instance. See ExIncus.Instances.delete/3.
Runs a command in an instance. See ExIncus.Instances.exec/4.
Fetches an instance. See ExIncus.Instances.get/3.
Imports an image tarball from disk. See ExIncus.Images.import_file/3.
Creates and starts an instance from an image. See ExIncus.Instances.launch/4.
Lists instances. See ExIncus.Instances.list/2.
Reads a file from an instance. See ExIncus.Instances.pull_file/4.
Writes a file into an instance. See ExIncus.Instances.push_file/5.
Restarts an instance. See ExIncus.Instances.restart/3.
Fetches server information. See ExIncus.Server.info/2.
Starts an instance. See ExIncus.Instances.start/3.
Stops an instance. See ExIncus.Instances.stop/3.
Functions
Builds a client. See ExIncus.Client.new/1 for options.
Creates an instance from a params map. See ExIncus.Instances.create/3.
Deletes an instance. See ExIncus.Instances.delete/3.
Runs a command in an instance. See ExIncus.Instances.exec/4.
Fetches an instance. See ExIncus.Instances.get/3.
Imports an image tarball from disk. See ExIncus.Images.import_file/3.
Creates and starts an instance from an image. See ExIncus.Instances.launch/4.
Lists instances. See ExIncus.Instances.list/2.
Reads a file from an instance. See ExIncus.Instances.pull_file/4.
Writes a file into an instance. See ExIncus.Instances.push_file/5.
Restarts an instance. See ExIncus.Instances.restart/3.
Fetches server information. See ExIncus.Server.info/2.
Starts an instance. See ExIncus.Instances.start/3.
Stops an instance. See ExIncus.Instances.stop/3.