Class: Algolia::CompositionClient

Inherits:
Object
  • Object
show all
Defined in:
lib/algolia/api/composition_client.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = nil) ⇒ CompositionClient

Returns a new instance of CompositionClient.



9
10
11
12
13
14
15
# File 'lib/algolia/api/composition_client.rb', line 9

def initialize(config = nil)
  raise "`config` is missing." if config.nil?
  raise "`app_id` is missing." if config.app_id.nil? || config.app_id == ""
  raise "`api_key` is missing." if config.api_key.nil? || config.api_key == ""

  @api_client = Algolia::ApiClient.new(config)
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



7
8
9
# File 'lib/algolia/api/composition_client.rb', line 7

def api_client
  @api_client
end

Class Method Details

.create(app_id, api_key, opts = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/algolia/api/composition_client.rb', line 17

def self.create(app_id, api_key, opts = {})
  hosts = []
  hosts << Transport::StatefulHost.new("#{app_id}-dsn.algolia.net", accept: CallType::READ)
  hosts << Transport::StatefulHost.new("#{app_id}.algolia.net", accept: CallType::WRITE)

  hosts += 1
    .upto(3)
    .map do |i|
      Transport::StatefulHost.new("#{app_id}-#{i}.algolianet.com", accept: CallType::READ | CallType::WRITE)
    end
    .shuffle

  config = Algolia::Configuration.new(app_id, api_key, hosts, "Composition", opts)
  create_with_config(config)
end

.create_with_config(config) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/algolia/api/composition_client.rb', line 33

def self.create_with_config(config)
  if config.connect_timeout.nil?
    config.connect_timeout = 2000
  end

  if config.read_timeout.nil?
    config.read_timeout = 5000
  end

  if config.write_timeout.nil?
    config.write_timeout = 30000
  end

  new(config)
end

Instance Method Details

#add_user_agent_segment(segment, version = nil) ⇒ Object



59
60
61
62
63
# File 'lib/algolia/api/composition_client.rb', line 59

def add_user_agent_segment(segment, version = nil)
  @api_client.config.add_user_agent_segment(segment, version)

  self
end

#custom_delete(path, parameters = nil, request_options = {}) ⇒ Object

Parameters:

  • path (String)

    Path of the endpoint, for example ‘1/newFeature`. (required)

  • parameters (Hash<String, Object>) (defaults to: nil)

    Query parameters to apply to the current query.

  • request_options:

    The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)

Returns:

  • (Object)


103
104
105
106
# File 'lib/algolia/api/composition_client.rb', line 103

def custom_delete(path, parameters = nil, request_options = {})
  response = custom_delete_with_http_info(path, parameters, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Object")
end

#custom_delete_with_http_info(path, parameters = nil, request_options = {}) ⇒ Http::Response

Returns the response.

Parameters:

  • path (String)

    Path of the endpoint, for example ‘1/newFeature`. (required)

  • parameters (Hash<String, Object>) (defaults to: nil)

    Query parameters to apply to the current query.

  • request_options:

    The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)

Returns:



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/algolia/api/composition_client.rb', line 71

def custom_delete_with_http_info(path, parameters = nil, request_options = {})
  # verify the required parameter 'path' is set
  if @api_client.config.client_side_validation && path.nil?
    raise ArgumentError, "Parameter `path` is required when calling `custom_delete`."
  end

  path = "/{path}".sub("{" + "path" + "}", path.to_s)
  query_params = {}
  query_params = query_params.merge(parameters) unless parameters.nil?
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body]

  new_options = request_options.merge(
    :operation => :"CompositionClient.custom_delete",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:DELETE, path, new_options)
end

#custom_get(path, parameters = nil, request_options = {}) ⇒ Object

Parameters:

  • path (String)

    Path of the endpoint, for example ‘1/newFeature`. (required)

  • parameters (Hash<String, Object>) (defaults to: nil)

    Query parameters to apply to the current query.

  • request_options:

    The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)

Returns:

  • (Object)


146
147
148
149
# File 'lib/algolia/api/composition_client.rb', line 146

def custom_get(path, parameters = nil, request_options = {})
  response = custom_get_with_http_info(path, parameters, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Object")
end

#custom_get_with_http_info(path, parameters = nil, request_options = {}) ⇒ Http::Response

Returns the response.

Parameters:

  • path (String)

    Path of the endpoint, for example ‘1/newFeature`. (required)

  • parameters (Hash<String, Object>) (defaults to: nil)

    Query parameters to apply to the current query.

  • request_options:

    The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)

