algoliasearch 1.20.1 → 1.21.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +1 -1
- data/Rakefile +4 -1
- data/lib/algolia/client.rb +104 -68
- data/lib/algolia/index.rb +221 -155
- data/lib/algolia/protocol.rb +12 -16
- data/lib/algolia/version.rb +1 -1
- data/spec/client_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 166a052570141d9782b6faed8c7b3731c2d4553d1628e3d7e903bb24edb276d1
|
4
|
+
data.tar.gz: ccb0597728f4b692b8841594a8b42d83f839a22dd1f3abf03e1caf2d52fa266f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ed95969c8417cbd9fee0a89600965bf688d8536719ffea8481c31143796a2235b5e441392a69d8e75961e5c3dfabe34c9d6c75f12cdae8a7aac56d5e7327f2c
|
7
|
+
data.tar.gz: b620520144dcf52e870bd07fa1d51a3f227f9cd83e815d183bec770471a56d066afc32e898317ad5e593b5eec10b70f5cbd78d9b04ae25e509d0092a235f0b9d
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## [1.21.0](https://github.com/algolia/algoliasearch-client-ruby/releases/tag/1.21.0) (2018-05-24)
|
2
|
+
|
3
|
+
* Fix(tests): fix warning for unspecified exception (#287)
|
4
|
+
* Fix release task missing github link (#291)
|
5
|
+
* Api review (#292)
|
6
|
+
|
1
7
|
## [1.20.1](https://github.com/algolia/algoliasearch-client-ruby/releases/tag/1.20.1) (2018-05-15)
|
2
8
|
|
3
9
|
* Fix changelog link in gemspec (#290)
|
data/Gemfile.lock
CHANGED
data/Rakefile
CHANGED
@@ -35,6 +35,8 @@ RSpec::Core::RakeTask.new(:spec)
|
|
35
35
|
task :default => :spec
|
36
36
|
|
37
37
|
namespace :algolia do
|
38
|
+
GIT_TAG_URL = 'https://github.com/algolia/algoliasearch-client-ruby/releases/tag/'
|
39
|
+
|
38
40
|
def last_commit_date
|
39
41
|
`git log -1 --date=short --format=%cd`.chomp
|
40
42
|
end
|
@@ -51,9 +53,10 @@ namespace :algolia do
|
|
51
53
|
task :changelog, [:version] do |t, args|
|
52
54
|
# Filters-out commits containing some keywords and adds header
|
53
55
|
exceptions_regexp = Regexp.union(['README'])
|
56
|
+
title = "## [%s](%s%s) (%s)\n\n" % [args[:version], GIT_TAG_URL, args[:version], last_commit_date]
|
54
57
|
changes = changelog.each_line
|
55
58
|
.map { |line| (exceptions_regexp === line) ? nil : "* #{line.capitalize}" }
|
56
|
-
.prepend(
|
59
|
+
.prepend(title)
|
57
60
|
.append("\n\n")
|
58
61
|
.join
|
59
62
|
|
data/lib/algolia/client.rb
CHANGED
@@ -9,8 +9,10 @@ require 'base64'
|
|
9
9
|
module Algolia
|
10
10
|
WAIT_TASK_DEFAULT_TIME_BEFORE_RETRY = 100
|
11
11
|
|
12
|
+
#
|
12
13
|
# A class which encapsulates the HTTPS communication with the Algolia
|
13
14
|
# API server. Uses the HTTPClient library for low-level HTTP communication.
|
15
|
+
#
|
14
16
|
class Client
|
15
17
|
attr_reader :ssl, :ssl_version, :hosts, :search_hosts, :application_id, :api_key, :headers, :connect_timeout, :send_timeout, :receive_timeout, :search_timeout, :batch_timeout
|
16
18
|
|
@@ -21,7 +23,7 @@ module Algolia
|
|
21
23
|
DEFAULT_SEARCH_TIMEOUT = 5
|
22
24
|
|
23
25
|
def initialize(data = {})
|
24
|
-
raise ArgumentError.new(
|
26
|
+
raise ArgumentError.new('No APPLICATION_ID provided, please set :application_id') if data[:application_id].nil?
|
25
27
|
|
26
28
|
@ssl = data[:ssl].nil? ? true : data[:ssl]
|
27
29
|
@ssl_version = data[:ssl_version].nil? ? nil : data[:ssl_version]
|
@@ -67,6 +69,7 @@ module Algolia
|
|
67
69
|
#
|
68
70
|
# Allow to use IP rate limit when you have a proxy between end-user and Algolia.
|
69
71
|
# This option will set the X-Forwarded-For HTTP header with the client IP and the X-Forwarded-API-Key with the API Key having rate limits.
|
72
|
+
#
|
70
73
|
# @param admin_api_key the admin API Key you can find in your dashboard
|
71
74
|
# @param end_user_ip the end user IP (you can use both IPV4 or IPV6 syntax)
|
72
75
|
# @param rate_limit_api_key the API key on which you have a rate limit
|
@@ -123,10 +126,10 @@ module Algolia
|
|
123
126
|
requests = {
|
124
127
|
:requests => queries.map do |query|
|
125
128
|
query = query.dup
|
126
|
-
|
127
|
-
raise ArgumentError.new("Missing '#{index_name_key}' option") if
|
128
|
-
encoded_params = Hash[query.map { |k,v| [k.to_s, v.is_a?(Array) ? v.to_json : v] }]
|
129
|
-
{ :indexName =>
|
129
|
+
index_name = query.delete(index_name_key) || query.delete(index_name_key.to_s)
|
130
|
+
raise ArgumentError.new("Missing '#{index_name_key}' option") if index_name.nil?
|
131
|
+
encoded_params = Hash[query.map { |k, v| [k.to_s, v.is_a?(Array) ? v.to_json : v] }]
|
132
|
+
{ :indexName => index_name, :params => Protocol.to_query(encoded_params) }
|
130
133
|
end
|
131
134
|
}
|
132
135
|
post(Protocol.multiple_queries_uri(strategy), requests.to_json, :search, request_options)
|
@@ -146,17 +149,19 @@ module Algolia
|
|
146
149
|
|
147
150
|
#
|
148
151
|
# Move an existing index.
|
152
|
+
#
|
149
153
|
# @param src_index the name of index to copy.
|
150
154
|
# @param dst_index the new index name that will contains a copy of srcIndexName (destination will be overriten if it already exist).
|
151
155
|
# @param request_options contains extra parameters to send with your query
|
152
156
|
#
|
153
157
|
def move_index(src_index, dst_index, request_options = {})
|
154
|
-
request = {
|
158
|
+
request = { 'operation' => 'move', 'destination' => dst_index };
|
155
159
|
post(Protocol.index_operation_uri(src_index), request.to_json, :write, request_options)
|
156
160
|
end
|
157
161
|
|
158
162
|
#
|
159
163
|
# Move an existing index and wait until the move has been processed
|
164
|
+
#
|
160
165
|
# @param src_index the name of index to copy.
|
161
166
|
# @param dst_index the new index name that will contains a copy of srcIndexName (destination will be overriten if it already exist).
|
162
167
|
# @param request_options contains extra parameters to send with your query
|
@@ -169,19 +174,21 @@ module Algolia
|
|
169
174
|
|
170
175
|
#
|
171
176
|
# Copy an existing index.
|
177
|
+
#
|
172
178
|
# @param src_index the name of index to copy.
|
173
179
|
# @param dst_index the new index name that will contains a copy of srcIndexName (destination will be overriten if it already exist).
|
174
180
|
# @param scope the optional list of scopes to copy (all if not specified).
|
175
181
|
# @param request_options contains extra parameters to send with your query
|
176
182
|
#
|
177
183
|
def copy_index(src_index, dst_index, scope = nil, request_options = {})
|
178
|
-
request = {
|
179
|
-
request[
|
184
|
+
request = { 'operation' => 'copy', 'destination' => dst_index };
|
185
|
+
request['scope'] = scope unless scope.nil?
|
180
186
|
post(Protocol.index_operation_uri(src_index), request.to_json, :write, request_options)
|
181
187
|
end
|
182
188
|
|
183
189
|
#
|
184
190
|
# Copy an existing index and wait until the copy has been processed.
|
191
|
+
#
|
185
192
|
# @param src_index the name of index to copy.
|
186
193
|
# @param dst_index the new index name that will contains a copy of srcIndexName (destination will be overriten if it already exist).
|
187
194
|
# @param scope the optional list of scopes to copy (all if not specified).
|
@@ -193,6 +200,7 @@ module Algolia
|
|
193
200
|
res
|
194
201
|
end
|
195
202
|
|
203
|
+
#
|
196
204
|
# Delete an index
|
197
205
|
# @param name the name of the index to delete
|
198
206
|
# @param request_options contains extra parameters to send with your query
|
@@ -201,6 +209,7 @@ module Algolia
|
|
201
209
|
init_index(name).delete(request_options)
|
202
210
|
end
|
203
211
|
|
212
|
+
#
|
204
213
|
# Delete an index and wait until the deletion has been processed.
|
205
214
|
# @param name the name of the index to delete
|
206
215
|
# @param request_options contains extra parameters to send with your query
|
@@ -236,16 +245,20 @@ module Algolia
|
|
236
245
|
get(Protocol.logs(offset, length, type), :write, request_options)
|
237
246
|
end
|
238
247
|
|
248
|
+
#
|
239
249
|
# List all existing user keys with their associated ACLs
|
240
250
|
#
|
241
251
|
# @param request_options contains extra parameters to send with your query
|
252
|
+
#
|
242
253
|
def list_api_keys(request_options = {})
|
243
254
|
get(Protocol.keys_uri, :read, request_options)
|
244
255
|
end
|
245
256
|
|
257
|
+
#
|
246
258
|
# Get ACL of a user key
|
247
259
|
#
|
248
260
|
# @param request_options contains extra parameters to send with your query
|
261
|
+
#
|
249
262
|
def get_api_key(key, request_options = {})
|
250
263
|
get(Protocol.key_uri(key), :read, request_options)
|
251
264
|
end
|
@@ -263,7 +276,7 @@ module Algolia
|
|
263
276
|
# - settings : allows to get index settings (https only)
|
264
277
|
# - editSettings : allows to change index settings (https only)
|
265
278
|
#
|
266
|
-
# @param
|
279
|
+
# @param object The list of parameters for this key.
|
267
280
|
# Defined by a Hash that can contain the following values:
|
268
281
|
# - acl: array of string
|
269
282
|
# - indexes: array of string
|
@@ -275,13 +288,11 @@ module Algolia
|
|
275
288
|
# - maxQueriesPerIPPerHour: integer
|
276
289
|
# @param request_options contains extra parameters to send with your query - Default = {}
|
277
290
|
#
|
278
|
-
def add_api_key(
|
279
|
-
if
|
280
|
-
params = {
|
281
|
-
:acl => obj
|
282
|
-
}
|
291
|
+
def add_api_key(object, request_options = {}, max_queries_per_IP_per_hour = 0, max_hits_per_query = 0, indexes = nil)
|
292
|
+
if object.instance_of?(Array)
|
293
|
+
params = { :acl => object }
|
283
294
|
else
|
284
|
-
params =
|
295
|
+
params = object
|
285
296
|
end
|
286
297
|
|
287
298
|
validity = 0
|
@@ -290,23 +301,18 @@ module Algolia
|
|
290
301
|
request_options = {}
|
291
302
|
end
|
292
303
|
|
293
|
-
if validity != 0
|
294
|
-
params['validity'] = validity.to_i
|
295
|
-
end
|
296
|
-
if maxQueriesPerIPPerHour != 0
|
297
|
-
params['maxQueriesPerIPPerHour'] = maxQueriesPerIPPerHour.to_i
|
298
|
-
end
|
299
|
-
if maxHitsPerQuery != 0
|
300
|
-
params['maxHitsPerQuery'] = maxHitsPerQuery.to_i
|
301
|
-
end
|
302
304
|
params[:indexes] = indexes if indexes
|
305
|
+
params['validity'] = validity.to_i if validity != 0
|
306
|
+
params['maxHitsPerQuery'] = max_hits_per_query.to_i if max_hits_per_query != 0
|
307
|
+
params['maxQueriesPerIPPerHour'] = max_queries_per_IP_per_hour.to_i if max_queries_per_IP_per_hour != 0
|
308
|
+
|
303
309
|
post(Protocol.keys_uri, params.to_json, :write, request_options)
|
304
310
|
end
|
305
311
|
|
306
312
|
#
|
307
313
|
# Update a user key
|
308
314
|
#
|
309
|
-
# Deprecated call was update_api_key(key, acl, validity,
|
315
|
+
# Deprecated call was update_api_key(key, acl, validity, max_queries_per_IP_per_hour, max_hits_per_query, indexes)
|
310
316
|
#
|
311
317
|
# ACL can contain an array with those strings:
|
312
318
|
# - search: allow to search (https and http)
|
@@ -317,7 +323,7 @@ module Algolia
|
|
317
323
|
# - editSettings : allows to change index settings (https only)
|
318
324
|
#
|
319
325
|
# @param key API Key to update
|
320
|
-
# @param
|
326
|
+
# @param object The list of parameters for this key.
|
321
327
|
# Defined by a Hash that can contain the following values:
|
322
328
|
# - acl: array of string
|
323
329
|
# - indexes: array of string
|
@@ -329,13 +335,11 @@ module Algolia
|
|
329
335
|
# - maxQueriesPerIPPerHour: integer
|
330
336
|
# @param request_options contains extra parameters to send with your query - Default = {}
|
331
337
|
#
|
332
|
-
def update_api_key(key,
|
333
|
-
if
|
334
|
-
params = {
|
335
|
-
:acl => obj
|
336
|
-
}
|
338
|
+
def update_api_key(key, object, request_options = {}, max_queries_per_IP_per_hour = 0, max_hits_per_query = 0, indexes = nil)
|
339
|
+
if object.instance_of?(Array)
|
340
|
+
params = { :acl => object }
|
337
341
|
else
|
338
|
-
params =
|
342
|
+
params = object
|
339
343
|
end
|
340
344
|
|
341
345
|
validity = 0
|
@@ -344,44 +348,44 @@ module Algolia
|
|
344
348
|
request_options = {}
|
345
349
|
end
|
346
350
|
|
347
|
-
if validity != 0
|
348
|
-
params['validity'] = validity.to_i
|
349
|
-
end
|
350
|
-
if maxQueriesPerIPPerHour != 0
|
351
|
-
params['maxQueriesPerIPPerHour'] = maxQueriesPerIPPerHour.to_i
|
352
|
-
end
|
353
|
-
if maxHitsPerQuery != 0
|
354
|
-
params['maxHitsPerQuery'] = maxHitsPerQuery.to_i
|
355
|
-
end
|
356
351
|
params[:indexes] = indexes if indexes
|
352
|
+
params['validity'] = validity.to_i if validity != 0
|
353
|
+
params['maxQueriesPerIPPerHour'] = max_queries_per_IP_per_hour.to_i if max_queries_per_IP_per_hour != 0
|
354
|
+
params['maxHitsPerQuery'] = max_hits_per_query.to_i if max_hits_per_query != 0
|
355
|
+
|
357
356
|
put(Protocol.key_uri(key), params.to_json, :write, request_options)
|
358
357
|
end
|
359
358
|
|
359
|
+
#
|
360
360
|
# Delete an existing user key
|
361
361
|
#
|
362
362
|
def delete_api_key(key, request_options = {})
|
363
363
|
delete(Protocol.key_uri(key), :write, request_options)
|
364
364
|
end
|
365
365
|
|
366
|
+
#
|
366
367
|
# Send a batch request targeting multiple indices
|
367
368
|
#
|
368
|
-
def batch(
|
369
|
-
post(Protocol.batch_uri, {
|
369
|
+
def batch(operations, request_options = {})
|
370
|
+
post(Protocol.batch_uri, { 'requests' => operations }.to_json, :batch, request_options)
|
370
371
|
end
|
371
372
|
|
373
|
+
#
|
372
374
|
# Send a batch request targeting multiple indices and wait the end of the indexing
|
373
375
|
#
|
374
|
-
def batch!(
|
375
|
-
res = batch(
|
376
|
+
def batch!(operations, request_options = {})
|
377
|
+
res = batch(operations, request_options)
|
376
378
|
res['taskID'].each do |index, taskID|
|
377
379
|
init_index(index).wait_task(taskID, WAIT_TASK_DEFAULT_TIME_BEFORE_RETRY, request_options)
|
378
380
|
end
|
379
381
|
end
|
380
382
|
|
383
|
+
#
|
381
384
|
# Perform an HTTP request for the given uri and method
|
382
385
|
# with common basic response handling. Will raise a
|
383
386
|
# AlgoliaProtocolError if the response has an error status code,
|
384
387
|
# and will return the parsed JSON body on success, if there is one.
|
388
|
+
#
|
385
389
|
def request(uri, method, data = nil, type = :write, request_options = {})
|
386
390
|
exceptions = []
|
387
391
|
|
@@ -439,7 +443,9 @@ module Algolia
|
|
439
443
|
|
440
444
|
private
|
441
445
|
|
446
|
+
#
|
442
447
|
# This method returns a thread-local array of sessions
|
448
|
+
#
|
443
449
|
def thread_local_hosts(read)
|
444
450
|
thread_hosts_key = read ? "algolia_search_hosts_#{application_id}" : "algolia_hosts_#{application_id}"
|
445
451
|
Thread.current[thread_hosts_key] ||= (read ? search_hosts : hosts).each_with_index.map do |host, i|
|
@@ -527,7 +533,9 @@ module Algolia
|
|
527
533
|
|
528
534
|
#
|
529
535
|
# Allow to use IP rate limit when you have a proxy between end-user and Algolia.
|
530
|
-
# This option will set the X-Forwarded-For HTTP header with the client IP and the
|
536
|
+
# This option will set the X-Forwarded-For HTTP header with the client IP and the
|
537
|
+
# X-Forwarded-API-Key with the API Key having rate limits.
|
538
|
+
#
|
531
539
|
# @param admin_api_key the admin API Key you can find in your dashboard
|
532
540
|
# @param end_user_ip the end user IP (you can use both IPV4 or IPV6 syntax)
|
533
541
|
# @param rate_limit_api_key the API key on which you have a rate limit
|
@@ -560,7 +568,7 @@ module Algolia
|
|
560
568
|
#
|
561
569
|
def Algolia.generate_secured_api_key(private_api_key, tag_filters_or_params, user_token = nil)
|
562
570
|
if tag_filters_or_params.is_a?(Hash) && user_token.nil?
|
563
|
-
encoded_params = Hash[tag_filters_or_params.map { |k,v| [k.to_s, v.is_a?(Array) ? v.to_json : v] }]
|
571
|
+
encoded_params = Hash[tag_filters_or_params.map { |k, v| [k.to_s, v.is_a?(Array) ? v.to_json : v] }]
|
564
572
|
query_str = Protocol.to_query(encoded_params)
|
565
573
|
hmac = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), private_api_key, query_str)
|
566
574
|
Base64.encode64("#{hmac}#{query_str}").gsub("\n", '')
|
@@ -596,8 +604,9 @@ module Algolia
|
|
596
604
|
|
597
605
|
#
|
598
606
|
# Move an existing index.
|
607
|
+
#
|
599
608
|
# @param src_index the name of index to copy.
|
600
|
-
# @param dst_index the new index name that will contains a copy of
|
609
|
+
# @param dst_index the new index name that will contains a copy of src_index_name (destination will be overriten if it already exist).
|
601
610
|
# @param request_options contains extra parameters to send with your query
|
602
611
|
#
|
603
612
|
def Algolia.move_index(src_index, dst_index, request_options = {})
|
@@ -606,8 +615,9 @@ module Algolia
|
|
606
615
|
|
607
616
|
#
|
608
617
|
# Move an existing index and wait until the move has been processed
|
618
|
+
#
|
609
619
|
# @param src_index the name of index to copy.
|
610
|
-
# @param dst_index the new index name that will contains a copy of
|
620
|
+
# @param dst_index the new index name that will contains a copy of src_index_name (destination will be overriten if it already exist).
|
611
621
|
# @param request_options contains extra parameters to send with your query
|
612
622
|
#
|
613
623
|
def Algolia.move_index!(src_index, dst_index, request_options = {})
|
@@ -616,8 +626,9 @@ module Algolia
|
|
616
626
|
|
617
627
|
#
|
618
628
|
# Copy an existing index.
|
629
|
+
#
|
619
630
|
# @param src_index the name of index to copy.
|
620
|
-
# @param dst_index the new index name that will contains a copy of
|
631
|
+
# @param dst_index the new index name that will contains a copy of src_index_name (destination will be overriten if it already exist).
|
621
632
|
# @param scope the optional list of scopes to copy (all if not specified).
|
622
633
|
# @param request_options contains extra parameters to send with your query
|
623
634
|
#
|
@@ -627,8 +638,9 @@ module Algolia
|
|
627
638
|
|
628
639
|
#
|
629
640
|
# Copy an existing index and wait until the copy has been processed.
|
641
|
+
#
|
630
642
|
# @param src_index the name of index to copy.
|
631
|
-
# @param dst_index the new index name that will contains a copy of
|
643
|
+
# @param dst_index the new index name that will contains a copy of src_index_name (destination will be overriten if it already exist).
|
632
644
|
# @param scope the optional list of scopes to copy (all if not specified).
|
633
645
|
# @param request_options contains extra parameters to send with your query
|
634
646
|
#
|
@@ -636,12 +648,14 @@ module Algolia
|
|
636
648
|
Algolia.client.copy_index!(src_index, dst_index, scope, request_options)
|
637
649
|
end
|
638
650
|
|
651
|
+
#
|
639
652
|
# Delete an index
|
640
653
|
#
|
641
654
|
def Algolia.delete_index(name, request_options = {})
|
642
655
|
Algolia.client.delete_index(name, request_options)
|
643
656
|
end
|
644
657
|
|
658
|
+
#
|
645
659
|
# Delete an index and wait until the deletion has been processed.
|
646
660
|
#
|
647
661
|
def Algolia.delete_index!(name, request_options = {})
|
@@ -660,26 +674,34 @@ module Algolia
|
|
660
674
|
Algolia.client.get_logs(options, length, type)
|
661
675
|
end
|
662
676
|
|
677
|
+
#
|
663
678
|
# List all existing user keys with their associated ACLs
|
664
679
|
#
|
665
680
|
# @param request_options contains extra parameters to send with your query
|
681
|
+
#
|
666
682
|
def Algolia.list_api_keys(request_options = {})
|
667
683
|
Algolia.client.list_api_keys(request_options)
|
668
684
|
end
|
669
685
|
|
686
|
+
#
|
670
687
|
# Deprecated
|
688
|
+
#
|
671
689
|
def Algolia.list_user_keys(request_options = {})
|
672
690
|
Algolia.client.list_api_keys(request_options)
|
673
691
|
end
|
674
692
|
|
693
|
+
#
|
675
694
|
# Get ACL of a user key
|
676
695
|
#
|
677
696
|
# @param request_options contains extra parameters to send with your query
|
697
|
+
#
|
678
698
|
def Algolia.get_api_key(key, request_options = {})
|
679
699
|
Algolia.client.get_api_key(key, request_options)
|
680
700
|
end
|
681
701
|
|
702
|
+
#
|
682
703
|
# Deprecated
|
704
|
+
#
|
683
705
|
def Algolia.get_user_key(key, request_options = {})
|
684
706
|
Algolia.client.get_user_key(key, request_options)
|
685
707
|
end
|
@@ -687,7 +709,7 @@ module Algolia
|
|
687
709
|
#
|
688
710
|
# Create a new user key
|
689
711
|
#
|
690
|
-
# Deprecated call was add_api_key(acl, validity,
|
712
|
+
# Deprecated call was add_api_key(acl, validity, max_queries_per_IP_per_hour, max_hits_per_query, indexes)
|
691
713
|
#
|
692
714
|
# ACL can contain an array with those strings:
|
693
715
|
# - search: allow to search (https and http)
|
@@ -697,7 +719,7 @@ module Algolia
|
|
697
719
|
# - settings : allows to get index settings (https only)
|
698
720
|
# - editSettings : allows to change index settings (https only)
|
699
721
|
#
|
700
|
-
# @param
|
722
|
+
# @param object can be two different parameters:
|
701
723
|
# The list of parameters for this key. Defined by a NSDictionary that
|
702
724
|
# can contains the following values:
|
703
725
|
# - acl: array of string
|
@@ -705,24 +727,26 @@ module Algolia
|
|
705
727
|
# - validity: int
|
706
728
|
# - referers: array of string
|
707
729
|
# - description: string
|
708
|
-
# -
|
730
|
+
# - max_hits_per_query: integer
|
709
731
|
# - queryParameters: string
|
710
|
-
# -
|
732
|
+
# - max_queries_per_IP_per_hour: integer
|
711
733
|
# @param request_options contains extra parameters to send with your query - Default = {}
|
712
734
|
#
|
713
|
-
def Algolia.add_api_key(
|
714
|
-
Algolia.client.add_api_key(
|
735
|
+
def Algolia.add_api_key(object, request_options = {}, max_queries_per_IP_per_hour = 0, max_hits_per_query = 0, indexes = nil)
|
736
|
+
Algolia.client.add_api_key(object, request_options, max_queries_per_IP_per_hour, max_hits_per_query, indexes)
|
715
737
|
end
|
716
738
|
|
739
|
+
#
|
717
740
|
# Deprecated
|
718
|
-
|
719
|
-
|
741
|
+
#
|
742
|
+
def Algolia.add_user_key(object, request_options = {}, max_queries_per_IP_per_hour = 0, max_hits_per_query = 0, indexes = nil)
|
743
|
+
Algolia.client.add_api_key(object, request_options, max_queries_per_IP_per_hour, max_hits_per_query, indexes)
|
720
744
|
end
|
721
745
|
|
722
746
|
#
|
723
747
|
# Update a user key
|
724
748
|
#
|
725
|
-
# Deprecated call was update_api_key(key, acl, validity, maxQueriesPerIPPerHour,
|
749
|
+
# Deprecated call was update_api_key(key, acl, validity, maxQueriesPerIPPerHour, max_hits_per_query, indexes)
|
726
750
|
#
|
727
751
|
# ACL can contain an array with those strings:
|
728
752
|
# - search: allow to search (https and http)
|
@@ -733,48 +757,60 @@ module Algolia
|
|
733
757
|
# - editSettings : allows to change index settings (https only)
|
734
758
|
#
|
735
759
|
# @param key API Key to update
|
736
|
-
# @param
|
760
|
+
# @param object The list of parameters for this key.
|
737
761
|
# Defined by a Hash that can contain the following values:
|
738
762
|
# - acl: array of string
|
739
763
|
# - indexes: array of string
|
740
764
|
# - validity: int
|
741
765
|
# - referers: array of string
|
742
766
|
# - description: string
|
743
|
-
# -
|
767
|
+
# - max_hits_per_query: integer
|
744
768
|
# - queryParameters: string
|
745
|
-
# -
|
769
|
+
# - max_queries_per_IP_per_hour: integer
|
746
770
|
# @param request_options contains extra parameters to send with your query - Default = {}
|
747
771
|
#
|
748
|
-
def Algolia.update_api_key(key,
|
749
|
-
Algolia.client.update_api_key(key,
|
772
|
+
def Algolia.update_api_key(key, object, request_options = {}, max_queries_per_IP_per_hour = 0, max_hits_per_query = 0, indexes = nil)
|
773
|
+
Algolia.client.update_api_key(key, object, request_options, max_queries_per_IP_per_hour, max_hits_per_query, indexes)
|
750
774
|
end
|
751
775
|
|
776
|
+
#
|
752
777
|
# Deprecated
|
753
|
-
|
754
|
-
|
778
|
+
#
|
779
|
+
def Algolia.update_user_key(key, object, request_options = {}, max_queries_per_IP_per_hour = 0, max_hits_per_query = 0, indexes = nil)
|
780
|
+
Algolia.client.update_api_key(key, object, request_options, max_queries_per_IP_per_hour, max_hits_per_query, indexes)
|
755
781
|
end
|
756
782
|
|
783
|
+
#
|
757
784
|
# Delete an existing user key
|
785
|
+
#
|
758
786
|
def Algolia.delete_api_key(key, request_options = {})
|
759
787
|
Algolia.client.delete_api_key(key, request_options)
|
760
788
|
end
|
761
789
|
|
790
|
+
#
|
762
791
|
# Deprecated
|
792
|
+
#
|
763
793
|
def Algolia.delete_user_key(key, request_options = {})
|
764
794
|
Algolia.client.delete_api_key(key, request_options)
|
765
795
|
end
|
766
796
|
|
797
|
+
#
|
767
798
|
# Send a batch request targeting multiple indices
|
799
|
+
#
|
768
800
|
def Algolia.batch(requests, request_options = {})
|
769
801
|
Algolia.client.batch(requests, request_options)
|
770
802
|
end
|
771
803
|
|
804
|
+
#
|
772
805
|
# Send a batch request targeting multiple indices and wait the end of the indexing
|
806
|
+
#
|
773
807
|
def Algolia.batch!(requests, request_options = {})
|
774
808
|
Algolia.client.batch!(requests, request_options)
|
775
809
|
end
|
776
810
|
|
811
|
+
#
|
777
812
|
# Used mostly for testing. Lets you delete the api key global vars.
|
813
|
+
#
|
778
814
|
def Algolia.destroy
|
779
815
|
@@client.destroy unless @@client.nil?
|
780
816
|
@@client = nil
|
@@ -783,7 +819,7 @@ module Algolia
|
|
783
819
|
|
784
820
|
def Algolia.client
|
785
821
|
if !@@client
|
786
|
-
raise AlgoliaError,
|
822
|
+
raise AlgoliaError, 'API not initialized'
|
787
823
|
end
|
788
824
|
@@client
|
789
825
|
end
|