The tenant-scoped source-management API: Ankusa.Admin.Router on
admin.port (default 4002) serves list/get/create/update/delete for a
tenant's ingest sources.
A source is addressed as <tenant>.<name>; this client speaks in those terms
and builds the paths for you. Only [A-Za-z0-9_-]{1,64} tenants and names are
accepted, and both are checked before any path is built, so a caller-supplied
name cannot escape its tenant through URL normalization.
The version latch
:expected_version is an optional safety latch: when set, every API call
first makes sure GET /health reported that version, and a mismatch is an
Ankusa.SDK.VersionMismatchError before the request is sent.
The client is immutable, so the fetched version is returned rather than
remembered. Run verify_version/1 once at startup and keep the returned
client; every later call then re-checks the cached version without another
/health request:
{:ok, sources} = Ankusa.SDK.Sources.verify_version(Ankusa.SDK.Sources.new(url, expected_version: "0.3.0"))
{:ok, list} = Ankusa.SDK.Sources.list_sources(sources, "acme")Failures are Ankusa.SDK.SourceNotFoundError (404),
Ankusa.SDK.SourceConflictError (409), Ankusa.SDK.SourceStoreReadOnlyError
(409 source_store_read_only: the deployment's source store is a static seed),
Ankusa.SDK.SourceInvalidError (400, or an invalid tenant/name caught before
any request), Ankusa.SDK.VersionMismatchError, and
Ankusa.SDK.SourcesUnavailableError (unreachable, timed out, or 5xx). Every
one carries :status and :body.
Summary
Functions
Create a source: POST /v1/tenants/{tenant}/sources.
Delete a source: DELETE /v1/tenants/{tenant}/sources/{name}.
Fetch one source: GET /v1/tenants/{tenant}/sources/{name}.
List a tenant's sources: GET /v1/tenants/{tenant}/sources.
Build a client for base_url.
The deployment's Ankusa version: verify_version/1 then the "version" field.
Replace a source: PUT /v1/tenants/{tenant}/sources/{name}.
Fetch GET /health when the version isn't cached yet, enforce
:expected_version, and return the client with the version cached.
Types
Functions
@spec create_source(t(), term(), term(), Ankusa.SDK.Sources.Spec.t()) :: {:ok, Ankusa.SDK.Sources.Source.t()} | {:error, Exception.t()}
Create a source: POST /v1/tenants/{tenant}/sources.
The name travels in the body alongside the spec; the tenant comes from the URL.
@spec delete_source(t(), term(), term()) :: :ok | {:error, Exception.t()}
Delete a source: DELETE /v1/tenants/{tenant}/sources/{name}.
Returns :ok on 2xx (204 with an empty body). A source that still has
undelivered hooks on the server's node is 409 source_has_deliveries:
{:error, %Ankusa.SDK.SourceConflictError{}} whose body carries that
"error" and the "pending"/"inflight" counts. This function never sends
the admin API's ?deliveries=dead_letter.
@spec get_source(t(), term(), term()) :: {:ok, Ankusa.SDK.Sources.Source.t()} | {:error, Exception.t()}
Fetch one source: GET /v1/tenants/{tenant}/sources/{name}.
@spec list_sources(t(), term()) :: {:ok, [Ankusa.SDK.Sources.Source.t()]} | {:error, Exception.t()}
List a tenant's sources: GET /v1/tenants/{tenant}/sources.
Build a client for base_url.
Options are :headers (a map or {name, value} list sent on every request),
:timeout_ms (default 10_000, applied to connect and receive — to receive
only with a :finch pool, which owns its connect options),
:req_options (transport tuning: :finch, :connect_options,
:pool_timeout, :plug; :finch and :connect_options are exclusive), and
:expected_version (a version string to latch against, or nil for no latch).
@spec server_version(t()) :: {:ok, String.t()} | {:error, Ankusa.SDK.SourcesUnavailableError.t() | Ankusa.SDK.VersionMismatchError.t()}
The deployment's Ankusa version: verify_version/1 then the "version" field.
@spec update_source(t(), term(), term(), Ankusa.SDK.Sources.Spec.t()) :: {:ok, Ankusa.SDK.Sources.Source.t()} | {:error, Exception.t()}
Replace a source: PUT /v1/tenants/{tenant}/sources/{name}.
The name comes from the URL; the spec carries no name.
@spec verify_version(t()) :: {:ok, t()} | {:error, Ankusa.SDK.SourcesUnavailableError.t() | Ankusa.SDK.VersionMismatchError.t()}
Fetch GET /health when the version isn't cached yet, enforce
:expected_version, and return the client with the version cached.
Run it once at startup and keep the returned client; later calls then skip the probe.