ExIncus.Operations (ex_incus v1.0.0)

Copy Markdown

Query, wait on and cancel background operations.

See ExIncus.Operation for what an operation is. You mostly won't call this module yourself: the resource modules wait on operations for you unless you pass wait: false.

Summary

Functions

Cancels a running operation (only possible when :may_cancel is true).

Fetches the current state of an operation.

Lists operations.

Waits for an operation to finish.

Functions

cancel(client, op, opts \\ [])

@spec cancel(ExIncus.Client.t(), ExIncus.Operation.t() | String.t(), keyword()) ::
  {:ok, term()} | {:error, ExIncus.Error.t()}

Cancels a running operation (only possible when :may_cancel is true).

get(client, op, opts \\ [])

@spec get(ExIncus.Client.t(), ExIncus.Operation.t() | String.t(), keyword()) ::
  {:ok, ExIncus.Operation.t()} | {:error, ExIncus.Error.t()}

Fetches the current state of an operation.

Accepts an ExIncus.Operation, a UUID or a "/1.0/operations/<uuid>" path.

list(client, opts \\ [])

@spec list(
  ExIncus.Client.t(),
  keyword()
) :: {:ok, map()} | {:error, ExIncus.Error.t()}

Lists operations.

Returns a map of status ("running", "success", ...) to operations. Pass recursion: 0 to get URLs instead of objects.

wait(client, op, opts \\ [])

@spec wait(ExIncus.Client.t(), ExIncus.Operation.t() | String.t(), keyword()) ::
  {:ok, ExIncus.Operation.t()} | {:error, ExIncus.Error.t()}

Waits for an operation to finish.

Returns {:ok, operation} if it completed successfully, and {:error, %ExIncus.Error{}} if it failed, was cancelled, or is still running when the timeout expires.

Options

  • :timeout - seconds to wait, or :infinity (default 300)