algolia 3.39.0 → 3.40.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 +4 -4
- data/.github/workflows/issue.yml +1 -1
- data/.github/workflows/release.yml +1 -1
- data/CHANGELOG.md +21 -0
- data/Gemfile.lock +1 -1
- data/lib/algolia/api/abtesting_client.rb +16 -0
- data/lib/algolia/api/abtesting_v3_client.rb +16 -0
- data/lib/algolia/api/analytics_client.rb +100 -0
- data/lib/algolia/api/composition_client.rb +83 -0
- data/lib/algolia/api/ingestion_client.rb +230 -0
- data/lib/algolia/api/insights_client.rb +20 -0
- data/lib/algolia/api/monitoring_client.rb +36 -0
- data/lib/algolia/api/personalization_client.rb +24 -0
- data/lib/algolia/api/query_suggestions_client.rb +36 -0
- data/lib/algolia/api/recommend_client.rb +44 -0
- data/lib/algolia/api/search_client.rb +550 -22
- data/lib/algolia/chunked_helper_options.rb +15 -0
- data/lib/algolia/configuration.rb +3 -1
- data/lib/algolia/models/abtesting/ab_test.rb +5 -0
- data/lib/algolia/models/ingestion/destination_update.rb +2 -11
- data/lib/algolia/models/ingestion/destination_update_input.rb +228 -0
- data/lib/algolia/models/query-suggestions/configuration.rb +1 -0
- data/lib/algolia/models/query-suggestions/configuration_response.rb +1 -0
- data/lib/algolia/models/query-suggestions/configuration_with_index.rb +1 -0
- data/lib/algolia/models/query-suggestions/source_index.rb +4 -0
- data/lib/algolia/models/recommend/fallback_params.rb +2 -1
- data/lib/algolia/models/recommend/recommend_search_params.rb +2 -1
- data/lib/algolia/models/search/browse_params_object.rb +2 -1
- data/lib/algolia/models/search/consequence_params.rb +2 -1
- data/lib/algolia/models/search/fetched_index.rb +25 -4
- data/lib/algolia/models/search/fetched_index_ab_test.rb +253 -0
- data/lib/algolia/models/search/fetched_index_ab_test_target.rb +210 -0
- data/lib/algolia/models/search/fetched_index_ab_test_variant.rb +242 -0
- data/lib/algolia/models/search/index_settings.rb +2 -1
- data/lib/algolia/models/search/search_for_facets.rb +2 -1
- data/lib/algolia/models/search/search_for_hits.rb +2 -1
- data/lib/algolia/models/search/search_params_object.rb +2 -1
- data/lib/algolia/models/search/search_response_partial.rb +587 -0
- data/lib/algolia/models/search/search_result.rb +2 -1
- data/lib/algolia/models/search/settings_response.rb +2 -1
- data/lib/algolia/version.rb +1 -1
- data/lib/algolia.rb +1 -2
- metadata +8 -2
|
@@ -6,6 +6,49 @@ require "openssl"
|
|
|
6
6
|
require "base64"
|
|
7
7
|
|
|
8
8
|
module Algolia
|
|
9
|
+
# Configuration options for the ingestion transporter used by *_with_transformation helpers.
|
|
10
|
+
# When passed to SearchClient.with_transformation or set via set_transformation_options,
|
|
11
|
+
# the ingestion transporter is eagerly created using Ingestion API defaults (25s timeouts,
|
|
12
|
+
# no compression). Only fields explicitly set here override those defaults.
|
|
13
|
+
# See https://www.algolia.com/doc/libraries/ruby/v3/methods/ingestion
|
|
14
|
+
class TransformationOptions
|
|
15
|
+
attr_accessor(
|
|
16
|
+
:region,
|
|
17
|
+
:connect_timeout,
|
|
18
|
+
:read_timeout,
|
|
19
|
+
:write_timeout,
|
|
20
|
+
:hosts,
|
|
21
|
+
:compression_type,
|
|
22
|
+
:header_params
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
def initialize(region, opts = {})
|
|
26
|
+
if region.nil? || region.to_s.strip.empty?
|
|
27
|
+
raise(
|
|
28
|
+
ArgumentError,
|
|
29
|
+
"`region` is required in `TransformationOptions`. See https://www.algolia.com/doc/libraries/ruby/v3/methods/ingestion"
|
|
30
|
+
)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
valid_keys = %i[connect_timeout read_timeout write_timeout hosts compression_type header_params]
|
|
34
|
+
unknown = opts.keys - valid_keys
|
|
35
|
+
unless unknown.empty?
|
|
36
|
+
raise(
|
|
37
|
+
ArgumentError,
|
|
38
|
+
"Unknown TransformationOptions keys: #{unknown.join(", ")}. Valid keys are: #{valid_keys.join(", ")}"
|
|
39
|
+
)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
@region = region
|
|
43
|
+
@connect_timeout = opts[:connect_timeout]
|
|
44
|
+
@read_timeout = opts[:read_timeout]
|
|
45
|
+
@write_timeout = opts[:write_timeout]
|
|
46
|
+
@hosts = opts[:hosts]
|
|
47
|
+
@compression_type = opts[:compression_type]
|
|
48
|
+
@header_params = opts[:header_params]
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
9
52
|
class SearchClient
|
|
10
53
|
attr_accessor :api_client
|
|
11
54
|
|
|
@@ -27,6 +70,10 @@ module Algolia
|
|
|
27
70
|
end
|
|
28
71
|
|
|
29
72
|
@api_client = Algolia::ApiClient.new(config)
|
|
73
|
+
@ingestion_transporter = nil
|
|
74
|
+
if config.transformation_options
|
|
75
|
+
@ingestion_transporter = _build_ingestion_transporter(config.transformation_options)
|
|
76
|
+
end
|
|
30
77
|
end
|
|
31
78
|
|
|
32
79
|
def self.create(app_id, api_key, opts = {})
|
|
@@ -49,6 +96,31 @@ module Algolia
|
|
|
49
96
|
new(config)
|
|
50
97
|
end
|
|
51
98
|
|
|
99
|
+
# Creates a SearchClient configured with a TransformationOptions for use with
|
|
100
|
+
# *_with_transformation helpers. The ingestion transporter is initialised eagerly using
|
|
101
|
+
# Ingestion API defaults (25s timeouts); set override fields on TransformationOptions to
|
|
102
|
+
# change specific defaults.
|
|
103
|
+
# See https://www.algolia.com/doc/libraries/ruby/v3/methods/ingestion
|
|
104
|
+
#
|
|
105
|
+
# @param app_id [String] the Algolia application ID. (required)
|
|
106
|
+
# @param api_key [String] the Algolia API key. (required)
|
|
107
|
+
# @param transformation_options [TransformationOptions] the transformation options including region and optional ingestion transporter overrides. (required)
|
|
108
|
+
# @param opts [Hash] additional configuration options passed to the search client. (optional)
|
|
109
|
+
# @return [SearchClient]
|
|
110
|
+
def self.with_transformation(app_id, api_key, transformation_options, opts = {})
|
|
111
|
+
opts = opts.dup
|
|
112
|
+
hosts = opts.delete(:hosts)
|
|
113
|
+
if hosts
|
|
114
|
+
config = Algolia::Configuration.new(app_id, api_key, hosts, "Search", opts)
|
|
115
|
+
client = new(config)
|
|
116
|
+
else
|
|
117
|
+
client = create(app_id, api_key, opts)
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
client.set_transformation_options(transformation_options)
|
|
121
|
+
client
|
|
122
|
+
end
|
|
123
|
+
|
|
52
124
|
# Helper method to switch the API key used to authenticate the requests.
|
|
53
125
|
#
|
|
54
126
|
# @param api_key [String] the new API key to use.
|
|
@@ -123,10 +195,18 @@ module Algolia
|
|
|
123
195
|
if @api_client.config.client_side_validation && index_name.nil?
|
|
124
196
|
raise ArgumentError, "Parameter `index_name` is required when calling `add_or_update_object`."
|
|
125
197
|
end
|
|
198
|
+
# verify the required parameter 'index_name' is not empty
|
|
199
|
+
if @api_client.config.client_side_validation && index_name.empty?
|
|
200
|
+
raise ArgumentError, "Parameter `index_name` is required when calling `add_or_update_object`."
|
|
201
|
+
end
|
|
126
202
|
# verify the required parameter 'algolia_object_id' is set
|
|
127
203
|
if @api_client.config.client_side_validation && algolia_object_id.nil?
|
|
128
204
|
raise ArgumentError, "Parameter `algolia_object_id` is required when calling `add_or_update_object`."
|
|
129
205
|
end
|
|
206
|
+
# verify the required parameter 'algolia_object_id' is not empty
|
|
207
|
+
if @api_client.config.client_side_validation && algolia_object_id.empty?
|
|
208
|
+
raise ArgumentError, "Parameter `algolia_object_id` is required when calling `add_or_update_object`."
|
|
209
|
+
end
|
|
130
210
|
# verify the required parameter 'body' is set
|
|
131
211
|
if @api_client.config.client_side_validation && body.nil?
|
|
132
212
|
raise ArgumentError, "Parameter `body` is required when calling `add_or_update_object`."
|
|
@@ -229,6 +309,10 @@ module Algolia
|
|
|
229
309
|
if @api_client.config.client_side_validation && x_algolia_user_id.nil?
|
|
230
310
|
raise ArgumentError, "Parameter `x_algolia_user_id` is required when calling `assign_user_id`."
|
|
231
311
|
end
|
|
312
|
+
# verify the required parameter 'x_algolia_user_id' is not empty
|
|
313
|
+
if @api_client.config.client_side_validation && x_algolia_user_id.empty?
|
|
314
|
+
raise ArgumentError, "Parameter `x_algolia_user_id` is required when calling `assign_user_id`."
|
|
315
|
+
end
|
|
232
316
|
# verify the required parameter 'assign_user_id_params' is set
|
|
233
317
|
if @api_client.config.client_side_validation && assign_user_id_params.nil?
|
|
234
318
|
raise ArgumentError, "Parameter `assign_user_id_params` is required when calling `assign_user_id`."
|
|
@@ -280,6 +364,10 @@ module Algolia
|
|
|
280
364
|
if @api_client.config.client_side_validation && index_name.nil?
|
|
281
365
|
raise ArgumentError, "Parameter `index_name` is required when calling `batch`."
|
|
282
366
|
end
|
|
367
|
+
# verify the required parameter 'index_name' is not empty
|
|
368
|
+
if @api_client.config.client_side_validation && index_name.empty?
|
|
369
|
+
raise ArgumentError, "Parameter `index_name` is required when calling `batch`."
|
|
370
|
+
end
|
|
283
371
|
# verify the required parameter 'batch_write_params' is set
|
|
284
372
|
if @api_client.config.client_side_validation && batch_write_params.nil?
|
|
285
373
|
raise ArgumentError, "Parameter `batch_write_params` is required when calling `batch`."
|
|
@@ -331,6 +419,10 @@ module Algolia
|
|
|
331
419
|
if @api_client.config.client_side_validation && x_algolia_user_id.nil?
|
|
332
420
|
raise ArgumentError, "Parameter `x_algolia_user_id` is required when calling `batch_assign_user_ids`."
|
|
333
421
|
end
|
|
422
|
+
# verify the required parameter 'x_algolia_user_id' is not empty
|
|
423
|
+
if @api_client.config.client_side_validation && x_algolia_user_id.empty?
|
|
424
|
+
raise ArgumentError, "Parameter `x_algolia_user_id` is required when calling `batch_assign_user_ids`."
|
|
425
|
+
end
|
|
334
426
|
# verify the required parameter 'batch_assign_user_ids_params' is set
|
|
335
427
|
if @api_client.config.client_side_validation && batch_assign_user_ids_params.nil?
|
|
336
428
|
raise(
|
|
@@ -445,6 +537,10 @@ module Algolia
|
|
|
445
537
|
if @api_client.config.client_side_validation && index_name.nil?
|
|
446
538
|
raise ArgumentError, "Parameter `index_name` is required when calling `browse`."
|
|
447
539
|
end
|
|
540
|
+
# verify the required parameter 'index_name' is not empty
|
|
541
|
+
if @api_client.config.client_side_validation && index_name.empty?
|
|
542
|
+
raise ArgumentError, "Parameter `index_name` is required when calling `browse`."
|
|
543
|
+
end
|
|
448
544
|
|
|
449
545
|
path = "/1/indexes/{indexName}/browse".sub("{" + "indexName" + "}", Transport.encode_uri(index_name.to_s))
|
|
450
546
|
query_params = {}
|
|
@@ -490,6 +586,10 @@ module Algolia
|
|
|
490
586
|
if @api_client.config.client_side_validation && index_name.nil?
|
|
491
587
|
raise ArgumentError, "Parameter `index_name` is required when calling `clear_objects`."
|
|
492
588
|
end
|
|
589
|
+
# verify the required parameter 'index_name' is not empty
|
|
590
|
+
if @api_client.config.client_side_validation && index_name.empty?
|
|
591
|
+
raise ArgumentError, "Parameter `index_name` is required when calling `clear_objects`."
|
|
592
|
+
end
|
|
493
593
|
|
|
494
594
|
path = "/1/indexes/{indexName}/clear".sub("{" + "indexName" + "}", Transport.encode_uri(index_name.to_s))
|
|
495
595
|
query_params = {}
|
|
@@ -535,6 +635,10 @@ module Algolia
|
|
|
535
635
|
if @api_client.config.client_side_validation && index_name.nil?
|
|
536
636
|
raise ArgumentError, "Parameter `index_name` is required when calling `clear_rules`."
|
|
537
637
|
end
|
|
638
|
+
# verify the required parameter 'index_name' is not empty
|
|
639
|
+
if @api_client.config.client_side_validation && index_name.empty?
|
|
640
|
+
raise ArgumentError, "Parameter `index_name` is required when calling `clear_rules`."
|
|
641
|
+
end
|
|
538
642
|
|
|
539
643
|
path = "/1/indexes/{indexName}/rules/clear".sub("{" + "indexName" + "}", Transport.encode_uri(index_name.to_s))
|
|
540
644
|
query_params = {}
|
|
@@ -582,6 +686,10 @@ module Algolia
|
|
|
582
686
|
if @api_client.config.client_side_validation && index_name.nil?
|
|
583
687
|
raise ArgumentError, "Parameter `index_name` is required when calling `clear_synonyms`."
|
|
584
688
|
end
|
|
689
|
+
# verify the required parameter 'index_name' is not empty
|
|
690
|
+
if @api_client.config.client_side_validation && index_name.empty?
|
|
691
|
+
raise ArgumentError, "Parameter `index_name` is required when calling `clear_synonyms`."
|
|
692
|
+
end
|
|
585
693
|
|
|
586
694
|
path = "/1/indexes/{indexName}/synonyms/clear".sub("{" + "indexName" + "}", Transport.encode_uri(index_name.to_s))
|
|
587
695
|
query_params = {}
|
|
@@ -627,6 +735,10 @@ module Algolia
|
|
|
627
735
|
if @api_client.config.client_side_validation && path.nil?
|
|
628
736
|
raise ArgumentError, "Parameter `path` is required when calling `custom_delete`."
|
|
629
737
|
end
|
|
738
|
+
# verify the required parameter 'path' is not empty
|
|
739
|
+
if @api_client.config.client_side_validation && path.empty?
|
|
740
|
+
raise ArgumentError, "Parameter `path` is required when calling `custom_delete`."
|
|
741
|
+
end
|
|
630
742
|
|
|
631
743
|
path = "/{path}".sub("{" + "path" + "}", path.to_s)
|
|
632
744
|
query_params = {}
|
|
@@ -670,6 +782,10 @@ module Algolia
|
|
|
670
782
|
if @api_client.config.client_side_validation && path.nil?
|
|
671
783
|
raise ArgumentError, "Parameter `path` is required when calling `custom_get`."
|
|
672
784
|
end
|
|
785
|
+
# verify the required parameter 'path' is not empty
|
|
786
|
+
if @api_client.config.client_side_validation && path.empty?
|
|
787
|
+
raise ArgumentError, "Parameter `path` is required when calling `custom_get`."
|
|
788
|
+
end
|
|
673
789
|
|
|
674
790
|
path = "/{path}".sub("{" + "path" + "}", path.to_s)
|
|
675
791
|
query_params = {}
|
|
@@ -714,6 +830,10 @@ module Algolia
|
|
|
714
830
|
if @api_client.config.client_side_validation && path.nil?
|
|
715
831
|
raise ArgumentError, "Parameter `path` is required when calling `custom_post`."
|
|
716
832
|
end
|
|
833
|
+
# verify the required parameter 'path' is not empty
|
|
834
|
+
if @api_client.config.client_side_validation && path.empty?
|
|
835
|
+
raise ArgumentError, "Parameter `path` is required when calling `custom_post`."
|
|
836
|
+
end
|
|
717
837
|
|
|
718
838
|
path = "/{path}".sub("{" + "path" + "}", path.to_s)
|
|
719
839
|
query_params = {}
|
|
@@ -759,6 +879,10 @@ module Algolia
|
|
|
759
879
|
if @api_client.config.client_side_validation && path.nil?
|
|
760
880
|
raise ArgumentError, "Parameter `path` is required when calling `custom_put`."
|
|
761
881
|
end
|
|
882
|
+
# verify the required parameter 'path' is not empty
|
|
883
|
+
if @api_client.config.client_side_validation && path.empty?
|
|
884
|
+
raise ArgumentError, "Parameter `path` is required when calling `custom_put`."
|
|
885
|
+
end
|
|
762
886
|
|
|
763
887
|
path = "/{path}".sub("{" + "path" + "}", path.to_s)
|
|
764
888
|
query_params = {}
|
|
@@ -804,6 +928,10 @@ module Algolia
|
|
|
804
928
|
if @api_client.config.client_side_validation && key.nil?
|
|
805
929
|
raise ArgumentError, "Parameter `key` is required when calling `delete_api_key`."
|
|
806
930
|
end
|
|
931
|
+
# verify the required parameter 'key' is not empty
|
|
932
|
+
if @api_client.config.client_side_validation && key.empty?
|
|
933
|
+
raise ArgumentError, "Parameter `key` is required when calling `delete_api_key`."
|
|
934
|
+
end
|
|
807
935
|
|
|
808
936
|
path = "/1/keys/{key}".sub("{" + "key" + "}", Transport.encode_uri(key.to_s))
|
|
809
937
|
query_params = {}
|
|
@@ -849,6 +977,10 @@ module Algolia
|
|
|
849
977
|
if @api_client.config.client_side_validation && index_name.nil?
|
|
850
978
|
raise ArgumentError, "Parameter `index_name` is required when calling `delete_by`."
|
|
851
979
|
end
|
|
980
|
+
# verify the required parameter 'index_name' is not empty
|
|
981
|
+
if @api_client.config.client_side_validation && index_name.empty?
|
|
982
|
+
raise ArgumentError, "Parameter `index_name` is required when calling `delete_by`."
|
|
983
|
+
end
|
|
852
984
|
# verify the required parameter 'delete_by_params' is set
|
|
853
985
|
if @api_client.config.client_side_validation && delete_by_params.nil?
|
|
854
986
|
raise ArgumentError, "Parameter `delete_by_params` is required when calling `delete_by`."
|
|
@@ -898,6 +1030,10 @@ module Algolia
|
|
|
898
1030
|
if @api_client.config.client_side_validation && index_name.nil?
|
|
899
1031
|
raise ArgumentError, "Parameter `index_name` is required when calling `delete_index`."
|
|
900
1032
|
end
|
|
1033
|
+
# verify the required parameter 'index_name' is not empty
|
|
1034
|
+
if @api_client.config.client_side_validation && index_name.empty?
|
|
1035
|
+
raise ArgumentError, "Parameter `index_name` is required when calling `delete_index`."
|
|
1036
|
+
end
|
|
901
1037
|
|
|
902
1038
|
path = "/1/indexes/{indexName}".sub("{" + "indexName" + "}", Transport.encode_uri(index_name.to_s))
|
|
903
1039
|
query_params = {}
|
|
@@ -943,10 +1079,18 @@ module Algolia
|
|
|
943
1079
|
if @api_client.config.client_side_validation && index_name.nil?
|
|
944
1080
|
raise ArgumentError, "Parameter `index_name` is required when calling `delete_object`."
|
|
945
1081
|
end
|
|
1082
|
+
# verify the required parameter 'index_name' is not empty
|
|
1083
|
+
if @api_client.config.client_side_validation && index_name.empty?
|
|
1084
|
+
raise ArgumentError, "Parameter `index_name` is required when calling `delete_object`."
|
|
1085
|
+
end
|
|
946
1086
|
# verify the required parameter 'algolia_object_id' is set
|
|
947
1087
|
if @api_client.config.client_side_validation && algolia_object_id.nil?
|
|
948
1088
|
raise ArgumentError, "Parameter `algolia_object_id` is required when calling `delete_object`."
|
|
949
1089
|
end
|
|
1090
|
+
# verify the required parameter 'algolia_object_id' is not empty
|
|
1091
|
+
if @api_client.config.client_side_validation && algolia_object_id.empty?
|
|
1092
|
+
raise ArgumentError, "Parameter `algolia_object_id` is required when calling `delete_object`."
|
|
1093
|
+
end
|
|
950
1094
|
|
|
951
1095
|
path = "/1/indexes/{indexName}/{objectID}".sub("{" + "indexName" + "}", Transport.encode_uri(index_name.to_s)).sub(
|
|
952
1096
|
"{" + "objectID" + "}",
|
|
@@ -997,10 +1141,18 @@ module Algolia
|
|
|
997
1141
|
if @api_client.config.client_side_validation && index_name.nil?
|
|
998
1142
|
raise ArgumentError, "Parameter `index_name` is required when calling `delete_rule`."
|
|
999
1143
|
end
|
|
1144
|
+
# verify the required parameter 'index_name' is not empty
|
|
1145
|
+
if @api_client.config.client_side_validation && index_name.empty?
|
|
1146
|
+
raise ArgumentError, "Parameter `index_name` is required when calling `delete_rule`."
|
|
1147
|
+
end
|
|
1000
1148
|
# verify the required parameter 'algolia_object_id' is set
|
|
1001
1149
|
if @api_client.config.client_side_validation && algolia_object_id.nil?
|
|
1002
1150
|
raise ArgumentError, "Parameter `algolia_object_id` is required when calling `delete_rule`."
|
|
1003
1151
|
end
|
|
1152
|
+
# verify the required parameter 'algolia_object_id' is not empty
|
|
1153
|
+
if @api_client.config.client_side_validation && algolia_object_id.empty?
|
|
1154
|
+
raise ArgumentError, "Parameter `algolia_object_id` is required when calling `delete_rule`."
|
|
1155
|
+
end
|
|
1004
1156
|
|
|
1005
1157
|
path = "/1/indexes/{indexName}/rules/{objectID}"
|
|
1006
1158
|
.sub("{" + "indexName" + "}", Transport.encode_uri(index_name.to_s))
|
|
@@ -1050,6 +1202,10 @@ module Algolia
|
|
|
1050
1202
|
if @api_client.config.client_side_validation && source.nil?
|
|
1051
1203
|
raise ArgumentError, "Parameter `source` is required when calling `delete_source`."
|
|
1052
1204
|
end
|
|
1205
|
+
# verify the required parameter 'source' is not empty
|
|
1206
|
+
if @api_client.config.client_side_validation && source.empty?
|
|
1207
|
+
raise ArgumentError, "Parameter `source` is required when calling `delete_source`."
|
|
1208
|
+
end
|
|
1053
1209
|
|
|
1054
1210
|
path = "/1/security/sources/{source}".sub("{" + "source" + "}", Transport.encode_uri(source.to_s))
|
|
1055
1211
|
query_params = {}
|
|
@@ -1096,10 +1252,18 @@ module Algolia
|
|
|
1096
1252
|
if @api_client.config.client_side_validation && index_name.nil?
|
|
1097
1253
|
raise ArgumentError, "Parameter `index_name` is required when calling `delete_synonym`."
|
|
1098
1254
|
end
|
|
1255
|
+
# verify the required parameter 'index_name' is not empty
|
|
1256
|
+
if @api_client.config.client_side_validation && index_name.empty?
|
|
1257
|
+
raise ArgumentError, "Parameter `index_name` is required when calling `delete_synonym`."
|
|
1258
|
+
end
|
|
1099
1259
|
# verify the required parameter 'algolia_object_id' is set
|
|
1100
1260
|
if @api_client.config.client_side_validation && algolia_object_id.nil?
|
|
1101
1261
|
raise ArgumentError, "Parameter `algolia_object_id` is required when calling `delete_synonym`."
|
|
1102
1262
|
end
|
|
1263
|
+
# verify the required parameter 'algolia_object_id' is not empty
|
|
1264
|
+
if @api_client.config.client_side_validation && algolia_object_id.empty?
|
|
1265
|
+
raise ArgumentError, "Parameter `algolia_object_id` is required when calling `delete_synonym`."
|
|
1266
|
+
end
|
|
1103
1267
|
|
|
1104
1268
|
path = "/1/indexes/{indexName}/synonyms/{objectID}"
|
|
1105
1269
|
.sub("{" + "indexName" + "}", Transport.encode_uri(index_name.to_s))
|
|
@@ -1149,6 +1313,10 @@ module Algolia
|
|
|
1149
1313
|
if @api_client.config.client_side_validation && key.nil?
|
|
1150
1314
|
raise ArgumentError, "Parameter `key` is required when calling `get_api_key`."
|
|
1151
1315
|
end
|
|
1316
|
+
# verify the required parameter 'key' is not empty
|
|
1317
|
+
if @api_client.config.client_side_validation && key.empty?
|
|
1318
|
+
raise ArgumentError, "Parameter `key` is required when calling `get_api_key`."
|
|
1319
|
+
end
|
|
1152
1320
|
|
|
1153
1321
|
path = "/1/keys/{key}".sub("{" + "key" + "}", Transport.encode_uri(key.to_s))
|
|
1154
1322
|
query_params = {}
|
|
@@ -1365,10 +1533,18 @@ module Algolia
|
|
|
1365
1533
|
if @api_client.config.client_side_validation && index_name.nil?
|
|
1366
1534
|
raise ArgumentError, "Parameter `index_name` is required when calling `get_object`."
|
|
1367
1535
|
end
|
|
1536
|
+
# verify the required parameter 'index_name' is not empty
|
|
1537
|
+
if @api_client.config.client_side_validation && index_name.empty?
|
|
1538
|
+
raise ArgumentError, "Parameter `index_name` is required when calling `get_object`."
|
|
1539
|
+
end
|
|
1368
1540
|
# verify the required parameter 'algolia_object_id' is set
|
|
1369
1541
|
if @api_client.config.client_side_validation && algolia_object_id.nil?
|
|
1370
1542
|
raise ArgumentError, "Parameter `algolia_object_id` is required when calling `get_object`."
|
|
1371
1543
|
end
|
|
1544
|
+
# verify the required parameter 'algolia_object_id' is not empty
|
|
1545
|
+
if @api_client.config.client_side_validation && algolia_object_id.empty?
|
|
1546
|
+
raise ArgumentError, "Parameter `algolia_object_id` is required when calling `get_object`."
|
|
1547
|
+
end
|
|
1372
1548
|
|
|
1373
1549
|
path = "/1/indexes/{indexName}/{objectID}".sub("{" + "indexName" + "}", Transport.encode_uri(index_name.to_s)).sub(
|
|
1374
1550
|
"{" + "objectID" + "}",
|
|
@@ -1467,10 +1643,18 @@ module Algolia
|
|
|
1467
1643
|
if @api_client.config.client_side_validation && index_name.nil?
|
|
1468
1644
|
raise ArgumentError, "Parameter `index_name` is required when calling `get_rule`."
|
|
1469
1645
|
end
|
|
1646
|
+
# verify the required parameter 'index_name' is not empty
|
|
1647
|
+
if @api_client.config.client_side_validation && index_name.empty?
|
|
1648
|
+
raise ArgumentError, "Parameter `index_name` is required when calling `get_rule`."
|
|
1649
|
+
end
|
|
1470
1650
|
# verify the required parameter 'algolia_object_id' is set
|
|
1471
1651
|
if @api_client.config.client_side_validation && algolia_object_id.nil?
|
|
1472
1652
|
raise ArgumentError, "Parameter `algolia_object_id` is required when calling `get_rule`."
|
|
1473
1653
|
end
|
|
1654
|
+
# verify the required parameter 'algolia_object_id' is not empty
|
|
1655
|
+
if @api_client.config.client_side_validation && algolia_object_id.empty?
|
|
1656
|
+
raise ArgumentError, "Parameter `algolia_object_id` is required when calling `get_rule`."
|
|
1657
|
+
end
|
|
1474
1658
|
|
|
1475
1659
|
path = "/1/indexes/{indexName}/rules/{objectID}"
|
|
1476
1660
|
.sub("{" + "indexName" + "}", Transport.encode_uri(index_name.to_s))
|
|
@@ -1519,6 +1703,10 @@ module Algolia
|
|
|
1519
1703
|
if @api_client.config.client_side_validation && index_name.nil?
|
|
1520
1704
|
raise ArgumentError, "Parameter `index_name` is required when calling `get_settings`."
|
|
1521
1705
|
end
|
|
1706
|
+
# verify the required parameter 'index_name' is not empty
|
|
1707
|
+
if @api_client.config.client_side_validation && index_name.empty?
|
|
1708
|
+
raise ArgumentError, "Parameter `index_name` is required when calling `get_settings`."
|
|
1709
|
+
end
|
|
1522
1710
|
|
|
1523
1711
|
path = "/1/indexes/{indexName}/settings".sub("{" + "indexName" + "}", Transport.encode_uri(index_name.to_s))
|
|
1524
1712
|
query_params = {}
|
|
@@ -1603,10 +1791,18 @@ module Algolia
|
|
|
1603
1791
|
if @api_client.config.client_side_validation && index_name.nil?
|
|
1604
1792
|
raise ArgumentError, "Parameter `index_name` is required when calling `get_synonym`."
|
|
1605
1793
|
end
|
|
1794
|
+
# verify the required parameter 'index_name' is not empty
|
|
1795
|
+
if @api_client.config.client_side_validation && index_name.empty?
|
|
1796
|
+
raise ArgumentError, "Parameter `index_name` is required when calling `get_synonym`."
|
|
1797
|
+
end
|
|
1606
1798
|
# verify the required parameter 'algolia_object_id' is set
|
|
1607
1799
|
if @api_client.config.client_side_validation && algolia_object_id.nil?
|
|
1608
1800
|
raise ArgumentError, "Parameter `algolia_object_id` is required when calling `get_synonym`."
|
|
1609
1801
|
end
|
|
1802
|
+
# verify the required parameter 'algolia_object_id' is not empty
|
|
1803
|
+
if @api_client.config.client_side_validation && algolia_object_id.empty?
|
|
1804
|
+
raise ArgumentError, "Parameter `algolia_object_id` is required when calling `get_synonym`."
|
|
1805
|
+
end
|
|
1610
1806
|
|
|
1611
1807
|
path = "/1/indexes/{indexName}/synonyms/{objectID}"
|
|
1612
1808
|
.sub("{" + "indexName" + "}", Transport.encode_uri(index_name.to_s))
|
|
@@ -1655,6 +1851,10 @@ module Algolia
|
|
|
1655
1851
|
if @api_client.config.client_side_validation && index_name.nil?
|
|
1656
1852
|
raise ArgumentError, "Parameter `index_name` is required when calling `get_task`."
|
|
1657
1853
|
end
|
|
1854
|
+
# verify the required parameter 'index_name' is not empty
|
|
1855
|
+
if @api_client.config.client_side_validation && index_name.empty?
|
|
1856
|
+
raise ArgumentError, "Parameter `index_name` is required when calling `get_task`."
|
|
1857
|
+
end
|
|
1658
1858
|
# verify the required parameter 'task_id' is set
|
|
1659
1859
|
if @api_client.config.client_side_validation && task_id.nil?
|
|
1660
1860
|
raise ArgumentError, "Parameter `task_id` is required when calling `get_task`."
|
|
@@ -1745,6 +1945,10 @@ module Algolia
|
|
|
1745
1945
|
if @api_client.config.client_side_validation && user_id.nil?
|
|
1746
1946
|
raise ArgumentError, "Parameter `user_id` is required when calling `get_user_id`."
|
|
1747
1947
|
end
|
|
1948
|
+
# verify the required parameter 'user_id' is not empty
|
|
1949
|
+
if @api_client.config.client_side_validation && user_id.empty?
|
|
1950
|
+
raise ArgumentError, "Parameter `user_id` is required when calling `get_user_id`."
|
|
1951
|
+
end
|
|
1748
1952
|
|
|
1749
1953
|
path = "/1/clusters/mapping/{userID}".sub("{" + "userID" + "}", Transport.encode_uri(user_id.to_s))
|
|
1750
1954
|
query_params = {}
|
|
@@ -2040,6 +2244,10 @@ module Algolia
|
|
|
2040
2244
|
if @api_client.config.client_side_validation && index_name.nil?
|
|
2041
2245
|
raise ArgumentError, "Parameter `index_name` is required when calling `operation_index`."
|
|
2042
2246
|
end
|
|
2247
|
+
# verify the required parameter 'index_name' is not empty
|
|
2248
|
+
if @api_client.config.client_side_validation && index_name.empty?
|
|
2249
|
+
raise ArgumentError, "Parameter `index_name` is required when calling `operation_index`."
|
|
2250
|
+
end
|
|
2043
2251
|
# verify the required parameter 'operation_index_params' is set
|
|
2044
2252
|
if @api_client.config.client_side_validation && operation_index_params.nil?
|
|
2045
2253
|
raise ArgumentError, "Parameter `operation_index_params` is required when calling `operation_index`."
|
|
@@ -2098,10 +2306,18 @@ module Algolia
|
|
|
2098
2306
|
if @api_client.config.client_side_validation && index_name.nil?
|
|
2099
2307
|
raise ArgumentError, "Parameter `index_name` is required when calling `partial_update_object`."
|
|
2100
2308
|
end
|
|
2309
|
+
# verify the required parameter 'index_name' is not empty
|
|
2310
|
+
if @api_client.config.client_side_validation && index_name.empty?
|
|
2311
|
+
raise ArgumentError, "Parameter `index_name` is required when calling `partial_update_object`."
|
|
2312
|
+
end
|
|
2101
2313
|
# verify the required parameter 'algolia_object_id' is set
|
|
2102
2314
|
if @api_client.config.client_side_validation && algolia_object_id.nil?
|
|
2103
2315
|
raise ArgumentError, "Parameter `algolia_object_id` is required when calling `partial_update_object`."
|
|
2104
2316
|
end
|
|
2317
|
+
# verify the required parameter 'algolia_object_id' is not empty
|
|
2318
|
+
if @api_client.config.client_side_validation && algolia_object_id.empty?
|
|
2319
|
+
raise ArgumentError, "Parameter `algolia_object_id` is required when calling `partial_update_object`."
|
|
2320
|
+
end
|
|
2105
2321
|
# verify the required parameter 'attributes_to_update' is set
|
|
2106
2322
|
if @api_client.config.client_side_validation && attributes_to_update.nil?
|
|
2107
2323
|
raise ArgumentError, "Parameter `attributes_to_update` is required when calling `partial_update_object`."
|
|
@@ -2172,6 +2388,10 @@ module Algolia
|
|
|
2172
2388
|
if @api_client.config.client_side_validation && user_id.nil?
|
|
2173
2389
|
raise ArgumentError, "Parameter `user_id` is required when calling `remove_user_id`."
|
|
2174
2390
|
end
|
|
2391
|
+
# verify the required parameter 'user_id' is not empty
|
|
2392
|
+
if @api_client.config.client_side_validation && user_id.empty?
|
|
2393
|
+
raise ArgumentError, "Parameter `user_id` is required when calling `remove_user_id`."
|
|
2394
|
+
end
|
|
2175
2395
|
|
|
2176
2396
|
path = "/1/clusters/mapping/{userID}".sub("{" + "userID" + "}", Transport.encode_uri(user_id.to_s))
|
|
2177
2397
|
query_params = {}
|
|
@@ -2260,6 +2480,10 @@ module Algolia
|
|
|
2260
2480
|
if @api_client.config.client_side_validation && key.nil?
|
|
2261
2481
|
raise ArgumentError, "Parameter `key` is required when calling `restore_api_key`."
|
|
2262
2482
|
end
|
|
2483
|
+
# verify the required parameter 'key' is not empty
|
|
2484
|
+
if @api_client.config.client_side_validation && key.empty?
|
|
2485
|
+
raise ArgumentError, "Parameter `key` is required when calling `restore_api_key`."
|
|
2486
|
+
end
|
|
2263
2487
|
|
|
2264
2488
|
path = "/1/keys/{key}/restore".sub("{" + "key" + "}", Transport.encode_uri(key.to_s))
|
|
2265
2489
|
query_params = {}
|
|
@@ -2305,6 +2529,10 @@ module Algolia
|
|
|
2305
2529
|
if @api_client.config.client_side_validation && index_name.nil?
|
|
2306
2530
|
raise ArgumentError, "Parameter `index_name` is required when calling `save_object`."
|
|
2307
2531
|
end
|
|
2532
|
+
# verify the required parameter 'index_name' is not empty
|
|
2533
|
+
if @api_client.config.client_side_validation && index_name.empty?
|
|
2534
|
+
raise ArgumentError, "Parameter `index_name` is required when calling `save_object`."
|
|
2535
|
+
end
|
|
2308
2536
|
# verify the required parameter 'body' is set
|
|
2309
2537
|
if @api_client.config.client_side_validation && body.nil?
|
|
2310
2538
|
raise ArgumentError, "Parameter `body` is required when calling `save_object`."
|
|
@@ -2357,10 +2585,18 @@ module Algolia
|
|
|
2357
2585
|
if @api_client.config.client_side_validation && index_name.nil?
|
|
2358
2586
|
raise ArgumentError, "Parameter `index_name` is required when calling `save_rule`."
|
|
2359
2587
|
end
|
|
2588
|
+
# verify the required parameter 'index_name' is not empty
|
|
2589
|
+
if @api_client.config.client_side_validation && index_name.empty?
|
|
2590
|
+
raise ArgumentError, "Parameter `index_name` is required when calling `save_rule`."
|
|
2591
|
+
end
|
|
2360
2592
|
# verify the required parameter 'algolia_object_id' is set
|
|
2361
2593
|
if @api_client.config.client_side_validation && algolia_object_id.nil?
|
|
2362
2594
|
raise ArgumentError, "Parameter `algolia_object_id` is required when calling `save_rule`."
|
|
2363
2595
|
end
|
|
2596
|
+
# verify the required parameter 'algolia_object_id' is not empty
|
|
2597
|
+
if @api_client.config.client_side_validation && algolia_object_id.empty?
|
|
2598
|
+
raise ArgumentError, "Parameter `algolia_object_id` is required when calling `save_rule`."
|
|
2599
|
+
end
|
|
2364
2600
|
# verify the required parameter 'rule' is set
|
|
2365
2601
|
if @api_client.config.client_side_validation && rule.nil?
|
|
2366
2602
|
raise ArgumentError, "Parameter `rule` is required when calling `save_rule`."
|
|
@@ -2424,6 +2660,10 @@ module Algolia
|
|
|
2424
2660
|
if @api_client.config.client_side_validation && index_name.nil?
|
|
2425
2661
|
raise ArgumentError, "Parameter `index_name` is required when calling `save_rules`."
|
|
2426
2662
|
end
|
|
2663
|
+
# verify the required parameter 'index_name' is not empty
|
|
2664
|
+
if @api_client.config.client_side_validation && index_name.empty?
|
|
2665
|
+
raise ArgumentError, "Parameter `index_name` is required when calling `save_rules`."
|
|
2666
|
+
end
|
|
2427
2667
|
# verify the required parameter 'rules' is set
|
|
2428
2668
|
if @api_client.config.client_side_validation && rules.nil?
|
|
2429
2669
|
raise ArgumentError, "Parameter `rules` is required when calling `save_rules`."
|
|
@@ -2492,10 +2732,18 @@ module Algolia
|
|
|
2492
2732
|
if @api_client.config.client_side_validation && index_name.nil?
|
|
2493
2733
|
raise ArgumentError, "Parameter `index_name` is required when calling `save_synonym`."
|
|
2494
2734
|
end
|
|
2735
|
+
# verify the required parameter 'index_name' is not empty
|
|
2736
|
+
if @api_client.config.client_side_validation && index_name.empty?
|
|
2737
|
+
raise ArgumentError, "Parameter `index_name` is required when calling `save_synonym`."
|
|
2738
|
+
end
|
|
2495
2739
|
# verify the required parameter 'algolia_object_id' is set
|
|
2496
2740
|
if @api_client.config.client_side_validation && algolia_object_id.nil?
|
|
2497
2741
|
raise ArgumentError, "Parameter `algolia_object_id` is required when calling `save_synonym`."
|
|
2498
2742
|
end
|
|
2743
|
+
# verify the required parameter 'algolia_object_id' is not empty
|
|
2744
|
+
if @api_client.config.client_side_validation && algolia_object_id.empty?
|
|
2745
|
+
raise ArgumentError, "Parameter `algolia_object_id` is required when calling `save_synonym`."
|
|
2746
|
+
end
|
|
2499
2747
|
# verify the required parameter 'synonym_hit' is set
|
|
2500
2748
|
if @api_client.config.client_side_validation && synonym_hit.nil?
|
|
2501
2749
|
raise ArgumentError, "Parameter `synonym_hit` is required when calling `save_synonym`."
|
|
@@ -2565,6 +2813,10 @@ module Algolia
|
|
|
2565
2813
|
if @api_client.config.client_side_validation && index_name.nil?
|
|
2566
2814
|
raise ArgumentError, "Parameter `index_name` is required when calling `save_synonyms`."
|
|
2567
2815
|
end
|
|
2816
|
+
# verify the required parameter 'index_name' is not empty
|
|
2817
|
+
if @api_client.config.client_side_validation && index_name.empty?
|
|
2818
|
+
raise ArgumentError, "Parameter `index_name` is required when calling `save_synonyms`."
|
|
2819
|
+
end
|
|
2568
2820
|
# verify the required parameter 'synonym_hit' is set
|
|
2569
2821
|
if @api_client.config.client_side_validation && synonym_hit.nil?
|
|
2570
2822
|
raise ArgumentError, "Parameter `synonym_hit` is required when calling `save_synonyms`."
|
|
@@ -2748,10 +3000,18 @@ module Algolia
|
|
|
2748
3000
|
if @api_client.config.client_side_validation && index_name.nil?
|
|
2749
3001
|
raise ArgumentError, "Parameter `index_name` is required when calling `search_for_facet_values`."
|
|
2750
3002
|
end
|
|
3003
|
+
# verify the required parameter 'index_name' is not empty
|
|
3004
|
+
if @api_client.config.client_side_validation && index_name.empty?
|
|
3005
|
+
raise ArgumentError, "Parameter `index_name` is required when calling `search_for_facet_values`."
|
|
3006
|
+
end
|
|
2751
3007
|
# verify the required parameter 'facet_name' is set
|
|
2752
3008
|
if @api_client.config.client_side_validation && facet_name.nil?
|
|
2753
3009
|
raise ArgumentError, "Parameter `facet_name` is required when calling `search_for_facet_values`."
|
|
2754
3010
|
end
|
|
3011
|
+
# verify the required parameter 'facet_name' is not empty
|
|
3012
|
+
if @api_client.config.client_side_validation && facet_name.empty?
|
|
3013
|
+
raise ArgumentError, "Parameter `facet_name` is required when calling `search_for_facet_values`."
|
|
3014
|
+
end
|
|
2755
3015
|
|
|
2756
3016
|
path = "/1/indexes/{indexName}/facets/{facetName}/query"
|
|
2757
3017
|
.sub("{" + "indexName" + "}", Transport.encode_uri(index_name.to_s))
|
|
@@ -2809,6 +3069,10 @@ module Algolia
|
|
|
2809
3069
|
if @api_client.config.client_side_validation && index_name.nil?
|
|
2810
3070
|
raise ArgumentError, "Parameter `index_name` is required when calling `search_rules`."
|
|
2811
3071
|
end
|
|
3072
|
+
# verify the required parameter 'index_name' is not empty
|
|
3073
|
+
if @api_client.config.client_side_validation && index_name.empty?
|
|
3074
|
+
raise ArgumentError, "Parameter `index_name` is required when calling `search_rules`."
|
|
3075
|
+
end
|
|
2812
3076
|
|
|
2813
3077
|
path = "/1/indexes/{indexName}/rules/search".sub("{" + "indexName" + "}", Transport.encode_uri(index_name.to_s))
|
|
2814
3078
|
query_params = {}
|
|
@@ -2855,6 +3119,10 @@ module Algolia
|
|
|
2855
3119
|
if @api_client.config.client_side_validation && index_name.nil?
|
|
2856
3120
|
raise ArgumentError, "Parameter `index_name` is required when calling `search_single_index`."
|
|
2857
3121
|
end
|
|
3122
|
+
# verify the required parameter 'index_name' is not empty
|
|
3123
|
+
if @api_client.config.client_side_validation && index_name.empty?
|
|
3124
|
+
raise ArgumentError, "Parameter `index_name` is required when calling `search_single_index`."
|
|
3125
|
+
end
|
|
2858
3126
|
|
|
2859
3127
|
path = "/1/indexes/{indexName}/query".sub("{" + "indexName" + "}", Transport.encode_uri(index_name.to_s))
|
|
2860
3128
|
query_params = {}
|
|
@@ -2901,6 +3169,10 @@ module Algolia
|
|
|
2901
3169
|
if @api_client.config.client_side_validation && index_name.nil?
|
|
2902
3170
|
raise ArgumentError, "Parameter `index_name` is required when calling `search_synonyms`."
|
|
2903
3171
|
end
|
|
3172
|
+
# verify the required parameter 'index_name' is not empty
|
|
3173
|
+
if @api_client.config.client_side_validation && index_name.empty?
|
|
3174
|
+
raise ArgumentError, "Parameter `index_name` is required when calling `search_synonyms`."
|
|
3175
|
+
end
|
|
2904
3176
|
|
|
2905
3177
|
path = "/1/indexes/{indexName}/synonyms/search".sub(
|
|
2906
3178
|
"{" + "indexName" + "}",
|
|
@@ -3043,6 +3315,10 @@ module Algolia
|
|
|
3043
3315
|
if @api_client.config.client_side_validation && index_name.nil?
|
|
3044
3316
|
raise ArgumentError, "Parameter `index_name` is required when calling `set_settings`."
|
|
3045
3317
|
end
|
|
3318
|
+
# verify the required parameter 'index_name' is not empty
|
|
3319
|
+
if @api_client.config.client_side_validation && index_name.empty?
|
|
3320
|
+
raise ArgumentError, "Parameter `index_name` is required when calling `set_settings`."
|
|
3321
|
+
end
|
|
3046
3322
|
# verify the required parameter 'index_settings' is set
|
|
3047
3323
|
if @api_client.config.client_side_validation && index_settings.nil?
|
|
3048
3324
|
raise ArgumentError, "Parameter `index_settings` is required when calling `set_settings`."
|
|
@@ -3095,6 +3371,10 @@ module Algolia
|
|
|
3095
3371
|
if @api_client.config.client_side_validation && key.nil?
|
|
3096
3372
|
raise ArgumentError, "Parameter `key` is required when calling `update_api_key`."
|
|
3097
3373
|
end
|
|
3374
|
+
# verify the required parameter 'key' is not empty
|
|
3375
|
+
if @api_client.config.client_side_validation && key.empty?
|
|
3376
|
+
raise ArgumentError, "Parameter `key` is required when calling `update_api_key`."
|
|
3377
|
+
end
|
|
3098
3378
|
# verify the required parameter 'api_key' is set
|
|
3099
3379
|
if @api_client.config.client_side_validation && api_key.nil?
|
|
3100
3380
|
raise ArgumentError, "Parameter `api_key` is required when calling `update_api_key`."
|
|
@@ -3132,18 +3412,231 @@ module Algolia
|
|
|
3132
3412
|
@api_client.deserialize(response.body, request_options[:debug_return_type] || "Search::UpdateApiKeyResponse")
|
|
3133
3413
|
end
|
|
3134
3414
|
|
|
3415
|
+
# The parent search config MUST NOT leak into the ingestion transporter.
|
|
3416
|
+
def _build_ingestion_transporter(transformation_options)
|
|
3417
|
+
hosts = if transformation_options.hosts
|
|
3418
|
+
transformation_options.hosts
|
|
3419
|
+
else
|
|
3420
|
+
[
|
|
3421
|
+
Transport::StatefulHost.new(
|
|
3422
|
+
"data.#{transformation_options.region}.algolia.com",
|
|
3423
|
+
accept: CallType::READ | CallType::WRITE
|
|
3424
|
+
)
|
|
3425
|
+
]
|
|
3426
|
+
end
|
|
3427
|
+
|
|
3428
|
+
opts = {}
|
|
3429
|
+
unless transformation_options.connect_timeout.nil?
|
|
3430
|
+
opts[:connect_timeout] = transformation_options.connect_timeout
|
|
3431
|
+
end
|
|
3432
|
+
|
|
3433
|
+
opts[:read_timeout] = transformation_options.read_timeout unless transformation_options.read_timeout.nil?
|
|
3434
|
+
opts[:write_timeout] = transformation_options.write_timeout unless transformation_options.write_timeout.nil?
|
|
3435
|
+
unless transformation_options.compression_type.nil?
|
|
3436
|
+
opts[:compression_type] = transformation_options.compression_type
|
|
3437
|
+
end
|
|
3438
|
+
|
|
3439
|
+
config = Algolia::Configuration.new(
|
|
3440
|
+
@api_client.config.app_id,
|
|
3441
|
+
@api_client.config.api_key,
|
|
3442
|
+
hosts,
|
|
3443
|
+
"Ingestion",
|
|
3444
|
+
opts
|
|
3445
|
+
)
|
|
3446
|
+
|
|
3447
|
+
if transformation_options.header_params
|
|
3448
|
+
config.header_params = config.header_params.merge(transformation_options.header_params)
|
|
3449
|
+
end
|
|
3450
|
+
|
|
3451
|
+
Algolia::IngestionClient.create_with_config(config)
|
|
3452
|
+
end
|
|
3453
|
+
|
|
3454
|
+
# Helper: Sets (or replaces) the ingestion transporter used by *_with_transformation helpers.
|
|
3455
|
+
#
|
|
3456
|
+
# @param transformation_options [TransformationOptions] the transformation options including region and optional ingestion transporter overrides. (required)
|
|
3457
|
+
def set_transformation_options(transformation_options)
|
|
3458
|
+
raise ArgumentError, "`transformation_options` must not be nil" if transformation_options.nil?
|
|
3459
|
+
@ingestion_transporter = _build_ingestion_transporter(transformation_options)
|
|
3460
|
+
end
|
|
3461
|
+
|
|
3462
|
+
def assert_ingestion_transporter!
|
|
3463
|
+
if @ingestion_transporter.nil?
|
|
3464
|
+
raise(
|
|
3465
|
+
ArgumentError,
|
|
3466
|
+
"`transformation_options` must be set in the client config before calling this method. It defaults to the Ingestion API defaults. See https://www.algolia.com/doc/libraries/ruby/v3/methods/ingestion/"
|
|
3467
|
+
)
|
|
3468
|
+
end
|
|
3469
|
+
end
|
|
3470
|
+
|
|
3471
|
+
# Helper: Similar to the `save_objects` method but requires a Push connector to be created first,
|
|
3472
|
+
# in order to transform records before indexing them to Algolia.
|
|
3473
|
+
# `set_transformation_options` must have been called, or the client created via `SearchClient.with_transformation`.
|
|
3474
|
+
#
|
|
3475
|
+
# @param index_name [String] the `index_name` where the operation will be performed. (required)
|
|
3476
|
+
# @param objects [Array] the array of objects to store in the given Algolia `index_name`. (required)
|
|
3477
|
+
# @param wait_for_tasks [Boolean] whether to wait until every task has been processed. (optional, default: false)
|
|
3478
|
+
# @param batch_size [Integer] the size of each chunk of objects sent in a single push call. (optional, default: 1000)
|
|
3479
|
+
# @param request_options [Hash] the request options to send along with the query. (optional)
|
|
3480
|
+
#
|
|
3481
|
+
# @return [Array<Ingestion::WatchResponse>]
|
|
3482
|
+
def save_objects_with_transformation(
|
|
3483
|
+
index_name,
|
|
3484
|
+
objects,
|
|
3485
|
+
wait_for_tasks = false,
|
|
3486
|
+
batch_size = 1000,
|
|
3487
|
+
request_options = {},
|
|
3488
|
+
chunked_options = nil
|
|
3489
|
+
)
|
|
3490
|
+
assert_ingestion_transporter!
|
|
3491
|
+
|
|
3492
|
+
@ingestion_transporter.chunked_push(
|
|
3493
|
+
index_name,
|
|
3494
|
+
objects,
|
|
3495
|
+
Ingestion::Action::ADD_OBJECT,
|
|
3496
|
+
wait_for_tasks,
|
|
3497
|
+
batch_size,
|
|
3498
|
+
nil,
|
|
3499
|
+
request_options,
|
|
3500
|
+
chunked_options
|
|
3501
|
+
)
|
|
3502
|
+
end
|
|
3503
|
+
|
|
3504
|
+
# Helper: Similar to the `partial_update_objects` method but requires a Push connector to be created first,
|
|
3505
|
+
# in order to transform records before indexing them to Algolia.
|
|
3506
|
+
# `set_transformation_options` must have been called, or the client created via `SearchClient.with_transformation`.
|
|
3507
|
+
#
|
|
3508
|
+
# @param index_name [String] the `index_name` where the operation will be performed. (required)
|
|
3509
|
+
# @param objects [Array] the array of objects to update in the given Algolia `index_name`. (required)
|
|
3510
|
+
# @param create_if_not_exists [Boolean] whether to create objects that do not exist. (optional, default: false)
|
|
3511
|
+
# @param wait_for_tasks [Boolean] whether to wait until every task has been processed. (optional, default: false)
|
|
3512
|
+
# @param batch_size [Integer] the size of each chunk of objects sent in a single push call. (optional, default: 1000)
|
|
3513
|
+
# @param request_options [Hash] the request options to send along with the query. (optional)
|
|
3514
|
+
#
|
|
3515
|
+
# @return [Array<Ingestion::WatchResponse>]
|
|
3516
|
+
def partial_update_objects_with_transformation(
|
|
3517
|
+
index_name,
|
|
3518
|
+
objects,
|
|
3519
|
+
create_if_not_exists = false,
|
|
3520
|
+
wait_for_tasks = false,
|
|
3521
|
+
batch_size = 1000,
|
|
3522
|
+
request_options = {},
|
|
3523
|
+
chunked_options = nil
|
|
3524
|
+
)
|
|
3525
|
+
assert_ingestion_transporter!
|
|
3526
|
+
|
|
3527
|
+
action = create_if_not_exists ? Ingestion::Action::PARTIAL_UPDATE_OBJECT : Ingestion::Action::PARTIAL_UPDATE_OBJECT_NO_CREATE
|
|
3528
|
+
|
|
3529
|
+
@ingestion_transporter.chunked_push(
|
|
3530
|
+
index_name,
|
|
3531
|
+
objects,
|
|
3532
|
+
action,
|
|
3533
|
+
wait_for_tasks,
|
|
3534
|
+
batch_size,
|
|
3535
|
+
nil,
|
|
3536
|
+
request_options,
|
|
3537
|
+
chunked_options
|
|
3538
|
+
)
|
|
3539
|
+
end
|
|
3540
|
+
|
|
3541
|
+
# Helper: Similar to the `replace_all_objects` method but requires a Push connector to be created first,
|
|
3542
|
+
# in order to transform records before indexing them to Algolia.
|
|
3543
|
+
# `set_transformation_options` must have been called, or the client created via `SearchClient.with_transformation`.
|
|
3544
|
+
#
|
|
3545
|
+
# @param index_name [String] the `index_name` to replace objects in. (required)
|
|
3546
|
+
# @param objects [Array] the array of objects to store in the given Algolia `index_name`. (required)
|
|
3547
|
+
# @param batch_size [Integer] the size of each chunk of objects sent in a single push call. (optional, default: 1000)
|
|
3548
|
+
# @param scopes [Array] the scopes to keep from the index. (optional, default: settings, rules, synonyms)
|
|
3549
|
+
# @param request_options [Hash] the request options to send along with the query. (optional)
|
|
3550
|
+
#
|
|
3551
|
+
# @return [Search::ReplaceAllObjectsWithTransformationResponse]
|
|
3552
|
+
def replace_all_objects_with_transformation(
|
|
3553
|
+
index_name,
|
|
3554
|
+
objects,
|
|
3555
|
+
batch_size = 1000,
|
|
3556
|
+
scopes = [Search::ScopeType::SETTINGS, Search::ScopeType::RULES, Search::ScopeType::SYNONYMS],
|
|
3557
|
+
request_options = {},
|
|
3558
|
+
chunked_options = nil
|
|
3559
|
+
)
|
|
3560
|
+
assert_ingestion_transporter!
|
|
3561
|
+
|
|
3562
|
+
opts = Algolia::ChunkedHelperOptions.resolve(chunked_options)
|
|
3563
|
+
tmp_index_name = index_name + "_tmp_" + rand(10_000_000).to_s
|
|
3564
|
+
|
|
3565
|
+
begin
|
|
3566
|
+
copy_operation_response = operation_index(
|
|
3567
|
+
index_name,
|
|
3568
|
+
Search::OperationIndexParams.new(
|
|
3569
|
+
operation: Search::OperationType::COPY,
|
|
3570
|
+
destination: tmp_index_name,
|
|
3571
|
+
scope: scopes
|
|
3572
|
+
),
|
|
3573
|
+
request_options
|
|
3574
|
+
)
|
|
3575
|
+
|
|
3576
|
+
watch_responses = @ingestion_transporter.chunked_push(
|
|
3577
|
+
tmp_index_name,
|
|
3578
|
+
objects,
|
|
3579
|
+
Ingestion::Action::ADD_OBJECT,
|
|
3580
|
+
true,
|
|
3581
|
+
batch_size,
|
|
3582
|
+
index_name,
|
|
3583
|
+
request_options,
|
|
3584
|
+
opts
|
|
3585
|
+
)
|
|
3586
|
+
|
|
3587
|
+
wait_for_task(tmp_index_name, copy_operation_response.task_id, opts.max_retries)
|
|
3588
|
+
|
|
3589
|
+
copy_operation_response = operation_index(
|
|
3590
|
+
index_name,
|
|
3591
|
+
Search::OperationIndexParams.new(
|
|
3592
|
+
operation: Search::OperationType::COPY,
|
|
3593
|
+
destination: tmp_index_name,
|
|
3594
|
+
scope: scopes
|
|
3595
|
+
),
|
|
3596
|
+
request_options
|
|
3597
|
+
)
|
|
3598
|
+
|
|
3599
|
+
wait_for_task(tmp_index_name, copy_operation_response.task_id, opts.max_retries)
|
|
3600
|
+
|
|
3601
|
+
move_operation_response = operation_index(
|
|
3602
|
+
tmp_index_name,
|
|
3603
|
+
Search::OperationIndexParams.new(
|
|
3604
|
+
operation: Search::OperationType::MOVE,
|
|
3605
|
+
destination: index_name
|
|
3606
|
+
),
|
|
3607
|
+
request_options
|
|
3608
|
+
)
|
|
3609
|
+
|
|
3610
|
+
wait_for_task(tmp_index_name, move_operation_response.task_id, opts.max_retries)
|
|
3611
|
+
|
|
3612
|
+
search_watch_responses = watch_responses.map do |wr|
|
|
3613
|
+
Search::WatchResponse.build_from_hash(wr.to_hash)
|
|
3614
|
+
end
|
|
3615
|
+
|
|
3616
|
+
Search::ReplaceAllObjectsWithTransformationResponse.new(
|
|
3617
|
+
copy_operation_response: copy_operation_response,
|
|
3618
|
+
watch_responses: search_watch_responses,
|
|
3619
|
+
move_operation_response: move_operation_response
|
|
3620
|
+
)
|
|
3621
|
+
rescue Exception => e
|
|
3622
|
+
delete_index(tmp_index_name)
|
|
3623
|
+
|
|
3624
|
+
raise e
|
|
3625
|
+
end
|
|
3626
|
+
end
|
|
3627
|
+
|
|
3135
3628
|
# Helper: Wait for a task to be published (completed) for a given `index_name` and `task_id`.
|
|
3136
3629
|
#
|
|
3137
3630
|
# @param index_name [String] the `index_name` where the operation was performed. (required)
|
|
3138
3631
|
# @param task_id [Integer] the `task_id` returned in the method response. (required)
|
|
3139
|
-
# @param max_retries [Integer] the maximum number of retries. (optional, default to
|
|
3632
|
+
# @param max_retries [Integer] the maximum number of retries. (optional, default to Algolia::ChunkedHelperOptions::DEFAULT_MAX_RETRIES)
|
|
3140
3633
|
# @param timeout [Proc] the function to decide how long to wait between retries. (optional)
|
|
3141
3634
|
# @param request_options [Hash] the requestOptions to send along with the query, they will be forwarded to the `get_task` method.
|
|
3142
3635
|
# @return [Http::Response] the last get_task response
|
|
3143
3636
|
def wait_for_task(
|
|
3144
3637
|
index_name,
|
|
3145
3638
|
task_id,
|
|
3146
|
-
max_retries =
|
|
3639
|
+
max_retries = Algolia::ChunkedHelperOptions::DEFAULT_MAX_RETRIES,
|
|
3147
3640
|
timeout = -> (retry_count) { [retry_count * 200, 5000].min },
|
|
3148
3641
|
request_options = {}
|
|
3149
3642
|
)
|
|
@@ -3158,19 +3651,22 @@ module Algolia
|
|
|
3158
3651
|
sleep(timeout.call(retries) / 1000.0)
|
|
3159
3652
|
end
|
|
3160
3653
|
|
|
3161
|
-
raise
|
|
3654
|
+
raise(
|
|
3655
|
+
ApiError,
|
|
3656
|
+
"Stopped waiting for the task after #{max_retries} retries. This does not mean the operation failed; it may still complete. If you need to keep polling, retry with a higher max_retries."
|
|
3657
|
+
)
|
|
3162
3658
|
end
|
|
3163
3659
|
|
|
3164
3660
|
# Helper: Wait for an application-level task to be published (completed) for a given `task_id`.
|
|
3165
3661
|
#
|
|
3166
3662
|
# @param task_id [Integer] the `task_id` returned in the method response. (required)
|
|
3167
|
-
# @param max_retries [Integer] the maximum number of retries. (optional, default to
|
|
3663
|
+
# @param max_retries [Integer] the maximum number of retries. (optional, default to Algolia::ChunkedHelperOptions::DEFAULT_MAX_RETRIES)
|
|
3168
3664
|
# @param timeout [Proc] the function to decide how long to wait between retries. (optional)
|
|
3169
3665
|
# @param request_options [Hash] the requestOptions to send along with the query, they will be forwarded to the `get_task` method.
|
|
3170
3666
|
# @return [Http::Response] the last get_task response
|
|
3171
3667
|
def wait_for_app_task(
|
|
3172
3668
|
task_id,
|
|
3173
|
-
max_retries =
|
|
3669
|
+
max_retries = Algolia::ChunkedHelperOptions::DEFAULT_MAX_RETRIES,
|
|
3174
3670
|
timeout = -> (retry_count) { [retry_count * 200, 5000].min },
|
|
3175
3671
|
request_options = {}
|
|
3176
3672
|
)
|
|
@@ -3185,7 +3681,10 @@ module Algolia
|
|
|
3185
3681
|
sleep(timeout.call(retries) / 1000.0)
|
|
3186
3682
|
end
|
|
3187
3683
|
|
|
3188
|
-
raise
|
|
3684
|
+
raise(
|
|
3685
|
+
ApiError,
|
|
3686
|
+
"Stopped waiting for the task after #{max_retries} retries. This does not mean the operation failed; it may still complete. If you need to keep polling, retry with a higher max_retries."
|
|
3687
|
+
)
|
|
3189
3688
|
end
|
|
3190
3689
|
|
|
3191
3690
|
# Helper: Wait for an API key to be added, updated or deleted based on a given `operation`.
|
|
@@ -3201,7 +3700,7 @@ module Algolia
|
|
|
3201
3700
|
key,
|
|
3202
3701
|
operation,
|
|
3203
3702
|
api_key = Search::ApiKey.new,
|
|
3204
|
-
max_retries =
|
|
3703
|
+
max_retries = Algolia::ChunkedHelperOptions::DEFAULT_MAX_RETRIES,
|
|
3205
3704
|
timeout = -> (retry_count) { [retry_count * 200, 5000].min },
|
|
3206
3705
|
request_options = {}
|
|
3207
3706
|
)
|
|
@@ -3224,7 +3723,10 @@ module Algolia
|
|
|
3224
3723
|
sleep(timeout.call(retries) / 1000.0)
|
|
3225
3724
|
end
|
|
3226
3725
|
|
|
3227
|
-
raise
|
|
3726
|
+
raise(
|
|
3727
|
+
ApiError,
|
|
3728
|
+
"Stopped waiting for the task after #{max_retries} retries. This does not mean the operation failed; it may still complete. If you need to keep polling, retry with a higher max_retries."
|
|
3729
|
+
)
|
|
3228
3730
|
end
|
|
3229
3731
|
|
|
3230
3732
|
while retries < max_retries
|
|
@@ -3243,7 +3745,10 @@ module Algolia
|
|
|
3243
3745
|
sleep(timeout.call(retries) / 1000.0)
|
|
3244
3746
|
end
|
|
3245
3747
|
|
|
3246
|
-
raise
|
|
3748
|
+
raise(
|
|
3749
|
+
ApiError,
|
|
3750
|
+
"Stopped waiting for the task after #{max_retries} retries. This does not mean the operation failed; it may still complete. If you need to keep polling, retry with a higher max_retries."
|
|
3751
|
+
)
|
|
3247
3752
|
end
|
|
3248
3753
|
|
|
3249
3754
|
# Helper: Iterate on the `browse` method of the client to allow aggregating objects of an index.
|
|
@@ -3421,14 +3926,22 @@ module Algolia
|
|
|
3421
3926
|
#
|
|
3422
3927
|
# @return [BatchResponse]
|
|
3423
3928
|
#
|
|
3424
|
-
def save_objects(
|
|
3929
|
+
def save_objects(
|
|
3930
|
+
index_name,
|
|
3931
|
+
objects,
|
|
3932
|
+
wait_for_tasks = false,
|
|
3933
|
+
batch_size = 1000,
|
|
3934
|
+
request_options = {},
|
|
3935
|
+
chunked_options = nil
|
|
3936
|
+
)
|
|
3425
3937
|
chunked_batch(
|
|
3426
3938
|
index_name,
|
|
3427
3939
|
objects,
|
|
3428
3940
|
Search::Action::ADD_OBJECT,
|
|
3429
3941
|
wait_for_tasks,
|
|
3430
3942
|
batch_size,
|
|
3431
|
-
request_options
|
|
3943
|
+
request_options,
|
|
3944
|
+
chunked_options
|
|
3432
3945
|
)
|
|
3433
3946
|
end
|
|
3434
3947
|
|
|
@@ -3442,14 +3955,22 @@ module Algolia
|
|
|
3442
3955
|
#
|
|
3443
3956
|
# @return [BatchResponse]
|
|
3444
3957
|
#
|
|
3445
|
-
def delete_objects(
|
|
3958
|
+
def delete_objects(
|
|
3959
|
+
index_name,
|
|
3960
|
+
object_ids,
|
|
3961
|
+
wait_for_tasks = false,
|
|
3962
|
+
batch_size = 1000,
|
|
3963
|
+
request_options = {},
|
|
3964
|
+
chunked_options = nil
|
|
3965
|
+
)
|
|
3446
3966
|
chunked_batch(
|
|
3447
3967
|
index_name,
|
|
3448
3968
|
object_ids.map { |id| {"objectID" => id} },
|
|
3449
3969
|
Search::Action::DELETE_OBJECT,
|
|
3450
3970
|
wait_for_tasks,
|
|
3451
3971
|
batch_size,
|
|
3452
|
-
request_options
|
|
3972
|
+
request_options,
|
|
3973
|
+
chunked_options
|
|
3453
3974
|
)
|
|
3454
3975
|
end
|
|
3455
3976
|
|
|
@@ -3470,7 +3991,8 @@ module Algolia
|
|
|
3470
3991
|
create_if_not_exists,
|
|
3471
3992
|
wait_for_tasks = false,
|
|
3472
3993
|
batch_size = 1000,
|
|
3473
|
-
request_options = {}
|
|
3994
|
+
request_options = {},
|
|
3995
|
+
chunked_options = nil
|
|
3474
3996
|
)
|
|
3475
3997
|
chunked_batch(
|
|
3476
3998
|
index_name,
|
|
@@ -3478,7 +4000,8 @@ module Algolia
|
|
|
3478
4000
|
create_if_not_exists ? Search::Action::PARTIAL_UPDATE_OBJECT : Search::Action::PARTIAL_UPDATE_OBJECT_NO_CREATE,
|
|
3479
4001
|
wait_for_tasks,
|
|
3480
4002
|
batch_size,
|
|
3481
|
-
request_options
|
|
4003
|
+
request_options,
|
|
4004
|
+
chunked_options
|
|
3482
4005
|
)
|
|
3483
4006
|
end
|
|
3484
4007
|
|
|
@@ -3499,8 +4022,10 @@ module Algolia
|
|
|
3499
4022
|
action = Action::ADD_OBJECT,
|
|
3500
4023
|
wait_for_tasks = false,
|
|
3501
4024
|
batch_size = 1000,
|
|
3502
|
-
request_options = {}
|
|
4025
|
+
request_options = {},
|
|
4026
|
+
chunked_options = nil
|
|
3503
4027
|
)
|
|
4028
|
+
opts = Algolia::ChunkedHelperOptions.resolve(chunked_options)
|
|
3504
4029
|
responses = []
|
|
3505
4030
|
objects.each_slice(batch_size) do |chunk|
|
|
3506
4031
|
requests = chunk.map do |object|
|
|
@@ -3512,7 +4037,7 @@ module Algolia
|
|
|
3512
4037
|
|
|
3513
4038
|
if wait_for_tasks
|
|
3514
4039
|
responses.each do |response|
|
|
3515
|
-
wait_for_task(index_name, response.task_id)
|
|
4040
|
+
wait_for_task(index_name, response.task_id, opts.max_retries)
|
|
3516
4041
|
end
|
|
3517
4042
|
end
|
|
3518
4043
|
|
|
@@ -3533,8 +4058,10 @@ module Algolia
|
|
|
3533
4058
|
objects,
|
|
3534
4059
|
batch_size = 1000,
|
|
3535
4060
|
scopes = [Search::ScopeType::SETTINGS, Search::ScopeType::RULES, Search::ScopeType::SYNONYMS],
|
|
3536
|
-
request_options = {}
|
|
4061
|
+
request_options = {},
|
|
4062
|
+
chunked_options = nil
|
|
3537
4063
|
)
|
|
4064
|
+
opts = Algolia::ChunkedHelperOptions.resolve(chunked_options)
|
|
3538
4065
|
tmp_index_name = index_name + "_tmp_" + rand(10_000_000).to_s
|
|
3539
4066
|
|
|
3540
4067
|
begin
|
|
@@ -3554,10 +4081,11 @@ module Algolia
|
|
|
3554
4081
|
Search::Action::ADD_OBJECT,
|
|
3555
4082
|
true,
|
|
3556
4083
|
batch_size,
|
|
3557
|
-
request_options
|
|
4084
|
+
request_options,
|
|
4085
|
+
opts
|
|
3558
4086
|
)
|
|
3559
4087
|
|
|
3560
|
-
wait_for_task(tmp_index_name, copy_operation_response.task_id)
|
|
4088
|
+
wait_for_task(tmp_index_name, copy_operation_response.task_id, opts.max_retries)
|
|
3561
4089
|
|
|
3562
4090
|
copy_operation_response = operation_index(
|
|
3563
4091
|
index_name,
|
|
@@ -3569,7 +4097,7 @@ module Algolia
|
|
|
3569
4097
|
request_options
|
|
3570
4098
|
)
|
|
3571
4099
|
|
|
3572
|
-
wait_for_task(tmp_index_name, copy_operation_response.task_id)
|
|
4100
|
+
wait_for_task(tmp_index_name, copy_operation_response.task_id, opts.max_retries)
|
|
3573
4101
|
|
|
3574
4102
|
move_operation_response = operation_index(
|
|
3575
4103
|
tmp_index_name,
|
|
@@ -3580,7 +4108,7 @@ module Algolia
|
|
|
3580
4108
|
request_options
|
|
3581
4109
|
)
|
|
3582
4110
|
|
|
3583
|
-
wait_for_task(tmp_index_name, move_operation_response.task_id)
|
|
4111
|
+
wait_for_task(tmp_index_name, move_operation_response.task_id, opts.max_retries)
|
|
3584
4112
|
|
|
3585
4113
|
Search::ReplaceAllObjectsResponse.new(
|
|
3586
4114
|
copy_operation_response: copy_operation_response,
|