algolia 3.39.1 → 3.41.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.
Files changed (156) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE/Bug_report.yml +1 -0
  3. data/.github/workflows/release.yml +1 -1
  4. data/CHANGELOG.md +19 -0
  5. data/Gemfile.lock +4 -4
  6. data/lib/algolia/api/agent_studio_client.rb +2364 -0
  7. data/lib/algolia/api/ingestion_client.rb +71 -0
  8. data/lib/algolia/api/search_client.rb +342 -22
  9. data/lib/algolia/chunked_helper_options.rb +15 -0
  10. data/lib/algolia/configuration.rb +3 -1
  11. data/lib/algolia/models/abtesting/ab_test.rb +5 -0
  12. data/lib/algolia/models/agent-studio/advanced_syntax_features.rb +34 -0
  13. data/lib/algolia/models/agent-studio/agent_completion_algolia_params.rb +221 -0
  14. data/lib/algolia/models/agent-studio/agent_completion_request.rb +247 -0
  15. data/lib/algolia/models/agent-studio/agent_config_create.rb +288 -0
  16. data/lib/algolia/models/agent-studio/agent_config_update.rb +294 -0
  17. data/lib/algolia/models/agent-studio/agent_status.rb +34 -0
  18. data/lib/algolia/models/agent-studio/agent_test_configuration.rb +271 -0
  19. data/lib/algolia/models/agent-studio/agent_with_version_response.rb +370 -0
  20. data/lib/algolia/models/agent-studio/algolia_display_results_tool_config.rb +254 -0
  21. data/lib/algolia/models/agent-studio/algolia_recommend_tool_config_input.rb +242 -0
  22. data/lib/algolia/models/agent-studio/algolia_recommend_tool_index_config.rb +228 -0
  23. data/lib/algolia/models/agent-studio/algolia_search_tool_config.rb +232 -0
  24. data/lib/algolia/models/agent-studio/algolia_search_tool_index_config.rb +249 -0
  25. data/lib/algolia/models/agent-studio/allowed_domain_bulk_delete.rb +212 -0
  26. data/lib/algolia/models/agent-studio/allowed_domain_bulk_insert.rb +212 -0
  27. data/lib/algolia/models/agent-studio/allowed_domain_create.rb +210 -0
  28. data/lib/algolia/models/agent-studio/allowed_domain_list_response.rb +211 -0
  29. data/lib/algolia/models/agent-studio/allowed_domain_response.rb +264 -0
  30. data/lib/algolia/models/agent-studio/alternatives_as_exact.rb +36 -0
  31. data/lib/algolia/models/agent-studio/anthropic_provider_input.rb +220 -0
  32. data/lib/algolia/models/agent-studio/application_config_patch.rb +209 -0
  33. data/lib/algolia/models/agent-studio/application_config_response.rb +208 -0
  34. data/lib/algolia/models/agent-studio/around_precision_union.rb +108 -0
  35. data/lib/algolia/models/agent-studio/around_radius_union.rb +108 -0
  36. data/lib/algolia/models/agent-studio/assistant_message_v4.rb +252 -0
  37. data/lib/algolia/models/agent-studio/assistant_message_v5.rb +228 -0
  38. data/lib/algolia/models/agent-studio/assistant_part_v4.rb +110 -0
  39. data/lib/algolia/models/agent-studio/assistant_part_v5.rb +110 -0
  40. data/lib/algolia/models/agent-studio/azure_open_ai_provider_input.rb +243 -0
  41. data/lib/algolia/models/agent-studio/base_provider_input.rb +209 -0
  42. data/lib/algolia/models/agent-studio/client_side_tool_config.rb +241 -0
  43. data/lib/algolia/models/agent-studio/client_tools_args_schema.rb +228 -0
  44. data/lib/algolia/models/agent-studio/compatibility_mode.rb +34 -0
  45. data/lib/algolia/models/agent-studio/conversation_base_response.rb +355 -0
  46. data/lib/algolia/models/agent-studio/conversation_full_response.rb +369 -0
  47. data/lib/algolia/models/agent-studio/conversation_metadata.rb +209 -0
  48. data/lib/algolia/models/agent-studio/distinct_union.rb +108 -0
  49. data/lib/algolia/models/agent-studio/episode.rb +243 -0
  50. data/lib/algolia/models/agent-studio/error_base.rb +207 -0
  51. data/lib/algolia/models/agent-studio/exact_on_single_word_query.rb +35 -0
  52. data/lib/algolia/models/agent-studio/facet_filters_union.rb +108 -0
  53. data/lib/algolia/models/agent-studio/facets.rb +208 -0
  54. data/lib/algolia/models/agent-studio/facets_param.rb +220 -0
  55. data/lib/algolia/models/agent-studio/facets_union.rb +108 -0
  56. data/lib/algolia/models/agent-studio/feedback_creation_request.rb +251 -0
  57. data/lib/algolia/models/agent-studio/feedback_response.rb +297 -0
  58. data/lib/algolia/models/agent-studio/ignore_plurals_union.rb +108 -0
  59. data/lib/algolia/models/agent-studio/index_search_parameters.rb +267 -0
  60. data/lib/algolia/models/agent-studio/inside_bounding_box_union.rb +108 -0
  61. data/lib/algolia/models/agent-studio/inside_polygon_union.rb +108 -0
  62. data/lib/algolia/models/agent-studio/location_item_union.rb +108 -0
  63. data/lib/algolia/models/agent-studio/mcp_server_tool_config.rb +276 -0
  64. data/lib/algolia/models/agent-studio/mcp_tool_config.rb +218 -0
  65. data/lib/algolia/models/agent-studio/memory_record.rb +368 -0
  66. data/lib/algolia/models/agent-studio/memory_type.rb +34 -0
  67. data/lib/algolia/models/agent-studio/message_part.rb +132 -0
  68. data/lib/algolia/models/agent-studio/message_response.rb +309 -0
  69. data/lib/algolia/models/agent-studio/message_role.rb +34 -0
  70. data/lib/algolia/models/agent-studio/message_v4.rb +117 -0
  71. data/lib/algolia/models/agent-studio/message_v5.rb +117 -0
  72. data/lib/algolia/models/agent-studio/messages_union.rb +108 -0
  73. data/lib/algolia/models/agent-studio/number_param.rb +230 -0
  74. data/lib/algolia/models/agent-studio/number_param_constraint.rb +219 -0
  75. data/lib/algolia/models/agent-studio/numeric_filters_union.rb +108 -0
  76. data/lib/algolia/models/agent-studio/open_ai_compatible_provider_input.rb +232 -0
  77. data/lib/algolia/models/agent-studio/open_ai_provider_input.rb +220 -0
  78. data/lib/algolia/models/agent-studio/optional_filters_union.rb +108 -0
  79. data/lib/algolia/models/agent-studio/optional_words_union.rb +108 -0
  80. data/lib/algolia/models/agent-studio/paginated_agents_response.rb +221 -0
  81. data/lib/algolia/models/agent-studio/paginated_conversations_response.rb +221 -0
  82. data/lib/algolia/models/agent-studio/paginated_provider_authentications_response.rb +221 -0
  83. data/lib/algolia/models/agent-studio/paginated_secret_keys_response.rb +221 -0
  84. data/lib/algolia/models/agent-studio/pagination_metadata.rb +241 -0
  85. data/lib/algolia/models/agent-studio/provider_authentication_create.rb +230 -0
  86. data/lib/algolia/models/agent-studio/provider_authentication_patch.rb +218 -0
  87. data/lib/algolia/models/agent-studio/provider_authentication_response.rb +274 -0
  88. data/lib/algolia/models/agent-studio/provider_input.rb +111 -0
  89. data/lib/algolia/models/agent-studio/provider_input_nullable.rb +111 -0
  90. data/lib/algolia/models/agent-studio/provider_name.rb +38 -0
  91. data/lib/algolia/models/agent-studio/query_type.rb +35 -0
  92. data/lib/algolia/models/agent-studio/re_ranking_apply_filter_union.rb +108 -0
  93. data/lib/algolia/models/agent-studio/reasoning_part.rb +219 -0
  94. data/lib/algolia/models/agent-studio/reasoning_part_v4.rb +217 -0
  95. data/lib/algolia/models/agent-studio/reasoning_part_v5.rb +217 -0
  96. data/lib/algolia/models/agent-studio/remove_stop_words_union.rb +108 -0
  97. data/lib/algolia/models/agent-studio/remove_words_if_no_results.rb +36 -0
  98. data/lib/algolia/models/agent-studio/search_parameters.rb +950 -0
  99. data/lib/algolia/models/agent-studio/search_parameters_overrides.rb +286 -0
  100. data/lib/algolia/models/agent-studio/secret_key_create.rb +222 -0
  101. data/lib/algolia/models/agent-studio/secret_key_patch.rb +223 -0
  102. data/lib/algolia/models/agent-studio/secret_key_response.rb +287 -0
  103. data/lib/algolia/models/agent-studio/start_part.rb +208 -0
  104. data/lib/algolia/models/agent-studio/start_step_part.rb +208 -0
  105. data/lib/algolia/models/agent-studio/step_start_part_v4.rb +206 -0
  106. data/lib/algolia/models/agent-studio/step_start_part_v5.rb +206 -0
  107. data/lib/algolia/models/agent-studio/string_array_param.rb +242 -0
  108. data/lib/algolia/models/agent-studio/string_array_param_constraint.rb +211 -0
  109. data/lib/algolia/models/agent-studio/supported_language.rb +169 -0
  110. data/lib/algolia/models/agent-studio/tag_filters_union.rb +108 -0
  111. data/lib/algolia/models/agent-studio/text_param.rb +220 -0
  112. data/lib/algolia/models/agent-studio/text_part.rb +216 -0
  113. data/lib/algolia/models/agent-studio/text_part_v4.rb +217 -0
  114. data/lib/algolia/models/agent-studio/text_part_v5.rb +217 -0
  115. data/lib/algolia/models/agent-studio/tool_approval_request_part.rb +285 -0
  116. data/lib/algolia/models/agent-studio/tool_call_part.rb +265 -0
  117. data/lib/algolia/models/agent-studio/tool_config.rb +108 -0
  118. data/lib/algolia/models/agent-studio/tool_config_input.rb +129 -0
  119. data/lib/algolia/models/agent-studio/tool_invocation_part_v4.rb +217 -0
  120. data/lib/algolia/models/agent-studio/tool_invocation_v4.rb +309 -0
  121. data/lib/algolia/models/agent-studio/tool_part_v5.rb +309 -0
  122. data/lib/algolia/models/agent-studio/tool_result_output.rb +221 -0
  123. data/lib/algolia/models/agent-studio/tool_result_output_type.rb +37 -0
  124. data/lib/algolia/models/agent-studio/tool_result_part.rb +254 -0
  125. data/lib/algolia/models/agent-studio/tool_state.rb +36 -0
  126. data/lib/algolia/models/agent-studio/typo_tolerance_enum.rb +36 -0
  127. data/lib/algolia/models/agent-studio/typo_tolerance_union.rb +108 -0
  128. data/lib/algolia/models/agent-studio/unknown_tool_config.rb +220 -0
  129. data/lib/algolia/models/agent-studio/user_data_response.rb +223 -0
  130. data/lib/algolia/models/agent-studio/user_message_metadata_v5.rb +209 -0
  131. data/lib/algolia/models/agent-studio/user_message_v4.rb +250 -0
  132. data/lib/algolia/models/agent-studio/user_message_v5.rb +237 -0
  133. data/lib/algolia/models/agent-studio/validation_error.rb +252 -0
  134. data/lib/algolia/models/agent-studio/vote_enum.rb +34 -0
  135. data/lib/algolia/models/query-suggestions/configuration.rb +1 -0
  136. data/lib/algolia/models/query-suggestions/configuration_response.rb +1 -0
  137. data/lib/algolia/models/query-suggestions/configuration_with_index.rb +1 -0
  138. data/lib/algolia/models/query-suggestions/source_index.rb +4 -0
  139. data/lib/algolia/models/recommend/fallback_params.rb +2 -1
  140. data/lib/algolia/models/recommend/recommend_search_params.rb +2 -1
  141. data/lib/algolia/models/search/browse_params_object.rb +2 -1
  142. data/lib/algolia/models/search/consequence_params.rb +2 -1
  143. data/lib/algolia/models/search/fetched_index.rb +25 -4
  144. data/lib/algolia/models/search/fetched_index_ab_test.rb +253 -0
  145. data/lib/algolia/models/search/fetched_index_ab_test_target.rb +210 -0
  146. data/lib/algolia/models/search/fetched_index_ab_test_variant.rb +242 -0
  147. data/lib/algolia/models/search/index_settings.rb +2 -1
  148. data/lib/algolia/models/search/search_for_facets.rb +2 -1
  149. data/lib/algolia/models/search/search_for_hits.rb +2 -1
  150. data/lib/algolia/models/search/search_params_object.rb +2 -1
  151. data/lib/algolia/models/search/search_response_partial.rb +587 -0
  152. data/lib/algolia/models/search/search_result.rb +2 -1
  153. data/lib/algolia/models/search/settings_response.rb +2 -1
  154. data/lib/algolia/version.rb +1 -1
  155. data/lib/algolia.rb +1 -2
  156. metadata +131 -2