Returns:



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/algolia/api/composition_client.rb', line 114

def custom_get_with_http_info(path, parameters = nil, request_options = {})
  # verify the required parameter 'path' is set
  if @api_client.config.client_side_validation && path.nil?
    raise ArgumentError, "Parameter `path` is required when calling `custom_get`."
  end

  path = "/{path}".sub("{" + "path" + "}", path.to_s)
  query_params = {}
  query_params = query_params.merge(parameters) unless parameters.nil?
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body]

  new_options = request_options.merge(
    :operation => :"CompositionClient.custom_get",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:GET, path, new_options)
end

#custom_post(path, parameters = nil, body = nil, request_options = {}) ⇒ Object

Parameters:

  • path (String)

    Path of the endpoint, for example ‘1/newFeature`. (required)

  • parameters (Hash<String, Object>) (defaults to: nil)

    Query parameters to apply to the current query.

  • body (Object) (defaults to: nil)

    Parameters to send with the custom request.

  • request_options:

    The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)

Returns:

  • (Object)


191
192
193
194
# File 'lib/algolia/api/composition_client.rb', line 191

def custom_post(path, parameters = nil, body = nil, request_options = {})
  response = custom_post_with_http_info(path, parameters, body, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Object")
end

#custom_post_with_http_info(path, parameters = nil, body = nil, request_options = {}) ⇒ Http::Response

Returns the response.

Parameters:

  • path (String)

    Path of the endpoint, for example ‘1/newFeature`. (required)

  • parameters (Hash<String, Object>) (defaults to: nil)

    Query parameters to apply to the current query.

  • body (Object) (defaults to: nil)

    Parameters to send with the custom request.

  • request_options:

    The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)

Returns:



158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'lib/algolia/api/composition_client.rb', line 158

def custom_post_with_http_info(path, parameters = nil, body = nil, request_options = {})
  # verify the required parameter 'path' is set
  if @api_client.config.client_side_validation && path.nil?
    raise ArgumentError, "Parameter `path` is required when calling `custom_post`."
  end

  path = "/{path}".sub("{" + "path" + "}", path.to_s)
  query_params = {}
  query_params = query_params.merge(parameters) unless parameters.nil?
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body] || @api_client.object_to_http_body(body)

  new_options = request_options.merge(
    :operation => :"CompositionClient.custom_post",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:POST, path, new_options)
end

#custom_put(path, parameters = nil, body = nil, request_options = {}) ⇒ Object

Parameters:

  • path (String)

    Path of the endpoint, for example ‘1/newFeature`. (required)

  • parameters (Hash<String, Object>) (defaults to: nil)

    Query parameters to apply to the current query.

  • body (Object) (defaults to: nil)

    Parameters to send with the custom request.

  • request_options:

    The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)

Returns:

  • (Object)


236
237
238
239
# File 'lib/algolia/api/composition_client.rb', line 236

def custom_put(path, parameters = nil, body = nil, request_options = {})
  response = custom_put_with_http_info(path, parameters, body, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Object")
end

#custom_put_with_http_info(path, parameters = nil, body = nil, request_options = {}) ⇒ Http::Response

Returns the response.

Parameters:

  • path (String)

    Path of the endpoint, for example ‘1/newFeature`. (required)

  • parameters (Hash<String, Object>) (defaults to: nil)

    Query parameters to apply to the current query.

  • body (Object) (defaults to: nil)

    Parameters to send with the custom request.

  • request_options:

    The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)

Returns:



203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
# File 'lib/algolia/api/composition_client.rb', line 203

def custom_put_with_http_info(path, parameters = nil, body = nil, request_options = {})
  # verify the required parameter 'path' is set
  if @api_client.config.client_side_validation && path.nil?
    raise ArgumentError, "Parameter `path` is required when calling `custom_put`."
  end

  path = "/{path}".sub("{" + "path" + "}", path.to_s)
  query_params = {}
  query_params = query_params.merge(parameters) unless parameters.nil?
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body] || @api_client.object_to_http_body(body)

  new_options = request_options.merge(
    :operation => :"CompositionClient.custom_put",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:PUT, path, new_options)
end

#delete_composition(composition_id, request_options = {}) ⇒ TaskIDResponse

Delete a composition from the current Algolia application.

Required API Key ACLs:

- editSettings

