# `AshAuthzed.Adapter`
[🔗](https://github.com/boxxxie/ash_authzed/blob/v0.2.0/lib/ash_authzed/adapter.ex#L1)

Behaviour and unified dispatcher for ReBAC backends (`Licet`, `SpiceDB` HTTP, or `Memory`).

# `operation`

```elixir
@type operation() :: {:create | :touch | :delete, String.t()}
```

# `apply_schema`

```elixir
@callback apply_schema(schema_text :: String.t(), opts :: keyword()) ::
  :ok | {:ok, term()} | {:error, Exception.t()}
```

# `check`

```elixir
@callback check(
  resource :: String.t(),
  permission :: String.t(),
  subject :: String.t(),
  opts :: keyword()
) ::
  {:ok, boolean()} | {:error, Exception.t()}
```

# `lookup_resources`

```elixir
@callback lookup_resources(
  resource_type :: String.t(),
  permission :: String.t(),
  subject :: String.t(),
  opts :: keyword()
) :: {:ok, [String.t()]} | {:error, Exception.t()}
```

# `write_tuples`

```elixir
@callback write_tuples(operations :: [operation()], opts :: keyword()) ::
  {:ok, term()} | {:error, Exception.t()}
```

# `apply_schema`

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

Applies a `.zed` schema text to the backing adapter store.

# `check`

```elixir
@spec check(String.t(), String.t() | atom(), String.t(), keyword()) ::
  {:ok, boolean()} | {:error, Exception.t()}
```

Checks whether `subject` has `permission` on `resource`, returning `{:ok, boolean()}` or `{:error, Exception.t()}`.

# `check?`

```elixir
@spec check?(String.t(), String.t() | atom(), String.t(), keyword()) :: boolean()
```

Checks whether `subject` has `permission` on `resource`.
Returns `true` if allowed, `false` otherwise.

# `lookup_resources`

```elixir
@spec lookup_resources(String.t(), String.t() | atom(), String.t(), keyword()) ::
  {:ok, [String.t()]} | {:error, Exception.t()}
```

Looks up all resource IDs of `resource_type` on which `subject` has `permission`.

# `lookup_resources!`

```elixir
@spec lookup_resources!(String.t(), String.t() | atom(), String.t(), keyword()) :: [
  String.t()
]
```

Looks up all resource IDs of `resource_type` on which `subject` has `permission`, raising on error.

# `write_tuples`

```elixir
@spec write_tuples([operation()], keyword()) ::
  :ok | {:ok, term()} | {:error, Exception.t()}
```

Applies a list of relationship tuple operations (`{:create | :touch | :delete, tuple_string}`).

---

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