algoliasearch 1.18.5 → 1.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 03233bbddd9db9af56283870fb84965758c916f4
4
- data.tar.gz: d9e3db3fe636e377dae693add2f19f6a80fe4524
3
+ metadata.gz: bf4c0cb75c3e02abc715ebc02df03ef3e3691675
4
+ data.tar.gz: 75607329cc6431559807e52c63336eefc9b6e92e
5
5
  SHA512:
6
- metadata.gz: 45283b077a95d7fc21890e98e194e6234e2cbcbd0da0f79f7b5f4d54c63d1a6429b408cba8170719f4380d2b2be3ecc9e7a6ff0ede6be590a04fe82d7db200af
7
- data.tar.gz: 0b9e1912eb4f1a44a8c9212b9c5e4a196564202ad1797f2d9ed17117603c72bbf372ce6b61c7b3132bf50ae34732aa6e0e6d2812e326c1946f0f9388319f367e
6
+ metadata.gz: bb3578f5e2fdafb61175bd770cf20d169054ca08ae82d1062c9ea36841d9e62f37c7e6e7ca02af1a8e97b023c58f963d006dae2e5e25d9221416290825ac6f44
7
+ data.tar.gz: 4b93d01d798b8447e112cfe37ab1ed22daf47e48df783daf76cc781bf8459408fb0e1ee585651961f29aa1e90b4f90a46ea4ae5acebf8a23f5959f03fd6d2170
data/ChangeLog CHANGED
@@ -1,5 +1,10 @@
1
1
  CHANGELOG
2
2
 