Parameters:

  • composition_id (String)

    Unique Composition ObjectID. (required)

  • request_options:

    The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)

Returns:

  • (TaskIDResponse)


283
284
285
286
# File 'lib/algolia/api/composition_client.rb', line 283

def delete_composition(composition_id, request_options = {})
  response = delete_composition_with_http_info(composition_id, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Composition::TaskIDResponse")
end

#delete_composition_rule(composition_id, algolia_object_id, request_options = {}) ⇒ TaskIDResponse

Delete a Composition Rule from the specified Composition ID.

Required API Key ACLs:

- editSettings

Parameters:

  • composition_id (String)

    Unique Composition ObjectID. (required)

  • algolia_object_id (String)

    Unique identifier of a rule object. (required)

  • request_options:

    The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)

Returns:

  • (TaskIDResponse)


335
336
337
338
# File 'lib/algolia/api/composition_client.rb', line 335

def delete_composition_rule(composition_id, algolia_object_id, request_options = {})
  response = delete_composition_rule_with_http_info(composition_id, algolia_object_id, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Composition::TaskIDResponse")
end

#delete_composition_rule_with_http_info(composition_id, algolia_object_id, request_options = {}) ⇒ Http::Response

Delete a Composition Rule from the specified Composition ID.

Required API Key ACLs:

- editSettings

Parameters:

  • composition_id (String)

    Unique Composition ObjectID. (required)

  • algolia_object_id (String)

    Unique identifier of a rule object. (required)

  • request_options:

    The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)

Returns:



296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
# File 'lib/algolia/api/composition_client.rb', line 296

def delete_composition_rule_with_http_info(composition_id, algolia_object_id, request_options = {})
  # verify the required parameter 'composition_id' is set
  if @api_client.config.client_side_validation && composition_id.nil?
    raise ArgumentError, "Parameter `composition_id` is required when calling `delete_composition_rule`."
  end
  # verify the required parameter 'algolia_object_id' is set
  if @api_client.config.client_side_validation && algolia_object_id.nil?
    raise ArgumentError, "Parameter `algolia_object_id` is required when calling `delete_composition_rule`."
  end

  path = "/1/compositions/{compositionID}/rules/{objectID}"
    .sub("{" + "compositionID" + "}", Transport.encode_uri(composition_id.to_s))
    .sub("{" + "objectID" + "}", Transport.encode_uri(algolia_object_id.to_s))
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body]

  new_options = request_options.merge(
    :operation => :"CompositionClient.delete_composition_rule",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:DELETE, path, new_options)
end

#delete_composition_with_http_info(composition_id, request_options = {}) ⇒ Http::Response

Delete a composition from the current Algolia application.

Required API Key ACLs:

- editSettings

Parameters:

  • composition_id (String)

    Unique Composition ObjectID. (required)

  • request_options:

    The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)

Returns:



248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
# File 'lib/algolia/api/composition_client.rb', line 248

def delete_composition_with_http_info(composition_id, request_options = {})
  # verify the required parameter 'composition_id' is set
  if @api_client.config.client_side_validation && composition_id.nil?
    raise ArgumentError, "Parameter `composition_id` is required when calling `delete_composition`."
  end

  path = "/1/compositions/{compositionID}".sub(
    "{" + "compositionID" + "}",
    Transport.encode_uri(composition_id.to_s)
  )
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body]

  new_options = request_options.merge(
    :operation => :"CompositionClient.delete_composition",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:DELETE, path, new_options)
end

#get_composition(composition_id, request_options = {}) ⇒ Composition

Retrieve a single composition in the current Algolia application.

Required API Key ACLs:

- editSettings
- settings

Parameters:

  • composition_id (String)

    Unique Composition ObjectID. (required)

  • request_options:

    The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)

Returns:



384
385
386
387
# File 'lib/algolia/api/composition_client.rb', line 384

def get_composition(composition_id, request_options = {})
  response = get_composition_with_http_info(composition_id, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Composition::Composition")
end

#get_composition_with_http_info(composition_id, request_options = {}) ⇒ Http::Response

Retrieve a single composition in the current Algolia application.

Required API Key ACLs:

- editSettings
- settings

Parameters:

  • composition_id (String)

    Unique Composition ObjectID. (required)

  • request_options:

    The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)

Returns:



348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
# File 'lib/algolia/api/composition_client.rb', line 348

