View Source Meilisearch.Key (meilisearch_ex v1.1.2)

Manipulate Meilisearch api keys. Key API

Link to this section Summary

Functions

Create a new Key in your Meilisearch instance. Meilisearch documentation

Delete an existing Index in your Meilisearch instance. Meilisearch documentation

Get a Key of your Meilisearch instance. Meilisearch documentation

List keys of your Meilisearch instance. Meilisearch documentation

Update an existing Key in your Meilisearch instance. Meilisearch documentation

Link to this section Types

@type t() :: %Meilisearch.Key{
  actions: [String.t()],
  createdAt: DateTime.t(),
  description: String.t() | nil,
  expiresAt: DateTime.t() | nil,
  indexes: [String.t()],
  key: String.t(),
  name: String.t() | nil,
  uid: String.t(),
  updatedAt: DateTime.t()
}

Link to this section Functions

@spec create(Tesla.Client.t(), %{
  uid: String.t() | nil,
  name: String.t() | nil,
  description: String.t() | nil,
  actions: [String.t()],
  indexes: [String.t()],
  expiresAt: DateTime.t() | nil
}) :: {:ok, t()} | {:error, Meilisearch.Client.error()}

Create a new Key in your Meilisearch instance. Meilisearch documentation

examples

Examples

iex> client = Meilisearch.Client.new(endpoint: "http://localhost:7700", key: "master_key_test")
iex> Meilisearch.Key.create(client, %{actions: ["*"], indexes: ["*"], expiresAt: nil})
{:ok, %{
  uid: "6062abda-a5aa-4414-ac91-ecd7944c0f8d",
  key: "d0552b41536279a0ad88bd595327b96f01176a60c2243e906c52ac02375f9bc4",
  name: nil,
  description: nil,
  actions: ["*"],
  indexes: ["*"],
  expiresAt: nil,
  createdAt: ~U[2021-08-12 10:00:00],
  updatedAt: ~U[2021-08-12 10:00:00],
}}
@spec delete(Tesla.Client.t(), String.t()) ::
  {:ok, nil} | {:error, Meilisearch.Client.error()}

Delete an existing Index in your Meilisearch instance. Meilisearch documentation

examples

Examples

iex> client = Meilisearch.Client.new(endpoint: "http://localhost:7700", key: "master_key_test")
iex> Meilisearch.Key.delete(client, "6062abda-a5aa-4414-ac91-ecd7944c0f8d")
{:ok, nil}
@spec get(Tesla.Client.t(), String.t()) ::
  {:ok, t()} | {:error, Meilisearch.Client.error()}

Get a Key of your Meilisearch instance. Meilisearch documentation

examples

Examples

iex> client = Meilisearch.Client.new(endpoint: "http://localhost:7700", key: "master_key_test")
iex> Meilisearch.Key.get(client, "74c9c733-3368-4738-bbe5-1d18a5fecb37")
{:ok, %{
  name: "Default Search API Key",
  description: "Use it to search from the frontend code",
  key: "0a6e572506c52ab0bd6195921575d23092b7f0c284ab4ac86d12346c33057f99",
  uid: "74c9c733-3368-4738-bbe5-1d18a5fecb37",
  actions: ["search"],
  indexes: ["*"],
  expiresAt: nil,
  createdAt: ~U[2021-08-12 10:00:00],
  updatedAt: ~U[2021-08-12 10:00:00]
}}
Link to this function

list(client, opts \\ [])

View Source
@spec list(Tesla.Client.t(), offset: integer(), limit: integer()) ::
  {:ok, Meilisearch.Pagination.t(t())} | {:error, Meilisearch.Client.error()}

List keys of your Meilisearch instance. Meilisearch documentation

examples

Examples

iex> client = Meilisearch.Client.new(endpoint: "http://localhost:7700", key: "master_key_test")
iex> Meilisearch.Key.list(client, limit: 20, offset: 0)
{:ok, %{offset: 0, limit: 20, total: 1, results: [%{
  name: "Default Search API Key",
  description: "Use it to search from the frontend code",
  key: "0a6e572506c52ab0bd6195921575d23092b7f0c284ab4ac86d12346c33057f99",
  uid: "74c9c733-3368-4738-bbe5-1d18a5fecb37",
  actions: ["search"],
  indexes: ["*"],
  expiresAt: nil,
  createdAt: ~U[2021-08-12 10:00:00],
  updatedAt: ~U[2021-08-12 10:00:00]
}]}}
Link to this function

update(client, key_uid, params)

View Source
@spec update(Tesla.Client.t(), String.t(), %{
  name: String.t() | nil,
  description: String.t() | nil
}) ::
  {:ok, t()} | {:error, Meilisearch.Client.error()}

Update an existing Key in your Meilisearch instance. Meilisearch documentation

examples

Examples

iex> client = Meilisearch.Client.new(endpoint: "http://localhost:7700", key: "master_key_test")
iex> Meilisearch.Key.update(client, "6062abda-a5aa-4414-ac91-ecd7944c0f8d", %{name: "Products/Reviews API key", description: "Manage documents: Products/Reviews API key"})
{:ok, %{
  uid: "6062abda-a5aa-4414-ac91-ecd7944c0f8d",
  key: "d0552b41536279a0ad88bd595327b96f01176a60c2243e906c52ac02375f9bc4",
  name: "Products/Reviews API key",
  description: "Manage documents: Products/Reviews API key",
  actions: ["*"],
  indexes: ["*"],
  expiresAt: nil,
  createdAt: ~U[2021-08-12 10:00:00],
  updatedAt: ~U[2021-08-12 10:00:00],
}}