Skip to content

Fix client.rb documentation #622

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2025-04-02 09:32:03 UTC using RuboCop version 1.75.1.
# on 2025-04-08 19:18:36 UTC using RuboCop version 1.75.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand Down Expand Up @@ -37,9 +37,9 @@ Style/IfUnlessModifier:
Exclude:
- 'lib/meilisearch/index.rb'

# Offense count: 1
# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings.
# URISchemes: http, https
Layout/LineLength:
Max: 155
Max: 160
48 changes: 24 additions & 24 deletions lib/meilisearch/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ class Client < HTTPRequest
#
# @see #indexes
# @see https://www.meilisearch.com/docs/reference/api/indexes#list-all-indexes Meilisearch API reference
# @param options [Hash<Symbol, Any>] limit and offset options
# @return [Hash<String, Any>]
# @param options [Hash{Symbol => Object}] limit and offset options
# @return [Hash{String => Object}]
# {index response object}[https://www.meilisearch.com/docs/reference/api/indexes#response]
def raw_indexes(options = {})
body = Utils.transform_attributes(options.transform_keys(&:to_sym).slice(:limit, :offset))
Expand Down Expand Up @@ -56,8 +56,8 @@ def swap_indexes(*options)
# Fetch indexes in instance.
#
# @see https://www.meilisearch.com/docs/reference/api/indexes#list-all-indexes Meilisearch API reference
# @param options [Hash<Symbol, Any>] limit and offset options
# @return [Hash<String, Any>]
# @param options [Hash{Symbol => Object}] limit and offset options
# @return [Hash{String => Object}]
# {index response object}[https://www.meilisearch.com/docs/reference/api/indexes#response]
# with results mapped to instances of {Index}
def indexes(options = {})
Expand All @@ -83,7 +83,7 @@ def indexes(options = {})
# @see https://www.meilisearch.com/docs/reference/api/indexes#create-an-index Meilisearch API reference
#
# @param index_uid [String] the uid of the new index
# @param options [Hash<Symbol, Any>, nil] snake_cased options of {the endpoint}[https://www.meilisearch.com/docs/reference/api/indexes#create-an-index]
# @param options [Hash{Symbol => Object}, nil] snake_cased options of {the endpoint}[https://www.meilisearch.com/docs/reference/api/indexes#create-an-index]
#
# @raise [ApiError]
# @return [Models::Task] the async task that creates the index
Expand Down Expand Up @@ -166,7 +166,7 @@ def fetch_raw_index(index_uid)
# @param offset [String, Integer, nil] skip the first +offset+ keys,
# useful for paging.
#
# @return [Hash<String, Any>] a {keys response}[https://www.meilisearch.com/docs/reference/api/keys#response]
# @return [Hash{String => Object}] a {keys response}[https://www.meilisearch.com/docs/reference/api/keys#response]
def keys(limit: nil, offset: nil)
body = { limit: limit, offset: offset }.compact

Expand All @@ -192,7 +192,7 @@ def keys(limit: nil, offset: nil)
# a hash of the uid and the master key that is the key's
# {key}[https://www.meilisearch.com/docs/reference/api/keys#key] field
#
# @return [Hash<String, Any>] a {key object}[https://www.meilisearch.com/docs/reference/api/keys#key-object]
# @return [Hash{String => Object}] a {key object}[https://www.meilisearch.com/docs/reference/api/keys#key-object]
def key(uid_or_key)
http_get "/keys/#{uid_or_key}"
end
Expand All @@ -211,13 +211,13 @@ def key(uid_or_key)
# @see #keys #keys to get all keys in the instance
# @see #key #key to fetch one key
# @see https://www.meilisearch.com/docs/reference/api/keys#create-a-key Meilisearch API reference
# @param key_options [Hash<Symbol, Any>] the key options of which the required are
# @param key_options [Hash{Symbol => Object}] the key options of which the required are
# - +:actions+ +Array+ of API actions allowed for key, +["*"]+ for all
# - +:indexes+ +Array+ of indexes key can act on, +["*"]+ for all
# - +:expires_at+ expiration datetime in
# {RFC 3339}[https://www.ietf.org/rfc/rfc3339.txt] format, nil if the key never expires
#
# @return [Hash<String, Any>] a {key object}[https://www.meilisearch.com/docs/reference/api/keys#key-object]
# @return [Hash{String => Object}] a {key object}[https://www.meilisearch.com/docs/reference/api/keys#key-object]
def create_key(key_options)
body = Utils.transform_attributes(key_options)