def get_composition_with_http_info(composition_id, request_options = {})
  # verify the required parameter 'composition_id' is set
  if @api_client.config.client_side_validation && composition_id.nil?
    raise ArgumentError, "Parameter `composition_id` is required when calling `get_composition`."
  end

  path = "/1/compositions/{compositionID}".sub(
    "{" + "compositionID" + "}",
    Transport.encode_uri(composition_id.to_s)
  )
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body]

  new_options = request_options.merge(
    :operation => :"CompositionClient.get_composition",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:GET, path, new_options)
end

#get_rule(composition_id, algolia_object_id, request_options = {}) ⇒ CompositionRule

Retrieves a rule by its ID. To find the object ID of rules, use the [‘search` operation](#tag/Rules/operation/searchRules).

Required API Key ACLs:

- editSettings
- settings

Parameters:

  • composition_id (String)

    Unique Composition ObjectID. (required)

  • algolia_object_id (String)

    Unique identifier of a rule object. (required)

  • request_options:

    The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)

Returns:

  • (CompositionRule)


438
439
440
441
# File 'lib/algolia/api/composition_client.rb', line 438

def get_rule(composition_id, algolia_object_id, request_options = {})
  response = get_rule_with_http_info(composition_id, algolia_object_id, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Composition::CompositionRule")
end

#get_rule_with_http_info(composition_id, algolia_object_id, request_options = {}) ⇒ Http::Response

Retrieves a rule by its ID. To find the object ID of rules, use the [‘search` operation](#tag/Rules/operation/searchRules).

Required API Key ACLs:

- editSettings
- settings

Parameters:

  • composition_id (String)

    Unique Composition ObjectID. (required)

  • algolia_object_id (String)

    Unique identifier of a rule object. (required)

  • request_options:

    The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)

Returns:



398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
# File 'lib/algolia/api/composition_client.rb', line 398

def get_rule_with_http_info(composition_id, algolia_object_id, request_options = {})
  # verify the required parameter 'composition_id' is set
  if @api_client.config.client_side_validation && composition_id.nil?
    raise ArgumentError, "Parameter `composition_id` is required when calling `get_rule`."
  end
  # verify the required parameter 'algolia_object_id' is set
  if @api_client.config.client_side_validation && algolia_object_id.nil?
    raise ArgumentError, "Parameter `algolia_object_id` is required when calling `get_rule`."
  end

  path = "/1/compositions/{compositionID}/rules/{objectID}"
    .sub("{" + "compositionID" + "}", Transport.encode_uri(composition_id.to_s))
    .sub("{" + "objectID" + "}", Transport.encode_uri(algolia_object_id.to_s))
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body]

  new_options = request_options.merge(
    :operation => :"CompositionClient.get_rule",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:GET, path, new_options)
end

#get_task(composition_id, task_id, request_options = {}) ⇒ GetTaskResponse

Checks the status of a given task.

Required API Key ACLs:

- editSettings
- settings
- addObject
- deleteObject
- deleteIndex

Parameters:

  • composition_id (String)

    Unique Composition ObjectID. (required)

  • task_id (Integer)

    Unique task identifier. (required)

  • request_options:

    The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)

Returns:

  • (GetTaskResponse)


498
499
500
501
# File 'lib/algolia/api/composition_client.rb', line 498

def get_task(composition_id, task_id, request_options = {})
  response = get_task_with_http_info(composition_id, task_id, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Composition::GetTaskResponse")
end

#get_task_with_http_info(composition_id, task_id, request_options = {}) ⇒ Http::Response

Checks the status of a given task.

Required API Key ACLs:

- editSettings
- settings
- addObject
- deleteObject
- deleteIndex

Parameters:

  • composition_id (String)

    Unique Composition ObjectID. (required)

  • task_id (Integer)

    Unique task identifier. (required)

  • request_options:

    The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)

Returns:



455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
# File 'lib/algolia/api/composition_client.rb', line 455

def get_task_with_http_info(composition_id, task_id, request_options = {})
  # verify the required parameter 'composition_id' is set
  if @api_client.config.client_side_validation && composition_id.nil?
    raise ArgumentError, "Parameter `composition_id` is required when calling `get_task`."
  end
  # verify the required parameter 'task_id' is set
  if @api_client.config.client_side_validation && task_id.nil?
    raise ArgumentError, "Parameter `task_id` is required when calling `get_task`."
  end

  path = "/1/compositions/{compositionID}/task/{taskID}"
    .sub("{" + "compositionID" + "}", Transport.encode_uri(composition_id.to_s))
    .sub("{" + "taskID" + "}", Transport.encode_uri(task_id.to_s))
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body]

  new_options = request_options.merge(
    :operation => :"CompositionClient.get_task",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:GET, path, new_options)