@@ -0,0 +1,253 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
4
+
5
+ require "date"
6
+ require "time"
7
+
8
+ module Algolia
9
+ module Search
10
+ # A/B test metadata. Only present if the index is part of an active A/B test.
11
+ class FetchedIndexAbTest
12
+ # A/B test ID.
13
+ attr_accessor :id
14
+
15
+ # A/B test schema version. Only present for v2 and later tests.
16
+ attr_accessor :version
17
+
18
+ # A/B test type. Only present for v2 and later tests. Currently always `index-configuration`.
19
+ attr_accessor :type
20
+
21
+ attr_accessor :target
22
+
23
+ # A/B test variants.
24
+ attr_accessor :variants
25
+
26
+ # Attribute mapping from ruby-style variable name to JSON key.
27
+ def self.attribute_map
28
+ {
29
+ :id => :id,
30
+ :version => :version,
31
+ :type => :type,
32
+ :target => :target,
33
+ :variants => :variants
34
+ }
35
+ end
36
+
37
+ # Attribute type mapping.
38
+ def self.types_mapping
39
+ {
40
+ :id => :"Integer",
41
+ :version => :"Integer",
42
+ :type => :"String",
43
+ :target => :"FetchedIndexAbTestTarget",
44
+ :variants => :"Array<FetchedIndexAbTestVariant>"
45
+ }
46
+ end
47
+
48
+ # List of attributes with nullable: true
49
+ def self.openapi_nullable
50
+ Set.new(
51
+ []
52
+ )
53
+ end
54
+
55
+ # Initializes the object
56
+ # @param [Hash] attributes Model attributes in the form of hash
57
+ def initialize(attributes = {})
58
+ if (!attributes.is_a?(Hash))
59
+ raise(
60
+ ArgumentError,
61
+ "The input argument (attributes) must be a hash in `Algolia::FetchedIndexAbTest` initialize method"
62
+ )
63
+ end
64
+
65
+ # check to see if the attribute exists and convert string to symbol for hash key
66
+ attributes = attributes.each_with_object({}) { |(k, v), h|
67
+ if (!self.class.attribute_map.key?(k.to_sym))
68
+ raise(
69
+ ArgumentError,
70
+ "`#{k}` is not a valid attribute in `Algolia::FetchedIndexAbTest`. Please check the name to make sure it's valid. List of attributes: " +
71
+ self.class.attribute_map.keys.inspect
72
+ )
73
+ end
74
+
75
+ h[k.to_sym] = v
76
+ }
77
+
78
+ if attributes.key?(:id)
79
+ self.id = attributes[:id]
80
+ else
81
+ self.id = nil
82
+ end
83
+
84
+ if attributes.key?(:version)
85
+ self.version = attributes[:version]
86
+ end
87
+
88
+ if attributes.key?(:type)
89
+ self.type = attributes[:type]
90
+ end
91
+
92
+ if attributes.key?(:target)
93
+ self.target = attributes[:target]
94
+ end
95
+
96
+ if attributes.key?(:variants)
97
+ if (value = attributes[:variants]).is_a?(Array)
98
+ self.variants = value
99
+ end
100
+ else
101
+ self.variants = nil
102
+ end
103
+ end
104
+
105
+ # Checks equality by comparing each attribute.
106
+ # @param [Object] Object to be compared
107
+ def ==(other)
108
+ return true if self.equal?(other)
109
+ self.class == other.class &&
110
+ id == other.id &&
111
+ version == other.version &&
112
+ type == other.type &&
113
+ target == other.target &&
114
+ variants == other.variants
115
+ end
116
+
117
+ # @see the `==` method
118
+ # @param [Object] Object to be compared
119
+ def eql?(other)
120
+ self == other
121
+ end
122
+
123
+ # Calculates hash code according to all attributes.
124
+ # @return [Integer] Hash code
125
+ def hash
126
+ [id, version, type, target, variants].hash
127
+ end
128
+
129
+ # Builds the object from hash
130
+ # @param [Hash] attributes Model attributes in the form of hash
131
+ # @return [Object] Returns the model itself
132
+ def self.build_from_hash(attributes)
133
+ return nil unless attributes.is_a?(Hash)
134
+ attributes = attributes.transform_keys(&:to_sym)
135
+ transformed_hash = {}
136
+ types_mapping.each_pair do |key, type|
137
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
138
+ transformed_hash[key.to_sym] = nil
139
+ elsif type =~ /\AArray<(.*)>/i
140
+ # check to ensure the input is an array given that the attribute
141
+ # is documented as an array but the input is not
142
+ if attributes[attribute_map[key]].is_a?(Array)
143
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
144
+ _deserialize(::Regexp.last_match(1), v)
145
+ }
146
+ end
147
+ elsif !attributes[attribute_map[key]].nil?
148
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
149
+ end
150
+ end
151
+
152
+ new(transformed_hash)
153
+ end
154
+
155
+ # Deserializes the data based on type
156
+ # @param string type Data type
157
+ # @param string value Value to be deserialized
158
+ # @return [Object] Deserialized data
159
+ def self._deserialize(type, value)
160
+ case type.to_sym
161
+ when :Time
162
+ Time.parse(value)
163
+ when :Date
164
+ Date.parse(value)
165
+ when :String
166
+ value.to_s
167
+ when :Integer
168
+ value.to_i
169
+ when :Float
170
+ value.to_f
171
+ when :Boolean
172
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
173
+ true
174
+ else
175
+ false
176
+ end
177
+
178
+ when :Object
179
+ # generic object (usually a Hash), return directly
180
+ value
181
+ when /\AArray<(?<inner_type>.+)>\z/
182
+ inner_type = Regexp.last_match[:inner_type]
183
+ value.map { |v| _deserialize(inner_type, v) }
184
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
185
+ k_type = Regexp.last_match[:k_type]
186
+ v_type = Regexp.last_match[:v_type]
187
+ {}.tap do |hash|
188
+ value.each do |k, v|
189
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
190
+ end
191
+ end
192
+ # model
193
+ else
194
+ # models (e.g. Pet) or oneOf
195
+ klass = Algolia::Search.const_get(type)
196
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
197
+ .build_from_hash(value)
198
+ end
199
+ end
200
+
201
+ # Returns the string representation of the object
202
+ # @return [String] String presentation of the object
203
+ def to_s
204
+ to_hash.to_s
205
+ end
206
+
207
+ # to_body is an alias to to_hash (backward compatibility)
208
+ # @return [Hash] Returns the object in the form of hash
209
+ def to_body
210
+ to_hash
211
+ end
212
+
213
+ def to_json(*_args)
214
+ to_hash.to_json
215
+ end
216
+
217
+ # Returns the object in the form of hash
218
+ # @return [Hash] Returns the object in the form of hash
219
+ def to_hash
220
+ hash = {}
221
+ self.class.attribute_map.each_pair do |attr, param|
222
+ value = send(attr)
223
+ if value.nil?
224
+ is_nullable = self.class.openapi_nullable.include?(attr)
225
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
226
+ end
227
+
228
+ hash[param] = _to_hash(value)
229
+ end
230
+
231
+ hash
232
+ end
233
+
234
+ # Outputs non-array value in the form of hash
235
+ # For object, use to_hash. Otherwise, just return the value
236
+ # @param [Object] value Any valid value
237
+ # @return [Hash] Returns the value in the form of hash
238
+ def _to_hash(value)
239
+ if value.is_a?(Array)
240
+ value.compact.map { |v| _to_hash(v) }
241
+ elsif value.is_a?(Hash)
242
+ {}.tap do |hash|
243
+ value.each { |k, v| hash[k] = _to_hash(v) }
244
+ end
245
+ elsif value.respond_to?(:to_hash)
246
+ value.to_hash
247
+ else
248
+ value
249
+ end
250
+ end
251
+ end
252
+ end
253
+ end
@@ -0,0 +1,210 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
4
+
5
+ require "date"
6
+ require "time"
7
+
8
+ module Algolia
9
+ module Search
10
+ # A/B test target criteria. Only present for v2 and later tests.
11
+ class FetchedIndexAbTestTarget
12
+ # Index name to match. Use `*` to target the entire application.
13
+ attr_accessor :index_name
14
+
15
+ # Attribute mapping from ruby-style variable name to JSON key.
16
+ def self.attribute_map
17
+ {
18
+ :index_name => :indexName
19
+ }
20
+ end
21
+
22
+ # Attribute type mapping.
23
+ def self.types_mapping
24
+ {
25
+ :index_name => :"String"
26
+ }
27
+ end
28
+
29
+ # List of attributes with nullable: true
30
+ def self.openapi_nullable
31
+ Set.new(
32
+ []
33
+ )
34
+ end
35
+
36
+ # Initializes the object
37
+ # @param [Hash] attributes Model attributes in the form of hash
38
+ def initialize(attributes = {})
39
+ if (!attributes.is_a?(Hash))
40
+ raise(
41
+ ArgumentError,
42
+ "The input argument (attributes) must be a hash in `Algolia::FetchedIndexAbTestTarget` initialize method"
43
+ )
44
+ end
45
+
46
+ # check to see if the attribute exists and convert string to symbol for hash key
47
+ attributes = attributes.each_with_object({}) { |(k, v), h|
48
+ if (!self.class.attribute_map.key?(k.to_sym))
49
+ raise(
50
+ ArgumentError,
51
+ "`#{k}` is not a valid attribute in `Algolia::FetchedIndexAbTestTarget`. Please check the name to make sure it's valid. List of attributes: " +
52
+ self.class.attribute_map.keys.inspect
53
+ )
54
+ end
55
+
56
+ h[k.to_sym] = v
57
+ }
58
+
59
+ if attributes.key?(:index_name)
60
+ self.index_name = attributes[:index_name]
61
+ else
62
+ self.index_name = nil
63
+ end
64
+ end
65
+
66
+ # Checks equality by comparing each attribute.
67
+ # @param [Object] Object to be compared
68
+ def ==(other)
69
+ return true if self.equal?(other)
70
+ self.class == other.class &&
71
+ index_name == other.index_name
72
+ end
73
+
74
+ # @see the `==` method
75
+ # @param [Object] Object to be compared
76
+ def eql?(other)
77
+ self == other
78
+ end
79
+
80
+ # Calculates hash code according to all attributes.
81
+ # @return [Integer] Hash code
82
+ def hash
83
+ [index_name].hash
84
+ end
85
+
86
+ # Builds the object from hash
87
+ # @param [Hash] attributes Model attributes in the form of hash
88
+ # @return [Object] Returns the model itself
89
+ def self.build_from_hash(attributes)
90
+ return nil unless attributes.is_a?(Hash)
91
+ attributes = attributes.transform_keys(&:to_sym)
92
+ transformed_hash = {}
93
+ types_mapping.each_pair do |key, type|
94
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
95
+ transformed_hash[key.to_sym] = nil
96
+ elsif type =~ /\AArray<(.*)>/i
97
+ # check to ensure the input is an array given that the attribute
98
+ # is documented as an array but the input is not
99
+ if attributes[attribute_map[key]].is_a?(Array)
100
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
101
+ _deserialize(::Regexp.last_match(1), v)
102
+ }
103
+ end
104
+ elsif !attributes[attribute_map[key]].nil?
105
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
106
+ end
107
+ end
108
+
109
+ new(transformed_hash)
110
+ end
111
+
112
+ # Deserializes the data based on type
113
+ # @param string type Data type
114
+ # @param string value Value to be deserialized
115
+ # @return [Object] Deserialized data
116
+ def self._deserialize(type, value)
117
+ case type.to_sym
118
+ when :Time
119
+ Time.parse(value)
120
+ when :Date
121
+ Date.parse(value)
122
+ when :String
123
+ value.to_s
124
+ when :Integer
125
+ value.to_i
126
+ when :Float
127
+ value.to_f
128
+ when :Boolean
129
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
130
+ true
131
+ else
132
+ false
133
+ end
134
+
135
+ when :Object
136
+ # generic object (usually a Hash), return directly
137
+ value
138
+ when /\AArray<(?<inner_type>.+)>\z/
139
+ inner_type = Regexp.last_match[:inner_type]
140
+ value.map { |v| _deserialize(inner_type, v) }
141
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
142
+ k_type = Regexp.last_match[:k_type]
143
+ v_type = Regexp.last_match[:v_type]
144
+ {}.tap do |hash|
145
+ value.each do |k, v|
146
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
147
+ end
148
+ end
149
+ # model
150
+ else
151
+ # models (e.g. Pet) or oneOf
152
+ klass = Algolia::Search.const_get(type)
153
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
154
+ .build_from_hash(value)
155
+ end
156
+ end
157
+
158
+ # Returns the string representation of the object
159
+ # @return [String] String presentation of the object
160
+ def to_s
161
+ to_hash.to_s
162
+ end
163
+
164
+ # to_body is an alias to to_hash (backward compatibility)
165
+ # @return [Hash] Returns the object in the form of hash
166
+ def to_body
167
+ to_hash
168
+ end
169
+
170
+ def to_json(*_args)
171
+ to_hash.to_json
172
+ end
173
+
174
+ # Returns the object in the form of hash
175
+ # @return [Hash] Returns the object in the form of hash
176
+ def to_hash
177
+ hash = {}
178
+ self.class.attribute_map.each_pair do |attr, param|
179
+ value = send(attr)
180
+ if value.nil?
181
+ is_nullable = self.class.openapi_nullable.include?(attr)
182
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
183
+ end
184
+
185
+ hash[param] = _to_hash(value)
186
+ end
187
+
188
+ hash
189
+ end
190
+
191
+ # Outputs non-array value in the form of hash
192
+ # For object, use to_hash. Otherwise, just return the value
193
+ # @param [Object] value Any valid value
194
+ # @return [Hash] Returns the value in the form of hash
195
+ def _to_hash(value)
196
+ if value.is_a?(Array)
197
+ value.compact.map { |v| _to_hash(v) }
198
+ elsif value.is_a?(Hash)
199
+ {}.tap do |hash|
200
+ value.each { |k, v| hash[k] = _to_hash(v) }
201
+ end
202
+ elsif value.respond_to?(:to_hash)
203
+ value.to_hash
204
+ else
205
+ value
206
+ end
207
+ end
208
+ end
209
+ end
210
+ end
@@ -0,0 +1,242 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
4
+
5
+ require "date"
6
+ require "time"
7
+
8
+ module Algolia
9
+ module Search
10
+ # A/B test variant for an index.
11
+ class FetchedIndexAbTestVariant
12
+ # Index name of the variant. Only present for v0/v1 tests; in v2 this moves into `payload`.
13
+ attr_accessor :index_name
14
+
15
+ # Percentage of search traffic routed to this variant.
16
+ attr_accessor :percentage
17
+
18
+ # URL-encoded custom search parameters applied to this variant. Only present for v0/v1 tests; in v2 this moves into `payload`.
19
+ attr_accessor :custom_search_parameters
20
+
21
+ # Type-specific configuration. Only present for v2 and later tests. Shape depends on the parent A/B test's `type`.
22
+ attr_accessor :payload
23
+
24
+ # Attribute mapping from ruby-style variable name to JSON key.
25
+ def self.attribute_map
26
+ {
27
+ :index_name => :indexName,
28
+ :percentage => :percentage,
29
+ :custom_search_parameters => :customSearchParameters,
30
+ :payload => :payload
31
+ }
32
+ end
33
+
34
+ # Attribute type mapping.
35
+ def self.types_mapping
36
+ {
37
+ :index_name => :"String",
38
+ :percentage => :"Integer",
39
+ :custom_search_parameters => :"String",
40
+ :payload => :"Hash<String, Object>"
41
+ }
42
+ end
43
+
44
+ # List of attributes with nullable: true
45
+ def self.openapi_nullable
46
+ Set.new(
47
+ []
48
+ )
49
+ end
50
+
51
+ # Initializes the object
52
+ # @param [Hash] attributes Model attributes in the form of hash
53
+ def initialize(attributes = {})
54
+ if (!attributes.is_a?(Hash))
55
+ raise(
56
+ ArgumentError,
57
+ "The input argument (attributes) must be a hash in `Algolia::FetchedIndexAbTestVariant` initialize method"
58
+ )
59
+ end
60
+
61
+ # check to see if the attribute exists and convert string to symbol for hash key
62
+ attributes = attributes.each_with_object({}) { |(k, v), h|
63
+ if (!self.class.attribute_map.key?(k.to_sym))
64
+ raise(
65
+ ArgumentError,
66
+ "`#{k}` is not a valid attribute in `Algolia::FetchedIndexAbTestVariant`. Please check the name to make sure it's valid. List of attributes: " +
67
+ self.class.attribute_map.keys.inspect
68
+ )
69
+ end
70
+
71
+ h[k.to_sym] = v
72
+ }
73
+
74
+ if attributes.key?(:index_name)
75
+ self.index_name = attributes[:index_name]
76
+ end
77
+
78
+ if attributes.key?(:percentage)
79
+ self.percentage = attributes[:percentage]
80
+ else
81
+ self.percentage = nil
82
+ end
83
+
84
+ if attributes.key?(:custom_search_parameters)
85
+ self.custom_search_parameters = attributes[:custom_search_parameters]
86
+ end
87
+
88
+ if attributes.key?(:payload)
89
+ if (value = attributes[:payload]).is_a?(Hash)
90
+ self.payload = value
91
+ end
92
+ end
93
+ end
94
+
95
+ # Checks equality by comparing each attribute.
96
+ # @param [Object] Object to be compared
97
+ def ==(other)
98
+ return true if self.equal?(other)
99
+ self.class == other.class &&
100
+ index_name == other.index_name &&
101
+ percentage == other.percentage &&
102
+ custom_search_parameters == other.custom_search_parameters &&
103
+ payload == other.payload
104
+ end
105
+
106
+ # @see the `==` method
107
+ # @param [Object] Object to be compared
108
+ def eql?(other)
109
+ self == other
110
+ end
111
+
112
+ # Calculates hash code according to all attributes.
113
+ # @return [Integer] Hash code
114
+ def hash
115
+ [index_name, percentage, custom_search_parameters, payload].hash
116
+ end
117
+
118
+ # Builds the object from hash
119
+ # @param [Hash] attributes Model attributes in the form of hash
120
+ # @return [Object] Returns the model itself
121
+ def self.build_from_hash(attributes)
122
+ return nil unless attributes.is_a?(Hash)
123
+ attributes = attributes.transform_keys(&:to_sym)
124
+ transformed_hash = {}
125
+ types_mapping.each_pair do |key, type|
126
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
127
+ transformed_hash[key.to_sym] = nil
128
+ elsif type =~ /\AArray<(.*)>/i
129
+ # check to ensure the input is an array given that the attribute
130
+ # is documented as an array but the input is not
131
+ if attributes[attribute_map[key]].is_a?(Array)
132
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
133
+ _deserialize(::Regexp.last_match(1), v)
134
+ }
135
+ end
136
+ elsif !attributes[attribute_map[key]].nil?
137
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
138
+ end
139
+ end
140
+
141
+ new(transformed_hash)
142
+ end
143
+
144
+ # Deserializes the data based on type
145
+ # @param string type Data type
146
+ # @param string value Value to be deserialized
147
+ # @return [Object] Deserialized data
148
+ def self._deserialize(type, value)
149
+ case type.to_sym
150
+ when :Time
151
+ Time.parse(value)
152
+ when :Date
153
+ Date.parse(value)
154
+ when :String
155
+ value.to_s
156
+ when :Integer
157
+ value.to_i
158
+ when :Float
159
+ value.to_f
160
+ when :Boolean
161
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
162
+ true
163
+ else
164
+ false
165
+ end
166
+
167
+ when :Object
168
+ # generic object (usually a Hash), return directly
169
+ value
170
+ when /\AArray<(?<inner_type>.+)>\z/
171
+ inner_type = Regexp.last_match[:inner_type]
172
+ value.map { |v| _deserialize(inner_type, v) }
173
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
174
+ k_type = Regexp.last_match[:k_type]
175
+ v_type = Regexp.last_match[:v_type]
176
+ {}.tap do |hash|
177
+ value.each do |k, v|
178
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
179
+ end
180
+ end
181
+ # model
182
+ else
183
+ # models (e.g. Pet) or oneOf
184
+ klass = Algolia::Search.const_get(type)
185
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
186
+ .build_from_hash(value)
187
+ end
188
+ end
189
+
190
+ # Returns the string representation of the object
191
+ # @return [String] String presentation of the object
192
+ def to_s
193
+ to_hash.to_s
194
+ end
195
+
196
+ # to_body is an alias to to_hash (backward compatibility)
197
+ # @return [Hash] Returns the object in the form of hash
198
+ def to_body
199
+ to_hash
200
+ end
201
+
202
+ def to_json(*_args)
203
+ to_hash.to_json
204
+ end
205
+
206
+ # Returns the object in the form of hash
207
+ # @return [Hash] Returns the object in the form of hash
208
+ def to_hash
209
+ hash = {}
210
+ self.class.attribute_map.each_pair do |attr, param|
211
+ value = send(attr)
212
+ if value.nil?
213
+ is_nullable = self.class.openapi_nullable.include?(attr)
214
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
215
+ end
216
+
217
+ hash[param] = _to_hash(value)
218
+ end
219
+
220
+ hash
221
+ end
222
+
223
+ # Outputs non-array value in the form of hash
224
+ # For object, use to_hash. Otherwise, just return the value
225
+ # @param [Object] value Any valid value
226
+ # @return [Hash] Returns the value in the form of hash
227
+ def _to_hash(value)
228
+ if value.is_a?(Array)
229
+ value.compact.map { |v| _to_hash(v) }
230
+ elsif value.is_a?(Hash)
231
+ {}.tap do |hash|
232
+ value.each { |k, v| hash[k] = _to_hash(v) }
233
+ end
234
+ elsif value.respond_to?(:to_hash)
235
+ value.to_hash
236
+ else
237
+ value
238
+ end
239
+ end
240
+ end
241
+ end
242
+ end
@@ -319,7 +319,8 @@ module Algolia
319
319
  Set.new(
320
320
  [
321
321
  :user_data,
322
- :optional_words
322
+ :optional_words,
323
+ :re_ranking_apply_filter
323
324
  ]
324
325
  )
325
326
  end