Expand All @@ -234,9 +234,9 @@ def create_key(key_options)
# @see #keys #keys to get all keys in the instance
# @see #key #key to fetch one key
# @see https://www.meilisearch.com/docs/reference/api/keys#update-a-key Meilisearch API reference
# @param key_options [Hash<Symbol, Any>] see {#create_key}
# @param key_options [Hash{Symbol => Object}] see {#create_key}
#
# @return [Hash<String, Any>] a {key object}[https://www.meilisearch.com/docs/reference/api/keys#key-object]
# @return [Hash{String => Object}] a {key object}[https://www.meilisearch.com/docs/reference/api/keys#key-object]
def update_key(uid_or_key, key_options)
body = Utils.transform_attributes(key_options)
body = body.slice('description', 'name')
Expand Down Expand Up @@ -282,7 +282,7 @@ def healthy?
# Check health of Meilisearch instance.
#
# @see https://www.meilisearch.com/docs/reference/api/health#get-health Meilisearch API reference
# @return [Hash<String, Any>] the health report from the Meilisearch instance
# @return [Hash{String => Object}] the health report from the Meilisearch instance
def health
http_get '/health'
end
Expand All @@ -292,7 +292,7 @@ def health
# Check version of Meilisearch server
#
# @see https://www.meilisearch.com/docs/reference/api/version#get-version-of-meilisearch Meilisearch API reference
# @return [Hash<String, String>] package version and last commit of Meilisearch server, see
# @return [Hash{String => String}] package version and last commit of Meilisearch server, see
# {version object}[https://www.meilisearch.com/docs/reference/api/version#version-object]
def version
http_get '/version'
Expand All @@ -302,7 +302,7 @@ def version
#
# @see Index#stats
# @see https://www.meilisearch.com/docs/reference/api/stats#get-stats-of-all-indexes Meilisearch API reference
# @return [Hash<String, Any>] see {stats object}[https://www.meilisearch.com/docs/reference/api/stats#stats-object]
# @return [Hash{String => Object}] see {stats object}[https://www.meilisearch.com/docs/reference/api/stats#stats-object]
def stats
http_get '/stats'
end
Expand Down Expand Up @@ -367,8 +367,8 @@ def create_snapshot
#
# @see https://www.meilisearch.com/docs/reference/api/tasks#task-object The Task Object
# @see https://www.meilisearch.com/docs/reference/api/tasks#cancel-tasks Meilisearch API reference
# @param options [Hash<Symbol, Any>] task search options as snake cased symbols, see the API reference
# @return [Hash<String, Any>] a Meilisearch task that is canceling other tasks
# @param options [Hash{Symbol => Object}] task search options as snake cased symbols, see the API reference
# @return [Hash{String => Object}] a Meilisearch task that is canceling other tasks
def cancel_tasks(options = {})
task_endpoint.cancel_tasks(options)
end
Expand All @@ -387,8 +387,8 @@ def cancel_tasks(options = {})
#
# @see https://www.meilisearch.com/docs/reference/api/tasks#task-object The Task Object
# @see https://www.meilisearch.com/docs/reference/api/tasks#cancel-tasks Meilisearch API reference
# @param options [Hash<Symbol, Any>] task search options as snake cased symbols, see the API reference
# @return [Hash<String, Any>] a Meilisearch task that is canceling other tasks
# @param options [Hash{Symbol => Object}] task search options as snake cased symbols, see the API reference
# @return [Hash{String => Object}] a Meilisearch task that is canceling other tasks
def delete_tasks(options = {})
task_endpoint.delete_tasks(options)
end
Expand All @@ -403,8 +403,8 @@ def delete_tasks(options = {})
#
# @see https://www.meilisearch.com/docs/reference/api/tasks#task-object The Task Object
# @see https://www.meilisearch.com/docs/reference/api/tasks#get-tasks Meilisearch API reference
# @param options [Hash<Symbol, Any>] task search options as snake cased symbols, see the API reference
# @return [Hash<String, Any>] results of the task search, see API reference
# @param options [Hash{Symbol => Object}] task search options as snake cased symbols, see the API reference
# @return [Hash{String => Object}] results of the task search, see API reference
def tasks(options = {})
task_endpoint.task_list(options)
end
Expand All @@ -420,7 +420,7 @@ def tasks(options = {})
# @see https://www.meilisearch.com/docs/reference/api/tasks#task-object The Task Object
# @see https://www.meilisearch.com/docs/reference/api/tasks#get-one-task Meilisearch API reference
# @param task_uid [String] uid of the requested task
# @return [Hash<String, Any>] a Meilisearch task object (see above)
# @return [Hash{String => Object}] a Meilisearch task object (see above)
def task(task_uid)
task_endpoint.task(task_uid)
end
Expand All @@ -446,8 +446,8 @@ def wait_for_task(
#
# @see https://www.meilisearch.com/docs/reference/api/batches#batch-object The Batch Object
# @see https://www.meilisearch.com/docs/reference/api/batches#get-batches Meilisearch API reference
# @param options [Hash<Symbol, Any>] task search options as snake cased symbols, see the API reference
# @return [Hash<String, Any>] results of the batches search, see API reference
# @param options [Hash{Symbol => Object}] task search options as snake cased symbols, see the API reference
# @return [Hash{String => Object}] results of the batches search, see API reference
def batches(options = {})
http_get '/batches', options
end
Expand All @@ -460,7 +460,7 @@ def batches(options = {})
# @see https://www.meilisearch.com/docs/reference/api/batches#batch-object The Batch Object
# @see https://www.meilisearch.com/docs/reference/api/batches#get-one-batch Meilisearch API reference
# @param batch_uid [String] the uid of the request batch
# @return [Hash<String, Any>] a batch object, see above
# @return [Hash{String => Object}] a batch object, see above
def batch(batch_uid)
http_get "/batches/#{batch_uid}"
end
Expand Down