# `Ankusa.SDK.Admin`
[🔗](https://github.com/jamescarr/ankusa/blob/sdk-elixir-v0.6.0/packages/sdk-elixir/lib/ankusa/sdk/admin.ex#L1)

The operator listener (`admin.port`, default `4002`): health, Prometheus
metrics, the redacted configuration, the dead-letter queue, replay jobs, and
the quarantine list.

Responses are node-local by design, so a fleet operator scrapes every node's
admin port. The listener performs no authentication of its own — `:headers` is
for whatever a deployer's boundary expects in front of it.

Failures carry `retryable`: `false` for a rejection (`409 role_not_enabled`,
another `4xx`), `true` for a `5xx`, a redirect, a non-JSON success body, or an
unreachable listener.

```elixir
admin = Ankusa.SDK.Admin.new("http://localhost:4002")
{:ok, %{"status" => "ok"}} = Ankusa.SDK.Admin.health(admin)
{:ok, %{"total" => total}} = Ankusa.SDK.Admin.list_dead_letters(admin, limit: 10)

{:ok, replay} = Ankusa.SDK.Admin.create_replay(admin, %{"kind" => "dlq", "rate" => 500})
{:ok, %{"replays" => replays}} = Ankusa.SDK.Admin.list_replays(admin)
{:ok, replay} = Ankusa.SDK.Admin.update_replay(admin, replay["id"], %{"state" => "paused"})
```

# `t`

```elixir
@type t() :: %Ankusa.SDK.Admin{http: term()}
```

# `config`

```elixir
@spec config(t()) :: {:ok, term()} | {:error, Exception.t()}
```

The effective, redacted configuration: `GET /v1/config`.

# `create_replay`

```elixir
@spec create_replay(t(), term()) :: {:ok, term()} | {:error, Exception.t()}
```

Create a replay job: `POST /v1/replays` with `spec` as the JSON body.

`spec` is a map (or keyword list) naming the job: `%{"kind" => "dlq"}`,
`%{"kind" => "archive"}` or `%{"kind" => "quarantine"}`, plus the kind's
filter (`source_id`/`id`/`since`/`until` for `dlq` and `quarantine`,
`from`/`to`/`sinks` for `archive`) and the optional `rate` and
`max_lag_ms`. The response is the full Replay object; a retry of the same
spec answers the existing running/paused job instead of creating a second.

# `get_replay`

```elixir
@spec get_replay(t(), String.t()) :: {:ok, term()} | {:error, Exception.t()}
```

One replay job by id: `GET /v1/replays/:id`. A `404` is `replay_not_found`.

# `health`

```elixir
@spec health(t()) :: {:ok, term()} | {:error, Exception.t()}
```

Liveness probe: `GET /health` → `{"status", "instance", "roles"}`.

# `list_audit`

```elixir
@spec list_audit(t(), term()) :: {:ok, term()} | {:error, Exception.t()}
```

The audit trail, newest first: `GET /v1/audit`.

`params` may carry `cursor`, `limit`, `since`, `until`, `actor`, `action` and
`tenant`; `nil` values are left out of the query string rather than sent as
`=`.

# `list_dead_letters`

```elixir
@spec list_dead_letters(t(), term()) :: {:ok, term()} | {:error, Exception.t()}
```

A page of dead-lettered hooks, newest first: `GET /v1/dlq`.

`params` may carry `source_id`, `since` and `limit`; `nil` values are left out
of the query string rather than sent as `=`.

# `list_quarantined`

```elixir
@spec list_quarantined(t(), term()) :: {:ok, term()} | {:error, Exception.t()}
```

Recent quarantined hooks, newest first: `GET /v1/quarantine`.

`params` may carry `limit`; `nil` values are left out of the query string.

# `list_replays`

```elixir
@spec list_replays(t()) :: {:ok, term()} | {:error, Exception.t()}
```

Every replay job, newest first: `GET /v1/replays` → `{"replays", [...]}`.

# `metrics`

```elixir
@spec metrics(t()) :: {:ok, binary()} | {:error, Exception.t()}
```

The Prometheus text exposition body: `GET /metrics`.

# `new`

```elixir
@spec new(String.t(), keyword()) :: t()
```

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), and
`:req_options` (transport tuning: `:finch`, `:connect_options`,
`:pool_timeout`, `:plug`; `:finch` and `:connect_options` are exclusive).

# `update_replay`

```elixir
@spec update_replay(t(), String.t(), term()) ::
  {:ok, term()} | {:error, Exception.t()}
```

Change a replay job: `PATCH /v1/replays/:id`.

`patch` may set `state` (`"running"`/`"paused"`/`"cancelled"`), `rate`, and
`max_lag_ms`. A job that already finished (`done`/`cancelled`/`failed`) is a
`replay_finished` rejection.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