end

#list_compositions(page = nil, hits_per_page = nil, request_options = {}) ⇒ ListCompositionsResponse

Lists all compositions in the current Algolia application.

Required API Key ACLs:

- editSettings
- settings

Parameters:

  • page (Integer) (defaults to: nil)

    Requested page of the API response. If ‘null`, the API response is not paginated.

  • hits_per_page (Integer) (defaults to: nil)

    Number of hits per page. (default to 100)

  • request_options:

    The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)

Returns:

  • (ListCompositionsResponse)


543
544
545
546
547
548
549
# File 'lib/algolia/api/composition_client.rb', line 543

def list_compositions(page = nil, hits_per_page = nil, request_options = {})
  response = list_compositions_with_http_info(page, hits_per_page, request_options)
  @api_client.deserialize(
    response.body,
    request_options[:debug_return_type] || "Composition::ListCompositionsResponse"
  )
end

#list_compositions_with_http_info(page = nil, hits_per_page = nil, request_options = {}) ⇒ Http::Response

Lists all compositions in the current Algolia application.

Required API Key ACLs:

- editSettings
- settings

Parameters:

  • page (Integer) (defaults to: nil)

    Requested page of the API response. If ‘null`, the API response is not paginated.

  • hits_per_page (Integer) (defaults to: nil)

    Number of hits per page. (default to 100)

  • request_options:

    The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)

Returns:



512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
# File 'lib/algolia/api/composition_client.rb', line 512

def list_compositions_with_http_info(page = nil, hits_per_page = nil, request_options = {})
  path = "/1/compositions"
  query_params = {}
  query_params[:page] = page unless page.nil?
  query_params[:hitsPerPage] = hits_per_page unless hits_per_page.nil?
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body]

  new_options = request_options.merge(
    :operation => :"CompositionClient.list_compositions",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:GET, path, new_options)
end

#multiple_batch(batch_params, request_options = {}) ⇒ MultipleBatchResponse

Adds, updates, or deletes compositions with a single API request.

Required API Key ACLs:

- editSettings

Parameters:

  • batch_params (BatchParams)

    (required)

  • request_options:

    The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)

Returns:

  • (MultipleBatchResponse)


590
591
592
593
594
595
596
# File 'lib/algolia/api/composition_client.rb', line 590

def multiple_batch(batch_params, request_options = {})
  response = multiple_batch_with_http_info(batch_params, request_options)
  @api_client.deserialize(
    response.body,
    request_options[:debug_return_type] || "Composition::MultipleBatchResponse"
  )
end

#multiple_batch_with_http_info(batch_params, request_options = {}) ⇒ Http::Response

Adds, updates, or deletes compositions with a single API request.

Required API Key ACLs:

- editSettings

Parameters:

  • batch_params (BatchParams)

    (required)

  • request_options:

    The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)

Returns:



558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
# File 'lib/algolia/api/composition_client.rb', line 558

def multiple_batch_with_http_info(batch_params, request_options = {})
  # verify the required parameter 'batch_params' is set
  if @api_client.config.client_side_validation && batch_params.nil?
    raise ArgumentError, "Parameter `batch_params` is required when calling `multiple_batch`."
  end

  path = "/1/compositions/*/batch"
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body] || @api_client.object_to_http_body(batch_params)

  new_options = request_options.merge(
    :operation => :"CompositionClient.multiple_batch",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:POST, path, new_options)
end

#put_composition(composition_id, composition, request_options = {}) ⇒ TaskIDResponse

Upsert a composition in the current Algolia application.

Required API Key ACLs:

- editSettings

Parameters:

  • composition_id (String)

    Unique Composition ObjectID. (required)

  • composition (Composition)

    (required)

  • request_options:

    The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)

Returns:

  • (TaskIDResponse)


646
647
648
649
# File 'lib/algolia/api/composition_client.rb', line 646

def put_composition(composition_id, composition, request_options = {})
  response = put_composition_with_http_info(composition_id, composition, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Composition::TaskIDResponse")
end

#put_composition_rule(composition_id, algolia_object_id, composition_rule, request_options = {}) ⇒ TaskIDResponse

Upsert a Composition Rule for the specified composition ID.

Required API Key ACLs:

- editSettings

Parameters:

  • composition_id (String)

    Unique Composition ObjectID. (required)

  • algolia_object_id (String)

    Unique identifier of a rule object. (required)

  • composition_rule (CompositionRule)

    (required)

  • request_options:

    The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)

