ExTypesense.Key (ExTypesense v1.1.0)

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.

Same as create_key/2 but passes another connection.

Delete an API key given its ID.

Same as delete_key/2 but passes another connection.

Retrieve (metadata about) all keys.

Same as get_key/2 but passes another connection.

Retrieve (metadata about) all keys.

Same as list_keys/1 but passes another connection.

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)

Same as create_key/1

ExTypesense.create_key(body, [])
ExTypesense.create_key(%{api_key: xyz, host: ...}, body)
ExTypesense.create_key(OpenApiTypesense.Connection.new(), body)

create_key(conn, body, opts)

(since 1.0.0)

Same as create_key/2 but passes another connection.

ExTypesense.create_key(%{api_key: xyz, host: ...}, body, [])
ExTypesense.create_key(OpenApiTypesense.Connection.new(), body, [])

delete_key(key_id)

(since 1.0.0)

Delete an API key given its ID.

delete_key(key_id, opts)

(since 1.0.0)

Same as delete_key/1

ExTypesense.delete_key(6, [])
ExTypesense.delete_key(%{api_key: xyz, host: ...}, 7)
ExTypesense.delete_key(OpenApiTypesense.Connection.new(), 8)

delete_key(conn, key_id, opts)

(since 1.0.0)

Same as delete_key/2 but passes another connection.

ExTypesense.delete_key(%{api_key: xyz, host: ...}, 7, [])
ExTypesense.delete_key(OpenApiTypesense.Connection.new(), 8, [])

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)

Same as get_key/1

ExTypesense.get_key(6, [])
ExTypesense.get_key(%{api_key: xyz, host: ...}, 7)
ExTypesense.get_key(OpenApiTypesense.Connection.new(), 8)

get_key(conn, key_id, opts)

(since 1.0.0)

Same as get_key/2 but passes another connection.

ExTypesense.get_key(%{api_key: xyz, host: ...}, 7, [])
ExTypesense.get_key(OpenApiTypesense.Connection.new(), 8, [])

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(map() | OpenApiTypesense.Connection.t() | keyword()) ::
  {:ok, OpenApiTypesense.ApiKeysResponse.t()} | :error
@spec list_keys(map() | OpenApiTypesense.Connection.t() | keyword()) ::
  {:ok, OpenApiTypesense.ApiKeysResponse.t()} | :error

Same as list_keys/0

ExTypesense.list_keys([])
ExTypesense.list_keys(%{api_key: xyz, host: ...})
ExTypesense.list_keys(OpenApiTypesense.Connection.new())

list_keys(conn, opts)

(since 1.0.0)

Same as list_keys/1 but passes another connection.

ExTypesense.list_keys(%{api_key: xyz, host: ...}, [])
ExTypesense.list_keys(OpenApiTypesense.Connection.new(), [])