ExTypesense.Key (ExTypesense v2.0.1)

View Source

Typesense allows you to create API Keys with fine-grained access control. You can restrict access on a per-collection, per-action, per-record or even per-field level or a mixture of these.

More here: https://typesense.org/docs/latest/api/api-keys.html

Summary

Functions

Typesense allows you to create API Keys with fine-grained access control. You can restrict access on a per-collection, per-action, per-record or even per-field level or a mixture of these.

Delete an API key given its ID.

Retrieve (metadata about) all keys.

Retrieve (metadata about) all keys.

Functions

create_key(body)

(since 1.0.0)
@spec create_key(map()) ::
  {:ok, OpenApiTypesense.ApiKey.t()}
  | {:error, OpenApiTypesense.ApiResponse.t()}

Typesense allows you to create API Keys with fine-grained access control. You can restrict access on a per-collection, per-action, per-record or even per-field level or a mixture of these.

Examples

iex> body = %{
...>   actions: ["documents:search"],
...>   collections: ["companies"],
...>   description: "Search-only companies key"
...> }
iex> ExTypesense.create_key(body)

create_key(body, opts)

(since 1.0.0)
@spec create_key(
  map(),
  keyword()
) ::
  {:ok, OpenApiTypesense.ApiKey.t()}
  | {:error, OpenApiTypesense.ApiResponse.t()}

Same as create_key/1

Options

  • conn: The custom connection map or struct you passed

Examples

iex> conn = %{api_key: xyz, host: ...}
iex> ExTypesense.create_key(body, conn: conn)

iex> conn = OpenApiTypesense.Connection.new()
iex> ExTypesense.create_key(body, conn: conn)

iex> opts = [conn: conn]
iex> ExTypesense.create_key(body, opts)

delete_key(key_id)

(since 1.0.0)

Delete an API key given its ID.

delete_key(key_id, opts)

(since 1.0.0)
@spec delete_key(
  integer(),
  keyword()
) ::
  {:ok, OpenApiTypesense.ApiKeyDeleteResponse.t()}
  | {:error, OpenApiTypesense.ApiResponse.t()}

Same as delete_key/1

Options

  • conn: The custom connection map or struct you passed

Examples

iex> conn = %{api_key: xyz, host: ...}
iex> ExTypesense.delete_key(6, conn: conn)

iex> conn = OpenApiTypesense.Connection.new()
iex> ExTypesense.delete_key(7, conn: conn)

iex> opts = [conn: conn]
iex> ExTypesense.delete_key(8, opts)

get_key(key_id)

(since 1.0.0)
@spec get_key(integer()) ::
  {:ok, OpenApiTypesense.ApiKey.t()}
  | {:error, OpenApiTypesense.ApiResponse.t()}

Retrieve (metadata about) all keys.

get_key(key_id, opts)

(since 1.0.0)
@spec get_key(
  integer(),
  keyword()
) ::
  {:ok, OpenApiTypesense.ApiKey.t()}
  | {:error, OpenApiTypesense.ApiResponse.t()}

Same as get_key/1

Options

  • conn: The custom connection map or struct you passed

Examples

iex> conn = %{api_key: xyz, host: ...}
iex> ExTypesense.get_key(6, conn: conn)

iex> conn = OpenApiTypesense.Connection.new()
iex> ExTypesense.get_key(7, conn: conn)

iex> opts = [conn: conn]
iex> ExTypesense.get_key(8, opts)

list_keys()

(since 1.0.0)
@spec list_keys() :: {:ok, OpenApiTypesense.ApiKeysResponse.t()} | :error

Retrieve (metadata about) all keys.

list_keys(opts)

(since 1.0.0)
@spec list_keys(keyword()) :: {:ok, OpenApiTypesense.ApiKeysResponse.t()} | :error

Same as list_keys/0

Options

  • conn: The custom connection map or struct you passed

Examples

iex> conn = %{api_key: xyz, host: ...}
iex> ExTypesense.list_keys(conn: conn)

iex> conn = OpenApiTypesense.Connection.new()
iex> ExTypesense.list_keys(conn: conn)

iex> opts = [conn: conn]
iex> ExTypesense.list_keys(opts)