Returns:

  • (TaskIDResponse)


704
705
706
707
708
709
710
711
712
# File 'lib/algolia/api/composition_client.rb', line 704

def put_composition_rule(composition_id, algolia_object_id, composition_rule, request_options = {})
  response = put_composition_rule_with_http_info(
    composition_id,
    algolia_object_id,
    composition_rule,
    request_options
  )
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Composition::TaskIDResponse")
end

#put_composition_rule_with_http_info(composition_id, algolia_object_id, composition_rule, request_options = {}) ⇒ Http::Response

Upsert a Composition Rule for the specified composition ID.

Required API Key ACLs:

- editSettings

Parameters:

  • composition_id (String)

    Unique Composition ObjectID. (required)

  • algolia_object_id (String)

    Unique identifier of a rule object. (required)

  • composition_rule (CompositionRule)

    (required)

  • request_options:

    The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)

Returns:



660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
# File 'lib/algolia/api/composition_client.rb', line 660

def put_composition_rule_with_http_info(composition_id, algolia_object_id, composition_rule, request_options = {})
  # verify the required parameter 'composition_id' is set
  if @api_client.config.client_side_validation && composition_id.nil?
    raise ArgumentError, "Parameter `composition_id` is required when calling `put_composition_rule`."
  end
  # verify the required parameter 'algolia_object_id' is set
  if @api_client.config.client_side_validation && algolia_object_id.nil?
    raise ArgumentError, "Parameter `algolia_object_id` is required when calling `put_composition_rule`."
  end
  # verify the required parameter 'composition_rule' is set
  if @api_client.config.client_side_validation && composition_rule.nil?
    raise ArgumentError, "Parameter `composition_rule` is required when calling `put_composition_rule`."
  end

  path = "/1/compositions/{compositionID}/rules/{objectID}"
    .sub("{" + "compositionID" + "}", Transport.encode_uri(composition_id.to_s))
    .sub("{" + "objectID" + "}", Transport.encode_uri(algolia_object_id.to_s))
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body] || @api_client.object_to_http_body(composition_rule)

  new_options = request_options.merge(
    :operation => :"CompositionClient.put_composition_rule",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:PUT, path, new_options)
end

#put_composition_with_http_info(composition_id, composition, request_options = {}) ⇒ Http::Response

Upsert a composition in the current Algolia application.

Required API Key ACLs:

- editSettings

Parameters:

  • composition_id (String)

    Unique Composition ObjectID. (required)

  • composition (Composition)

    (required)

  • request_options:

    The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)

Returns:



606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
# File 'lib/algolia/api/composition_client.rb', line 606

def put_composition_with_http_info(composition_id, composition, request_options = {})
  # verify the required parameter 'composition_id' is set
  if @api_client.config.client_side_validation && composition_id.nil?
    raise ArgumentError, "Parameter `composition_id` is required when calling `put_composition`."
  end
  # verify the required parameter 'composition' is set
  if @api_client.config.client_side_validation && composition.nil?
    raise ArgumentError, "Parameter `composition` is required when calling `put_composition`."
  end

  path = "/1/compositions/{compositionID}".sub(
    "{" + "compositionID" + "}",
    Transport.encode_uri(composition_id.to_s)
  )
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body] || @api_client.object_to_http_body(composition)

  new_options = request_options.merge(
    :operation => :"CompositionClient.put_composition",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:PUT, path, new_options)
end

#save_rules(composition_id, rules, request_options = {}) ⇒ RulesMultipleBatchResponse

Create or update or delete multiple composition rules.

Required API Key ACLs:

- editSettings

Parameters:

  • composition_id (String)

    Unique Composition ObjectID. (required)

  • rules (CompositionRulesBatchParams)

    (required)

  • request_options:

    The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)

Returns:

  • (RulesMultipleBatchResponse)


762
763
764
765
766
767
768
# File 'lib/algolia/api/composition_client.rb', line 762

def save_rules(composition_id, rules, request_options = {})
  response = save_rules_with_http_info(composition_id, rules, request_options)
  @api_client.deserialize(
    response.body,
    request_options[:debug_return_type] || "Composition::RulesMultipleBatchResponse"
  )
end