3
+ 2017-12-15 1.19.0
4
+ * Add request options to any method using API calls (#213)
5
+ * Add export_synonyms index method (#260)
6
+ * Add export_rules index method (#261)
7
+
3
8
  2017-12-07 1.18.5
4
9
  * Fix missing requirement
5
10
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- algoliasearch (1.18.5)
4
+ algoliasearch (1.19.0)
5
5
  hashdiff (= 0.3.5)
6
6
  httpclient (~> 2.8.3)
7
7
  json (>= 1.5.1)
data/Rakefile CHANGED
@@ -32,18 +32,24 @@ end
32
32
  require 'rspec/core/rake_task'
33
33
  RSpec::Core::RakeTask.new(:spec)
34
34
 
35
- # Monkey-patching tag naming from v4.2.0 to 4.2.0
36
- namespace :release do
37
- task :github, :version do |_t, args|
38
- version = Gem::Version.new(args.version)
39
- gh_api_post :path => "/repos/bundler/bundler/releases",
40
- :body => {
41
- :tag_name => version,
42
- :name => version,
43
- :body => release_notes(version),
44
- :prerelease => version.prerelease?,
45
- }
35
+ task :default => :spec
36
+
37
+ task :semver, [:version] do |t, args|
38
+ puts "NEW VERSION", args[:version]
39
+
40
+ File.open(File.expand_path('../lib/algolia/version.rb', __FILE__), 'w') do |file|
41
+ file.write <<~SEMVER
42
+ module Algolia
43
+ VERSION = "#{args[:version]}"
44
+ end
45
+ SEMVER
46
46
  end
47
47
  end
48
48
 
49
- task :default => :spec
49
+ module Bundler
50
+ class GemHelper
51
+ def version_tag
52
+ "#{version}"
53
+ end
54
+ end
55
+ end
@@ -7,6 +7,7 @@ require 'openssl'
7
7
  require 'base64'
8
8
 
9
9
  module Algolia
10
+ WAIT_TASK_DEFAULT_TIME_BEFORE_RETRY = 100
10
11
 
11
12
  # A class which encapsulates the HTTPS communication with the Algolia
12
13
  # API server. Uses the HTTPClient library for low-level HTTP communication.
@@ -99,12 +100,26 @@ module Algolia
99
100
 
100
101
  #
101
102
  # This method allows to query multiple indexes with one API call
102
- #
103
- # @param queries the array of hash representing the query and associated index name
104
- # @param index_name_key the name of the key used to fetch the index_name (:index_name by default)
105
- # @param strategy define the strategy applied on the sequential searches (none by default)
106
103
  #
107
- def multiple_queries(queries, index_name_key = :index_name, strategy = "none")
104
+ # @param queries the array of hash representing the query and associated index name
105
+ # @param options - accepts those keys:
106
+ # - index_name_key the name of the key used to fetch the index_name (:index_name by default)
107
+ # - strategy define the strategy applied on the sequential searches (none by default)
108
+ # - request_options contains extra parameters to send with your query
109
+ #
110
+ def multiple_queries(queries, options = nil, strategy = nil)
111
+ if options.is_a?(Hash)
112
+ index_name_key = options.delete(:index_name_key) || options.delete('index_name_key')
113
+ strategy = options.delete(:strategy) || options.delete('strategy')
114
+ request_options = options.delete(:request_options) || options.delete('request_options')
115
+ else
116
+ # Deprecated def multiple_queries(queries, index_name_key, strategy)
117
+ index_name_key = options
118
+ end
119
+ index_name_key ||= :index_name
120
+ strategy ||= 'none'
121
+ request_options ||= {}
122
+
108
123
  requests = {
109
124
  :requests => queries.map do |query|
110
125
  query = query.dup
@@ -114,7 +129,7 @@ module Algolia
114
129
  { :indexName => indexName, :params => Protocol.to_query(encoded_params) }
115
130
  end
116
131
  }
117
- post(Protocol.multiple_queries_uri(strategy), requests.to_json, :search)
132
+ post(Protocol.multiple_queries_uri(strategy), requests.to_json, :search, request_options)
118
133
  end
119
134
 
120
135
  #
@@ -123,28 +138,32 @@ module Algolia
123
138
  # {"items": [{ "name": "contacts", "createdAt": "2013-01-18T15:33:13.556Z"},
124
139
  # {"name": "notes", "createdAt": "2013-01-18T15:33:13.556Z"}]}
125
140
  #
126
- def list_indexes
127
- get(Protocol.indexes_uri, :read)
141
+ # @param request_options contains extra parameters to send with your query
142
+ #
143
+ def list_indexes(request_options = {})
144
+ get(Protocol.indexes_uri, :read, request_options)
128
145
  end
129
146
 
130
147
  #
131
148
  # Move an existing index.
132
149
  # @param src_index the name of index to copy.
133
150
  # @param dst_index the new index name that will contains a copy of srcIndexName (destination will be overriten if it already exist).
151
+ # @param request_options contains extra parameters to send with your query
134
152
  #
135
- def move_index(src_index, dst_index)
153
+ def move_index(src_index, dst_index, request_options = {})
136
154
  request = {"operation" => "move", "destination" => dst_index};
137
- post(Protocol.index_operation_uri(src_index), request.to_json)
155
+ post(Protocol.index_operation_uri(src_index), request.to_json, :write, request_options)
138
156
  end
139
157
 
140
158
  #
141
159
  # Move an existing index and wait until the move has been processed
142
160
  # @param src_index the name of index to copy.
143
161
  # @param dst_index the new index name that will contains a copy of srcIndexName (destination will be overriten if it already exist).
162
+ # @param request_options contains extra parameters to send with your query
144
163
  #
145
- def move_index!(src_index, dst_index)
146
- res = move_index(src_index, dst_index)
147
- init_index(dst_index).wait_task(res['taskID'])
164
+ def move_index!(src_index, dst_index, request_options = {})
165
+ res = move_index(src_index, dst_index, request_options)
166
+ init_index(dst_index).wait_task(res['taskID'], WAIT_TASK_DEFAULT_TIME_BEFORE_RETRY, request_options)
148
167
  res
149
168
  end
150
169
 
@@ -153,11 +172,12 @@ module Algolia
153
172
  # @param src_index the name of index to copy.
154
173
  # @param dst_index the new index name that will contains a copy of srcIndexName (destination will be overriten if it already exist).
155
174
  # @param scope the optional list of scopes to copy (all if not specified).
175
+ # @param request_options contains extra parameters to send with your query
156
176
  #
157
- def copy_index(src_index, dst_index, scope = nil)
177
+ def copy_index(src_index, dst_index, scope = nil, request_options = {})
158
178
  request = {"operation" => "copy", "destination" => dst_index};
159
179
  request["scope"] = scope unless scope.nil?
160
- post(Protocol.index_operation_uri(src_index), request.to_json)
180
+ post(Protocol.index_operation_uri(src_index), request.to_json, :write, request_options)
161
181
  end
162
182
 
163
183
  #
@@ -165,10 +185,11 @@ module Algolia
165
185
  # @param src_index the name of index to copy.
166
186
  # @param dst_index the new index name that will contains a copy of srcIndexName (destination will be overriten if it already exist).
167
187
  # @param scope the optional list of scopes to copy (all if not specified).
188
+ # @param request_options contains extra parameters to send with your query
168
189
  #
169
- def copy_index!(src_index, dst_index, scope = nil)
170
- res = copy_index(src_index, dst_index, scope)
171
- init_index(dst_index).wait_task(res['taskID'])
190
+ def copy_index!(src_index, dst_index, scope = nil, request_options = {})
191
+ res = copy_index(src_index, dst_index, scope, request_options)
192
+ init_index(dst_index).wait_task(res['taskID'], WAIT_TASK_DEFAULT_TIME_BEFORE_RETRY, request_options)
172
193
  res
173
194
  end
174
195
 
@@ -187,59 +208,70 @@ module Algolia
187
208
  #
188
209
  # Return last logs entries.
189
210
  #
190
- # @param offset Specify the first entry to retrieve (0-based, 0 is the most recent log entry).
191
- # @param length Specify the maximum number of entries to retrieve starting at offset. Maximum allowed value: 1000.
192
- # @param type Optional type of log entries to retrieve ("all", "query", "build" or "error").
193
- #
194
- def get_logs(offset = 0, length = 10, type = "all")
195
- if (type.is_a?(true.class))
196
- if (type)
197
- type = "error"
198
- else
199
- type = "all"
200
- end
211
+ # @param options - accepts those keys:
212
+ # - offset Specify the first entry to retrieve (0-based, 0 is the most recent log entry) - Default = 0
213
+ # - length Specify the maximum number of entries to retrieve starting at offset. Maximum allowed value: 1000 - Default = 10
214
+ # - type Type of log entries to retrieve ("all", "query", "build" or "error") - Default = 'all'
215
+ # - request_options contains extra parameters to send with your query
216
+ #
217
+ def get_logs(options = nil, length = nil, type = nil)
218
+ if options.is_a?(Hash)
219
+ offset = options.delete('offset') || options.delete(:offset)
220
+ length = options.delete('length') || options.delete(:length)
221
+ type = options.delete('type') || options.delete(:type)
222
+ request_options = options.delete('request_options') || options.delete(:request_options)
223
+ else
224
+ # Deprecated def get_logs(offset, length, type)
225
+ offset = options
201
226
  end
202
- get(Protocol.logs(offset, length, type))
227
+ length ||= 10
228
+ type = 'all' if type.nil?
229
+ type = type ? 'error' : 'all' if type.is_a?(true.class)
230
+ request_options ||= {}
231
+
232
+ get(Protocol.logs(offset, length, type), :write, request_options)
203
233
  end
204
234
 
205
235
  # List all existing user keys with their associated ACLs
206
- def list_api_keys
207
- get(Protocol.keys_uri, :read)
236
+ #
237
+ # @param request_options contains extra parameters to send with your query
238
+ def list_api_keys(request_options = {})
239
+ get(Protocol.keys_uri, :read, request_options)
208
240
  end
209
241
 
210
242
  # Get ACL of a user key
211
- def get_api_key(key)
212
- get(Protocol.key_uri(key), :read)
243
+ #
244
+ # @param request_options contains extra parameters to send with your query
245
+ def get_api_key(key, request_options = {})
246
+ get(Protocol.key_uri(key), :read, request_options)
213
247
  end
214
248
 
215
249
  #
216
250
  # Create a new user key
217
251
  #
218
- # @param obj can be two different parameters:
219
- # The list of parameters for this key. Defined by a NSDictionary that
220
- # can contains the following values:
252
+ # Deprecated call was add_api_key(acl, validity, maxQueriesPerIPPerHour, maxHitsPerQuery, indexes)
253
+ #
254
+ # ACL can contain an array with those strings:
255
+ # - search: allow to search (https and http)
256
+ # - addObject: allows to add/update an object in the index (https only)
257
+ # - deleteObject : allows to delete an existing object (https only)
258
+ # - deleteIndex : allows to delete index content (https only)
259
+ # - settings : allows to get index settings (https only)
260
+ # - editSettings : allows to change index settings (https only)
261
+ #
262
+ # @param obj The list of parameters for this key.
263
+ # Defined by a Hash that can contain the following values:
221
264
  # - acl: array of string
222
- # - indices: array of string
265
+ # - indexes: array of string
223
266
  # - validity: int
224
267
  # - referers: array of string
225
268
  # - description: string
226
269
  # - maxHitsPerQuery: integer
227
270
  # - queryParameters: string
228
271
  # - maxQueriesPerIPPerHour: integer
229
- # Or the list of ACL for this key. Defined by an array of NSString that
230
- # can contains the following values:
231
- # - search: allow to search (https and http)
232
- # - addObject: allows to add/update an object in the index (https only)
233
- # - deleteObject : allows to delete an existing object (https only)
234
- # - deleteIndex : allows to delete index content (https only)
235
- # - settings : allows to get index settings (https only)
236
- # - editSettings : allows to change index settings (https only)
237
- # @param validity the number of seconds after which the key will be automatically removed (0 means no time limit for this key)
238
- # @param maxQueriesPerIPPerHour the maximum number of API calls allowed from an IP address per hour (0 means unlimited)
239
- # @param maxHitsPerQuery the maximum number of hits this API key can retrieve in one call (0 means unlimited)
240
- # @param indexes the optional list of targeted indexes
241
- #
242
- def add_api_key(obj, validity = 0, maxQueriesPerIPPerHour = 0, maxHitsPerQuery = 0, indexes = nil)
272
+ # @param request_options contains extra parameters to send with your query - Default = {}
273
+ #
274
+ def add_api_key(obj, request_options = {}, maxQueriesPerIPPerHour = 0, maxHitsPerQuery = 0, indexes = nil)
243
275
  if obj.instance_of? Array
244
276
  params = {
245
277
  :acl => obj
@@ -247,47 +279,53 @@ module Algolia
247
279
  else
248
280
  params = obj
249
281
  end
282
+
283
+ validity = 0
284
+ unless request_options.is_a?(Hash)
285
+ validity = request_options
286
+ request_options = {}
287
+ end
288
+
250
289
  if validity != 0
251
- params["validity"] = validity.to_i
290
+ params['validity'] = validity.to_i
252
291
  end
253
292
  if maxQueriesPerIPPerHour != 0
254
- params["maxQueriesPerIPPerHour"] = maxQueriesPerIPPerHour.to_i
293
+ params['maxQueriesPerIPPerHour'] = maxQueriesPerIPPerHour.to_i
255
294
  end
256
295
  if maxHitsPerQuery != 0
257
- params["maxHitsPerQuery"] = maxHitsPerQuery.to_i
296
+ params['maxHitsPerQuery'] = maxHitsPerQuery.to_i
258
297
  end
259
298
  params[:indexes] = indexes if indexes
260
- post(Protocol.keys_uri, params.to_json)
299
+ post(Protocol.keys_uri, params.to_json, :write, request_options)
261
300
  end
262
301
 
263
302
  #
264
303
  # Update a user key
265
304
  #
266
- # @param obj can be two different parameters:
267
- # The list of parameters for this key. Defined by a NSDictionary that
268
- # can contains the following values:
305
+ # Deprecated call was update_api_key(key, acl, validity, maxQueriesPerIPPerHour, maxHitsPerQuery, indexes)
306
+ #
307
+ # ACL can contain an array with those strings:
308
+ # - search: allow to search (https and http)
309
+ # - addObject: allows to add/update an object in the index (https only)
310
+ # - deleteObject : allows to delete an existing object (https only)
311
+ # - deleteIndex : allows to delete index content (https only)
312
+ # - settings : allows to get index settings (https only)
313
+ # - editSettings : allows to change index settings (https only)
314
+ #
315
+ # @param key API Key to update
316
+ # @param obj The list of parameters for this key.
317
+ # Defined by a Hash that can contain the following values:
269
318
  # - acl: array of string
270
- # - indices: array of string
319
+ # - indexes: array of string
271
320
  # - validity: int
272
321
  # - referers: array of string
273
322
  # - description: string
274
323
  # - maxHitsPerQuery: integer
275
324
  # - queryParameters: string
276
325
  # - maxQueriesPerIPPerHour: integer
277
- # Or the list of ACL for this key. Defined by an array of NSString that
278
- # can contains the following values:
279
- # - search: allow to search (https and http)
280
- # - addObject: allows to add/update an object in the index (https only)
281
- # - deleteObject : allows to delete an existing object (https only)
282
- # - deleteIndex : allows to delete index content (https only)
283
- # - settings : allows to get index settings (https only)
284
- # - editSettings : allows to change index settings (https only)
285
- # @param validity the number of seconds after which the key will be automatically removed (0 means no time limit for this key)
286
- # @param maxQueriesPerIPPerHour the maximum number of API calls allowed from an IP address per hour (0 means unlimited)
287
- # @param maxHitsPerQuery the maximum number of hits this API key can retrieve in one call (0 means unlimited)
288
- # @param indexes the optional list of targeted indexes
289
- #
290
- def update_api_key(key, obj, validity = 0, maxQueriesPerIPPerHour = 0, maxHitsPerQuery = 0, indexes = nil)
326
+ # @param request_options contains extra parameters to send with your query - Default = {}
327
+ #
328
+ def update_api_key(key, obj, request_options = {}, maxQueriesPerIPPerHour = 0, maxHitsPerQuery = 0, indexes = nil)
291
329
  if obj.instance_of? Array
292
330
  params = {
293
331
  :acl => obj
@@ -295,35 +333,44 @@ module Algolia
295
333
  else
296
334
  params = obj
297
335
  end
336
+
337
+ validity = 0
338
+ unless request_options.is_a?(Hash)
339
+ validity = request_options
340
+ request_options = {}
341
+ end
342
+
298
343
  if validity != 0
299
- params["validity"] = validity.to_i
344
+ params['validity'] = validity.to_i
300
345
  end
301
346
  if maxQueriesPerIPPerHour != 0
302
- params["maxQueriesPerIPPerHour"] = maxQueriesPerIPPerHour.to_i
347
+ params['maxQueriesPerIPPerHour'] = maxQueriesPerIPPerHour.to_i
303
348
  end
304
349
  if maxHitsPerQuery != 0
305
- params["maxHitsPerQuery"] = maxHitsPerQuery.to_i
350
+ params['maxHitsPerQuery'] = maxHitsPerQuery.to_i
306
351
  end
307
352
  params[:indexes] = indexes if indexes
308
- put(Protocol.key_uri(key), params.to_json)
353
+ put(Protocol.key_uri(key), params.to_json, :write, request_options)
309
354
  end
310
355
 
311
-
312
356
  # Delete an existing user key
313
- def delete_api_key(key)
314
- delete(Protocol.key_uri(key))
357
+ #
358
+ def delete_api_key(key, request_options = {})
359
+ delete(Protocol.key_uri(key), :write, request_options)
315
360
  end
316
361
 
317
362
  # Send a batch request targeting multiple indices
318
- def batch(requests)
319
- post(Protocol.batch_uri, {"requests" => requests}.to_json, :batch)
363
+ #
364
+ def batch(requests, request_options = {})
365
+ post(Protocol.batch_uri, {"requests" => requests}.to_json, :batch, request_options)
320
366
  end
321
367
 
322
368
  # Send a batch request targeting multiple indices and wait the end of the indexing
323
- def batch!(requests)
324
- res = batch(requests)
369
+ #
370
+ def batch!(requests, request_options = {})
371
+ res = batch(requests, request_options)
325
372
  res['taskID'].each do |index, taskID|
326
- init_index(index).wait_task(taskID)
373
+ init_index(index).wait_task(taskID, WAIT_TASK_DEFAULT_TIME_BEFORE_RETRY, request_options)
327
374
  end
328
375
  end
329
376
 
@@ -331,7 +378,7 @@ module Algolia
331
378
  # with common basic response handling. Will raise a
332
379
  # AlgoliaProtocolError if the response has an error status code,
333
380
  # and will return the parsed JSON body on success, if there is one.
334
- def request(uri, method, data = nil, type = :write)
381
+ def request(uri, method, data = nil, type = :write, request_options = {})
335
382
  exceptions = []
336
383
 
337
384
  connect_timeout = @connect_timeout
@@ -358,7 +405,7 @@ module Algolia
358
405
  host[:session].send_timeout = send_timeout
359
406
  host[:session].receive_timeout = receive_timeout
360
407
  begin
361
- return perform_request(host[:session], host[:base_url] + uri, method, data)
408
+ return perform_request(host[:session], host[:base_url] + uri, method, data, request_options)
362
409
  rescue AlgoliaProtocolError => e
363
410
  raise if e.code / 100 == 4
364
411
  exceptions << e
@@ -370,20 +417,20 @@ module Algolia
370
417
  raise AlgoliaProtocolError.new(0, "Cannot reach any host: #{exceptions.map { |e| e.to_s }.join(', ')}")
371
418
  end
372
419
 
373
- def get(uri, type = :write)
374
- request(uri, :GET, nil, type)
420
+ def get(uri, type = :write, request_options = {})
421
+ request(uri, :GET, nil, type, request_options)
375
422
  end
376
423
 
377
- def post(uri, body = {}, type = :write)
378
- request(uri, :POST, body, type)
424
+ def post(uri, body = {}, type = :write, request_options = {})
425
+ request(uri, :POST, body, type, request_options)
379
426
  end
380
427
 
381
- def put(uri, body = {}, type = :write)
382
- request(uri, :PUT, body, type)
428
+ def put(uri, body = {}, type = :write, request_options = {})
429
+ request(uri, :PUT, body, type, request_options)
383
430
  end
384
431
 
385
- def delete(uri, type = :write)
386
- request(uri, :DELETE, nil, type)
432
+ def delete(uri, type = :write, request_options = {})
433
+ request(uri, :DELETE, nil, type, request_options)
387
434
  end
388
435
 
389
436
  private
@@ -418,16 +465,20 @@ module Algolia
418
465
  end
419
466
  end
420
467
 
421
- def perform_request(session, url, method, data)
468
+ def perform_request(session, url, method, data, request_options)
469
+ hs = {}
470
+ extra_headers = request_options[:headers] || request_options['headers'] || {}
471
+ @headers.each { |key, val| hs[key.to_s] = val }
472
+ extra_headers.each { |key, val| hs[key.to_s] = val }
422
473
  response = case method
423
474
  when :GET
424
- session.get(url, { :header => @headers })
475
+ session.get(url, { :header => hs })
425
476
  when :POST
426
- session.post(url, { :body => data, :header => @headers })
477
+ session.post(url, { :body => data, :header => hs })
427
478
  when :PUT
428
- session.put(url, { :body => data, :header => @headers })
479
+ session.put(url, { :body => data, :header => hs })
429
480
  when :DELETE
430
- session.delete(url, { :header => @headers })
481
+ session.delete(url, { :header => hs })
431
482
  end
432
483
  if response.code / 100 != 2
433
484
  raise AlgoliaProtocolError.new(response.code, "Cannot #{method} to #{url}: #{response.content} (#{response.code})")
@@ -521,13 +572,9 @@ module Algolia
521
572
 
522
573
  #
523
574
  # This method allows to query multiple indexes with one API call
524
- #
525
- # @param queries the array of hash representing the query and associated index name
526
- # @param index_name_key the name of the key used to fetch the index_name (:index_name by default)
527
- # @param strategy define the strategy applied on the sequential searches (none by default)
528
575
  #
529
- def Algolia.multiple_queries(queries, index_name_key = :index_name, strategy = "none")
530
- Algolia.client.multiple_queries(queries, index_name_key, strategy)
576
+ def Algolia.multiple_queries(queries, options = nil, strategy = nil)
577
+ Algolia.client.multiple_queries(queries, options, strategy)
531
578
  end
532
579
 
533
580
  #
@@ -536,26 +583,30 @@ module Algolia
536
583
  # {"items": [{ "name": "contacts", "createdAt": "2013-01-18T15:33:13.556Z"},
537
584
  # {"name": "notes", "createdAt": "2013-01-18T15:33:13.556Z"}]}
538
585
  #
539
- def Algolia.list_indexes
540
- Algolia.client.list_indexes
586
+ # @param request_options contains extra parameters to send with your query
587
+ #
588
+ def Algolia.list_indexes(request_options = {})
589
+ Algolia.client.list_indexes(request_options)
541
590
  end
542
591
 
543
592
  #
544
593
  # Move an existing index.
545
594
  # @param src_index the name of index to copy.
546
595
  # @param dst_index the new index name that will contains a copy of srcIndexName (destination will be overriten if it already exist).
596
+ # @param request_options contains extra parameters to send with your query
547
597
  #
548
- def Algolia.move_index(src_index, dst_index)
549
- Algolia.client.move_index(src_index, dst_index)
598
+ def Algolia.move_index(src_index, dst_index, request_options = {})
599
+ Algolia.client.move_index(src_index, dst_index, request_options)
550
600
  end
551
601
 
552
602
  #
553
603
  # Move an existing index and wait until the move has been processed
554
604
  # @param src_index the name of index to copy.
555
605
  # @param dst_index the new index name that will contains a copy of srcIndexName (destination will be overriten if it already exist).
606
+ # @param request_options contains extra parameters to send with your query
556
607
  #
557
- def Algolia.move_index!(src_index, dst_index)
558
- Algolia.client.move_index!(src_index, dst_index)
608
+ def Algolia.move_index!(src_index, dst_index, request_options = {})
609
+ Algolia.client.move_index!(src_index, dst_index, request_options)
559
610
  end
560
611
 
561
612
  #
@@ -563,9 +614,10 @@ module Algolia
563
614
  # @param src_index the name of index to copy.
564
615
  # @param dst_index the new index name that will contains a copy of srcIndexName (destination will be overriten if it already exist).
565
616
  # @param scope the optional list of scopes to copy (all if not specified).
617
+ # @param request_options contains extra parameters to send with your query
566
618
  #
567
- def Algolia.copy_index(src_index, dst_index, scope = nil)
568
- Algolia.client.copy_index(src_index, dst_index, scope)
619
+ def Algolia.copy_index(src_index, dst_index, scope = nil, request_options = {})
620
+ Algolia.client.copy_index(src_index, dst_index, scope, request_options)
569
621
  end
570
622
 
571
623
  #
@@ -573,21 +625,22 @@ module Algolia
573
625
  # @param src_index the name of index to copy.
574
626
  # @param dst_index the new index name that will contains a copy of srcIndexName (destination will be overriten if it already exist).
575
627
  # @param scope the optional list of scopes to copy (all if not specified).
628
+ # @param request_options contains extra parameters to send with your query
576
629
  #
577
- def Algolia.copy_index!(src_index, dst_index, scope = nil)
578
- Algolia.client.copy_index!(src_index, dst_index, scope)
630
+ def Algolia.copy_index!(src_index, dst_index, scope = nil, request_options = {})
631
+ Algolia.client.copy_index!(src_index, dst_index, scope, request_options)
579
632
  end
580
633
 
581
634
  # Delete an index
582
635
  #
583
- def Algolia.delete_index(name)
584
- Algolia.client.delete_index(name)
636
+ def Algolia.delete_index(name, request_options = {})
637
+ Algolia.client.delete_index(name, request_options)
585
638
  end
586
639
 
587
640
  # Delete an index and wait until the deletion has been processed.
588
641
  #
589
- def Algolia.delete_index!(name)
590
- Algolia.client.delete_index!(name)
642
+ def Algolia.delete_index!(name, request_options = {})
643
+ Algolia.client.delete_index!(name, request_options)
591
644
  end
592
645
 
593
646
  #
@@ -595,121 +648,125 @@ module Algolia
595
648
  #
596
649
  # @param offset Specify the first entry to retrieve (0-based, 0 is the most recent log entry).
597
650
  # @param length Specify the maximum number of entries to retrieve starting at offset. Maximum allowed value: 1000.
651
+ # @param type Specify the type of entries you want to retrieve - default: "all"
652
+ # @param request_options contains extra parameters to send with your query
598
653
  #
599
- def Algolia.get_logs(offset = 0, length = 10, type = "all")
600
- Algolia.client.get_logs(offset, length, type)
654
+ def Algolia.get_logs(options = nil, length = nil, type = nil)
655
+ Algolia.client.get_logs(options, length, type)
601
656
  end
602
657
 
603
658
  # List all existing user keys with their associated ACLs
604
- def Algolia.list_api_keys
605
- Algolia.client.list_api_keys
659
+ #
660
+ # @param request_options contains extra parameters to send with your query
661
+ def Algolia.list_api_keys(request_options = {})
662
+ Algolia.client.list_api_keys(request_options)
606
663
  end
607
664
 
608
665
  # Deprecated
609
- def Algolia.list_user_keys
610
- Algolia.client.list_api_keys
666
+ def Algolia.list_user_keys(request_options = {})
667
+ Algolia.client.list_api_keys(request_options)
611
668
  end
612
669
 
613
670
  # Get ACL of a user key
614
- def Algolia.get_api_key(key)
615
- Algolia.client.get_api_key(key)
671
+ #
672
+ # @param request_options contains extra parameters to send with your query
673
+ def Algolia.get_api_key(key, request_options = {})
674
+ Algolia.client.get_api_key(key, request_options)
616
675
  end
617
676
 
618
677
  # Deprecated
619
- def Algolia.get_user_key(key)
620
- Algolia.client.get_user_key(key)
678
+ def Algolia.get_user_key(key, request_options = {})
679
+ Algolia.client.get_user_key(key, request_options)
621
680
  end
622
681
 
623
682
  #
624
683
  # Create a new user key
625
684
  #
685
+ # Deprecated call was add_api_key(acl, validity, maxQueriesPerIPPerHour, maxHitsPerQuery, indexes)
686
+ #
687
+ # ACL can contain an array with those strings:
688
+ # - search: allow to search (https and http)
689
+ # - addObject: allows to add/update an object in the index (https only)
690
+ # - deleteObject : allows to delete an existing object (https only)
691
+ # - deleteIndex : allows to delete index content (https only)
692
+ # - settings : allows to get index settings (https only)
693
+ # - editSettings : allows to change index settings (https only)
694
+ #
626
695
  # @param obj can be two different parameters:
627
696
  # The list of parameters for this key. Defined by a NSDictionary that
628
697
  # can contains the following values:
629
698
  # - acl: array of string
630
- # - indices: array of string
699
+ # - indexes: array of string
631
700
  # - validity: int
632
701
  # - referers: array of string
633
702
  # - description: string
634
703
  # - maxHitsPerQuery: integer
635
704
  # - queryParameters: string
636
705
  # - maxQueriesPerIPPerHour: integer
637
- # Or the list of ACL for this key. Defined by an array of NSString that
638
- # can contains the following values:
639
- # - search: allow to search (https and http)
640
- # - addObject: allows to add/update an object in the index (https only)
641
- # - deleteObject : allows to delete an existing object (https only)
642
- # - deleteIndex : allows to delete index content (https only)
643
- # - settings : allows to get index settings (https only)
644
- # - editSettings : allows to change index settings (https only)
645
- # @param validity the number of seconds after which the key will be automatically removed (0 means no time limit for this key)
646
- # @param maxQueriesPerIPPerHour the maximum number of API calls allowed from an IP address per hour (0 means unlimited)
647
- # @param maxHitsPerQuery the maximum number of hits this API key can retrieve in one call (0 means unlimited)
648
- # @param indexes the optional list of targeted indexes
649
- #
650
- def Algolia.add_api_key(obj, validity = 0, maxQueriesPerIPPerHour = 0, maxHitsPerQuery = 0, indexes = nil)
651
- Algolia.client.add_api_key(obj, validity, maxQueriesPerIPPerHour, maxHitsPerQuery, indexes)
706
+ # @param request_options contains extra parameters to send with your query - Default = {}
707
+ #
708
+ def Algolia.add_api_key(obj, request_options = {}, maxQueriesPerIPPerHour = 0, maxHitsPerQuery = 0, indexes = nil)
709
+ Algolia.client.add_api_key(obj, request_options, maxQueriesPerIPPerHour, maxHitsPerQuery, indexes)
652
710
  end
653
711
 
654
712
  # Deprecated
655
- def Algolia.add_user_key(obj, validity = 0, maxQueriesPerIPPerHour = 0, maxHitsPerQuery = 0, indexes = nil)
656
- Algolia.client.add_api_key(obj, validity, maxQueriesPerIPPerHour, maxHitsPerQuery, indexes)
713
+ def Algolia.add_user_key(obj, request_options = {}, maxQueriesPerIPPerHour = 0, maxHitsPerQuery = 0, indexes = nil)
714
+ Algolia.client.add_api_key(obj, request_options, maxQueriesPerIPPerHour, maxHitsPerQuery, indexes)
657
715
  end
658
716
 
659
717
  #
660
718
  # Update a user key
661
719
  #
662
- # @param obj can be two different parameters:
663
- # The list of parameters for this key. Defined by a NSDictionary that
664
- # can contains the following values:
720
+ # Deprecated call was update_api_key(key, acl, validity, maxQueriesPerIPPerHour, maxHitsPerQuery, indexes)
721
+ #
722
+ # ACL can contain an array with those strings:
723
+ # - search: allow to search (https and http)
724
+ # - addObject: allows to add/update an object in the index (https only)
725
+ # - deleteObject : allows to delete an existing object (https only)
726
+ # - deleteIndex : allows to delete index content (https only)
727
+ # - settings : allows to get index settings (https only)
728
+ # - editSettings : allows to change index settings (https only)
729
+ #
730
+ # @param key API Key to update
731
+ # @param obj The list of parameters for this key.
732
+ # Defined by a Hash that can contain the following values:
665
733
  # - acl: array of string
666
- # - indices: array of string
734
+ # - indexes: array of string
667
735
  # - validity: int
668
736
  # - referers: array of string
669
737
  # - description: string
670
738
  # - maxHitsPerQuery: integer
671
739
  # - queryParameters: string
672
740
  # - maxQueriesPerIPPerHour: integer
673
- # Or the list of ACL for this key. Defined by an array of NSString that
674
- # can contains the following values:
675
- # - search: allow to search (https and http)
676
- # - addObject: allows to add/update an object in the index (https only)
677
- # - deleteObject : allows to delete an existing object (https only)
678
- # - deleteIndex : allows to delete index content (https only)
679
- # - settings : allows to get index settings (https only)
680
- # - editSettings : allows to change index settings (https only)
681
- # @param validity the number of seconds after which the key will be automatically removed (0 means no time limit for this key)
682
- # @param maxQueriesPerIPPerHour the maximum number of API calls allowed from an IP address per hour (0 means unlimited)
683
- # @param maxHitsPerQuery the maximum number of hits this API key can retrieve in one call (0 means unlimited)
684
- # @param indexes the optional list of targeted indexes
685
- #
686
- def Algolia.update_api_key(key, obj, validity = 0, maxQueriesPerIPPerHour = 0, maxHitsPerQuery = 0, indexes = nil)
687
- Algolia.client.update_api_key(key, obj, validity, maxQueriesPerIPPerHour, maxHitsPerQuery, indexes)
741
+ # @param request_options contains extra parameters to send with your query - Default = {}
742
+ #
743
+ def Algolia.update_api_key(key, obj, request_options = {}, maxQueriesPerIPPerHour = 0, maxHitsPerQuery = 0, indexes = nil)
744
+ Algolia.client.update_api_key(key, obj, request_options, maxQueriesPerIPPerHour, maxHitsPerQuery, indexes)
688
745
  end
689
746
 
690
747
  # Deprecated
691
- def Algolia.update_user_key(key, obj, validity = 0, maxQueriesPerIPPerHour = 0, maxHitsPerQuery = 0, indexes = nil)
692
- Algolia.client.update_api_key(key, obj, validity, maxQueriesPerIPPerHour, maxHitsPerQuery, indexes)
748
+ def Algolia.update_user_key(key, obj, request_options = {}, maxQueriesPerIPPerHour = 0, maxHitsPerQuery = 0, indexes = nil)
749
+ Algolia.client.update_api_key(key, obj, request_options, maxQueriesPerIPPerHour, maxHitsPerQuery, indexes)
693
750
  end
694
751
 
695
752
  # Delete an existing user key
696
- def Algolia.delete_api_key(key)
697
- Algolia.client.delete_api_key(key)
753
+ def Algolia.delete_api_key(key, request_options = {})
754
+ Algolia.client.delete_api_key(key, request_options)
698
755
  end
699
756
 
700
757
  # Deprecated
701
- def Algolia.delete_user_key(key)
702
- Algolia.client.delete_api_key(key)
758
+ def Algolia.delete_user_key(key, request_options = {})
759
+ Algolia.client.delete_api_key(key, request_options)
703
760
  end
704
761
 
705
762
  # Send a batch request targeting multiple indices
706
- def Algolia.batch(requests)
707
- Algolia.client.batch(requests)
763
+ def Algolia.batch(requests, request_options = {})
764
+ Algolia.client.batch(requests, request_options)
708
765
  end
709
766
 
710
767
  # Send a batch request targeting multiple indices and wait the end of the indexing
711
- def Algolia.batch!(requests)
712
- Algolia.client.batch!(requests)
768
+ def Algolia.batch!(requests, request_options = {})
769
+ Algolia.client.batch!(requests, request_options)
713
770
  end
714
771
 
715
772
  # Used mostly for testing. Lets you delete the api key global vars.