#save_rules_with_http_info(composition_id, rules, request_options = {}) ⇒ Http::Response

Create or update or delete multiple composition rules.

Required API Key ACLs:

- editSettings

Parameters:

  • composition_id (String)

    Unique Composition ObjectID. (required)

  • rules (CompositionRulesBatchParams)

    (required)

  • request_options:

    The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)

Returns:



722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
# File 'lib/algolia/api/composition_client.rb', line 722

def save_rules_with_http_info(composition_id, rules, request_options = {})
  # verify the required parameter 'composition_id' is set
  if @api_client.config.client_side_validation && composition_id.nil?
    raise ArgumentError, "Parameter `composition_id` is required when calling `save_rules`."
  end
  # verify the required parameter 'rules' is set
  if @api_client.config.client_side_validation && rules.nil?
    raise ArgumentError, "Parameter `rules` is required when calling `save_rules`."
  end

  path = "/1/compositions/{compositionID}/rules/batch".sub(
    "{" + "compositionID" + "}",
    Transport.encode_uri(composition_id.to_s)
  )
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body] || @api_client.object_to_http_body(rules)

  new_options = request_options.merge(
    :operation => :"CompositionClient.save_rules",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:POST, path, new_options)
end

#search(composition_id, request_body, request_options = {}) ⇒ SearchResponse

Runs a query on a single composition and returns matching results.

Required API Key ACLs:

- search

Parameters:

  • composition_id (String)

    Unique Composition ObjectID. (required)

  • request_body (RequestBody)

    (required)

  • request_options:

    The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)

Returns:

  • (SearchResponse)


818
819
820
821
# File 'lib/algolia/api/composition_client.rb', line 818

def search(composition_id, request_body, request_options = {})
  response = search_with_http_info(composition_id, request_body, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Composition::SearchResponse")
end

#search_composition_rules(composition_id, search_composition_rules_params = nil, request_options = {}) ⇒ SearchCompositionRulesResponse

Searches for composition rules in your index.

Required API Key ACLs:

- settings

Parameters:

  • composition_id (String)

    Unique Composition ObjectID. (required)

  • search_composition_rules_params (SearchCompositionRulesParams) (defaults to: nil)
  • request_options:

    The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)

Returns:

  • (SearchCompositionRulesResponse)


871
872
873
874
875
876
877
878
879
880
881
# File 'lib/algolia/api/composition_client.rb', line 871

def search_composition_rules(composition_id, search_composition_rules_params = nil, request_options = {})
  response = search_composition_rules_with_http_info(
    composition_id,
    search_composition_rules_params,
    request_options
  )
  @api_client.deserialize(
    response.body,
    request_options[:debug_return_type] || "Composition::SearchCompositionRulesResponse"
  )
end

#search_composition_rules_with_http_info(composition_id, search_composition_rules_params = nil, request_options = {}) ⇒ Http::Response

Searches for composition rules in your index.

Required API Key ACLs:

- settings

Parameters:

  • composition_id (String)

    Unique Composition ObjectID. (required)

  • search_composition_rules_params (SearchCompositionRulesParams) (defaults to: nil)
  • request_options:

    The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)

Returns:



831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
# File 'lib/algolia/api/composition_client.rb', line 831

def search_composition_rules_with_http_info(
  composition_id,
  search_composition_rules_params = nil,
  request_options = {}
)
  # verify the required parameter 'composition_id' is set
  if @api_client.config.client_side_validation && composition_id.nil?
    raise ArgumentError, "Parameter `composition_id` is required when calling `search_composition_rules`."
  end

  path = "/1/compositions/{compositionID}/rules/search".sub(
    "{" + "compositionID" + "}",
    Transport.encode_uri(composition_id.to_s)
  )
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body] || @api_client.object_to_http_body(search_composition_rules_params)

  new_options = request_options.merge(
    :operation => :"CompositionClient.search_composition_rules",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:POST, path, new_options)
end

#search_for_facet_values(composition_id, facet_name, search_for_facet_values_request = nil, request_options = {}) ⇒ SearchForFacetValuesResponse

Searches for values of a specified facet attribute on the composition’s main source’s index. - By default, facet values are sorted by decreasing count. You can adjust this with the ‘sortFacetValueBy` parameter. - Searching for facet values doesn’t work if you have **more than 65 searchable facets and searchable attributes combined**.

Required API Key ACLs:

- search

Parameters:

  • composition_id (String)

    Unique Composition ObjectID. (required)

  • facet_name (String)

    Facet attribute in which to search for values. This attribute must be included in the ‘attributesForFaceting` index setting with the `searchable()` modifier. (required)

  • search_for_facet_values_request (SearchForFacetValuesRequest) (defaults to: nil)
  • request_options:

    The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)

Returns:

  • (SearchForFacetValuesResponse)


937
938
939
940
941
942
943
944
945
946
947
948
# File 'lib/algolia/api/composition_client.rb', line 937

def search_for_facet_values(composition_id, facet_name, search_for_facet_values_request = nil, request_options = {})
  response = search_for_facet_values_with_http_info(
    composition_id,
    facet_name,
    search_for_facet_values_request,
    request_options
  )
  @api_client.deserialize(
    response.body,
    request_options[:debug_return_type] || "Composition::SearchForFacetValuesResponse"
  )
end

#search_for_facet_values_with_http_info(composition_id, facet_name, search_for_facet_values_request = nil, request_options = {}) ⇒ Http::Response

Searches for values of a specified facet attribute on the composition’s main source’s index. - By default, facet values are sorted by decreasing count. You can adjust this with the ‘sortFacetValueBy` parameter. - Searching for facet values doesn’t work if you have **more than 65 searchable facets and searchable attributes combined**.

Required API Key ACLs:

- search

Parameters:

  • composition_id (String)

    Unique Composition ObjectID. (required)

  • facet_name (String)

    Facet attribute in which to search for values. This attribute must be included in the ‘attributesForFaceting` index setting with the `searchable()` modifier. (required)

  • search_for_facet_values_request (SearchForFacetValuesRequest) (defaults to: nil)
  • request_options:

    The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)

Returns:



892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
# File 'lib/algolia/api/composition_client.rb', line 892

def search_for_facet_values_with_http_info(
  composition_id,
  facet_name,
  search_for_facet_values_request = nil,
  request_options = {}
)
  # verify the required parameter 'composition_id' is set
  if @api_client.config.client_side_validation && composition_id.nil?
    raise ArgumentError, "Parameter `composition_id` is required when calling `search_for_facet_values`."
  end
  # verify the required parameter 'facet_name' is set
  if @api_client.config.client_side_validation && facet_name.nil?
    raise ArgumentError, "Parameter `facet_name` is required when calling `search_for_facet_values`."
  end

  path = "/1/compositions/{compositionID}/facets/{facetName}/query"
    .sub("{" + "compositionID" + "}", Transport.encode_uri(composition_id.to_s))
    .sub("{" + "facetName" + "}", Transport.encode_uri(facet_name.to_s))
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body] || @api_client.object_to_http_body(search_for_facet_values_request)

  new_options = request_options.merge(
    :operation => :"CompositionClient.search_for_facet_values",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => true
  )

  @api_client.call_api(:POST, path, new_options)
end

#search_with_http_info(composition_id, request_body, request_options = {}) ⇒ Http::Response

Runs a query on a single composition and returns matching results.

Required API Key ACLs:

- search

Parameters:

  • composition_id (String)

    Unique Composition ObjectID. (required)

  • request_body (RequestBody)

    (required)

  • request_options:

    The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)

Returns:



778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
# File 'lib/algolia/api/composition_client.rb', line 778

def search_with_http_info(composition_id, request_body, request_options = {})
  # verify the required parameter 'composition_id' is set
  if @api_client.config.client_side_validation && composition_id.nil?
    raise ArgumentError, "Parameter `composition_id` is required when calling `search`."
  end
  # verify the required parameter 'request_body' is set
  if @api_client.config.client_side_validation && request_body.nil?
    raise ArgumentError, "Parameter `request_body` is required when calling `search`."
  end

  path = "/1/compositions/{compositionID}/run".sub(
    "{" + "compositionID" + "}",
    Transport.encode_uri(composition_id.to_s)
  )
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body] || @api_client.object_to_http_body(request_body)

  new_options = request_options.merge(
    :operation => :"CompositionClient.search",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => true
  )

  @api_client.call_api(:POST, path, new_options)
end

#set_client_api_key(api_key) ⇒ void

This method returns an undefined value.

Helper method to switch the API key used to authenticate the requests.

Parameters:

  • api_key (String)

    the new API key to use.



53
54
55
56
57
# File 'lib/algolia/api/composition_client.rb', line 53

def set_client_api_key(api_key)
  @api_client.set_client_api_key(api_key)

  self
end