algolia 3.25.0 → 3.26.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 (61) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/issue.yml +1 -1
  3. data/.github/workflows/release.yml +1 -1
  4. data/CHANGELOG.md +10 -0
  5. data/Gemfile.lock +1 -1
  6. data/lib/algolia/api/composition_client.rb +765 -0
  7. data/lib/algolia/api/ingestion_client.rb +15 -4
  8. data/lib/algolia/api/search_client.rb +4 -2
  9. data/lib/algolia/models/composition/action.rb +34 -0
  10. data/lib/algolia/models/composition/advanced_syntax_features.rb +34 -0
  11. data/lib/algolia/models/composition/alternatives_as_exact.rb +36 -0
  12. data/lib/algolia/models/composition/anchoring.rb +36 -0
  13. data/lib/algolia/models/composition/base_injection_query_parameters.rb +732 -0
  14. data/lib/algolia/models/composition/batch_composition_action.rb +109 -0
  15. data/lib/algolia/models/composition/batch_params.rb +213 -0
  16. data/lib/algolia/models/composition/boolean_string.rb +34 -0
  17. data/lib/algolia/models/composition/composition.rb +244 -0
  18. data/lib/algolia/models/composition/composition_behavior.rb +210 -0
  19. data/lib/algolia/models/composition/composition_rule.rb +280 -0
  20. data/lib/algolia/models/composition/composition_rule_consequence.rb +211 -0
  21. data/lib/algolia/models/composition/composition_rules_batch_params.rb +211 -0
  22. data/lib/algolia/models/composition/composition_source.rb +210 -0
  23. data/lib/algolia/models/composition/composition_source_search.rb +220 -0
  24. data/lib/algolia/models/composition/condition.rb +238 -0
  25. data/lib/algolia/models/composition/delete_composition_action.rb +212 -0
  26. data/lib/algolia/models/composition/delete_composition_rule_action.rb +212 -0
  27. data/lib/algolia/models/composition/distinct.rb +110 -0
  28. data/lib/algolia/models/composition/exact_on_single_word_query.rb +35 -0
  29. data/lib/algolia/models/composition/external.rb +226 -0
  30. data/lib/algolia/models/composition/external_ordering.rb +34 -0
  31. data/lib/algolia/models/composition/external_source.rb +211 -0
  32. data/lib/algolia/models/composition/get_task_response.rb +210 -0
  33. data/lib/algolia/models/composition/ignore_plurals.rb +111 -0
  34. data/lib/algolia/models/composition/injected_item.rb +253 -0
  35. data/lib/algolia/models/composition/injected_item_hits_metadata.rb +222 -0
  36. data/lib/algolia/models/composition/injected_item_metadata.rb +209 -0
  37. data/lib/algolia/models/composition/injected_item_source.rb +109 -0
  38. data/lib/algolia/models/composition/injection.rb +222 -0
  39. data/lib/algolia/models/composition/list_compositions_response.rb +261 -0
  40. data/lib/algolia/models/composition/main.rb +207 -0
  41. data/lib/algolia/models/composition/main_injection_query_parameters.rb +807 -0
  42. data/lib/algolia/models/composition/multiple_batch_request.rb +221 -0
  43. data/lib/algolia/models/composition/multiple_batch_response.rb +213 -0
  44. data/lib/algolia/models/composition/optional_words.rb +110 -0
  45. data/lib/algolia/models/composition/query_type.rb +35 -0
  46. data/lib/algolia/models/composition/remove_stop_words.rb +110 -0
  47. data/lib/algolia/models/composition/remove_words_if_no_results.rb +36 -0
  48. data/lib/algolia/models/composition/rules_batch_composition_action.rb +109 -0
  49. data/lib/algolia/models/composition/rules_multiple_batch_request.rb +221 -0
  50. data/lib/algolia/models/composition/rules_multiple_batch_response.rb +211 -0
  51. data/lib/algolia/models/composition/search.rb +217 -0
  52. data/lib/algolia/models/composition/search_composition_rules_params.rb +261 -0
  53. data/lib/algolia/models/composition/search_composition_rules_response.rb +249 -0
  54. data/lib/algolia/models/composition/search_source.rb +211 -0
  55. data/lib/algolia/models/composition/task_id_response.rb +211 -0
  56. data/lib/algolia/models/composition/task_status.rb +34 -0
  57. data/lib/algolia/models/composition/time_range.rb +219 -0
  58. data/lib/algolia/models/composition/typo_tolerance.rb +110 -0
  59. data/lib/algolia/models/composition/typo_tolerance_enum.rb +36 -0
  60. data/lib/algolia/version.rb +1 -1
  61. metadata +52 -1
@@ -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 Composition
10
+ class GetTaskResponse
11
+ attr_accessor :status
12
+
13
+ # Attribute mapping from ruby-style variable name to JSON key.
14
+ def self.attribute_map
15
+ {
16
+ :status => :status
17
+ }
18
+ end
19
+
20
+ # Attribute type mapping.
21
+ def self.types_mapping
22
+ {
23
+ :status => :"TaskStatus"
24
+ }
25
+ end
26
+
27
+ # List of attributes with nullable: true
28
+ def self.openapi_nullable
29
+ Set.new(
30
+ []
31
+ )
32
+ end
33
+
34
+ # Initializes the object
35
+ # @param [Hash] attributes Model attributes in the form of hash
36
+ def initialize(attributes = {})
37
+ if (!attributes.is_a?(Hash))
38
+ raise(
39
+ ArgumentError,
40
+ "The input argument (attributes) must be a hash in `Algolia::GetTaskResponse` initialize method"
41
+ )
42
+ end
43
+
44
+ # check to see if the attribute exists and convert string to symbol for hash key
45
+ attributes = attributes.each_with_object({}) { |(k, v), h|
46
+ if (!self.class.attribute_map.key?(k.to_sym))
47
+ raise(
48
+ ArgumentError,
49
+ "`#{k}` is not a valid attribute in `Algolia::GetTaskResponse`. Please check the name to make sure it's valid. List of attributes: " +
50
+ self.class.attribute_map.keys.inspect
51
+ )
52
+ end
53
+
54
+ h[k.to_sym] = v
55
+ }
56
+
57
+ if attributes.key?(:status)
58
+ self.status = attributes[:status]
59
+ else
60
+ self.status = nil
61
+ end
62
+ end
63
+
64
+ # Checks equality by comparing each attribute.
65
+ # @param [Object] Object to be compared
66
+ def ==(other)
67
+ return true if self.equal?(other)
68
+ self.class == other.class &&
69
+ status == other.status
70
+ end
71
+
72
+ # @see the `==` method
73
+ # @param [Object] Object to be compared
74
+ def eql?(other)
75
+ self == other
76
+ end
77
+
78
+ # Calculates hash code according to all attributes.
79
+ # @return [Integer] Hash code
80
+ def hash
81
+ [status].hash
82
+ end
83
+
84
+ # Builds the object from hash
85
+ # @param [Hash] attributes Model attributes in the form of hash
86
+ # @return [Object] Returns the model itself
87
+ def self.build_from_hash(attributes)
88
+ return nil unless attributes.is_a?(Hash)
89
+ attributes = attributes.transform_keys(&:to_sym)
90
+ transformed_hash = {}
91
+ types_mapping.each_pair do |key, type|
92
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
93
+ transformed_hash[key.to_sym] = nil
94
+ elsif type =~ /\AArray<(.*)>/i
95
+ # check to ensure the input is an array given that the attribute
96
+ # is documented as an array but the input is not
97
+ if attributes[attribute_map[key]].is_a?(Array)
98
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
99
+ _deserialize(::Regexp.last_match(1), v)
100
+ }
101
+ end
102
+ elsif !attributes[attribute_map[key]].nil?
103
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
104
+ end
105
+ end
106
+
107
+ new(transformed_hash)
108
+ end
109
+
110
+ # Deserializes the data based on type
111
+ # @param string type Data type
112
+ # @param string value Value to be deserialized
113
+ # @return [Object] Deserialized data
114
+ def self._deserialize(type, value)
115
+ case type.to_sym
116
+ when :Time
117
+ Time.parse(value)
118
+ when :Date
119
+ Date.parse(value)
120
+ when :String
121
+ value.to_s
122
+ when :Integer
123
+ value.to_i
124
+ when :Float
125
+ value.to_f
126
+ when :Boolean
127
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
128
+ true
129
+ else
130
+ false
131
+ end
132
+
133
+ when :Object
134
+ # generic object (usually a Hash), return directly
135
+ value
136
+ when /\AArray<(?<inner_type>.+)>\z/
137
+ inner_type = Regexp.last_match[:inner_type]
138
+ value.map { |v| _deserialize(inner_type, v) }
139
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
140
+ k_type = Regexp.last_match[:k_type]
141
+ v_type = Regexp.last_match[:v_type]
142
+ {}.tap do |hash|
143
+ value.each do |k, v|
144
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
145
+ end
146
+ end
147
+ # model
148
+ else
149
+ # models (e.g. Pet) or oneOf
150
+ klass = Algolia::Composition.const_get(type)
151
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
152
+ .build_from_hash(value)
153
+ end
154
+ end
155
+
156
+ # Returns the string representation of the object
157
+ # @return [String] String presentation of the object
158
+ def to_s
159
+ to_hash.to_s
160
+ end
161
+
162
+ # to_body is an alias to to_hash (backward compatibility)
163
+ # @return [Hash] Returns the object in the form of hash
164
+ def to_body
165
+ to_hash
166
+ end
167
+
168
+ def to_json(*_args)
169
+ to_hash.to_json
170
+ end
171
+
172
+ # Returns the object in the form of hash
173
+ # @return [Hash] Returns the object in the form of hash
174
+ def to_hash
175
+ hash = {}
176
+ self.class.attribute_map.each_pair do |attr, param|
177
+ value = send(attr)
178
+ if value.nil?
179
+ is_nullable = self.class.openapi_nullable.include?(attr)
180
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
181
+ end
182
+
183
+ hash[param] = _to_hash(value)
184
+ end
185
+
186
+ hash
187
+ end
188
+
189
+ # Outputs non-array value in the form of hash
190
+ # For object, use to_hash. Otherwise, just return the value
191
+ # @param [Object] value Any valid value
192
+ # @return [Hash] Returns the value in the form of hash
193
+ def _to_hash(value)
194
+ if value.is_a?(Array)
195
+ value.compact.map { |v| _to_hash(v) }
196
+ elsif value.is_a?(Hash)
197
+ {}.tap do |hash|
198
+ value.each { |k, v| hash[k] = _to_hash(v) }
199
+ end
200
+ elsif value.respond_to?(:to_hash)
201
+ value.to_hash
202
+ else
203
+ value
204
+ end
205
+ end
206
+
207
+ end
208
+
209
+ end
210
+ end
@@ -0,0 +1,111 @@
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 Composition
10
+ # Treat singular, plurals, and other forms of declensions as equivalent. You should only use this feature for the languages used in your index.
11
+ module IgnorePlurals
12
+ class << self
13
+ # List of class defined in oneOf (OpenAPI v3)
14
+ def openapi_one_of
15
+ [
16
+ :"Array<SupportedLanguage>",
17
+ :"Boolean",
18
+ :"BooleanString"
19
+ ]
20
+ end
21
+
22
+ # Builds the object
23
+ # @param [Mixed] Data to be matched against the list of oneOf items
24
+ # @return [Object] Returns the model or the data itself
25
+ def build(data)
26
+ # Go through the list of oneOf items and attempt to identify the appropriate one.
27
+ # Note:
28
+ # - We do not attempt to check whether exactly one item matches.
29
+ # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
30
+ # due to the way the deserialization is made in the base_object template (it just casts without verifying).
31
+ # - TODO: scalar values are de facto behaving as if they were nullable.
32
+ # - TODO: logging when debugging is set.
33
+ openapi_one_of.each do |klass|
34
+ begin
35
+ # "nullable: true"
36
+ next if klass == :AnyType
37
+ typed_data = find_and_cast_into_type(klass, data)
38
+ return typed_data if typed_data
39
+ # rescue all errors so we keep iterating even if the current item lookup raises
40
+ rescue
41
+ end
42
+ end
43
+
44
+ openapi_one_of.include?(:AnyType) ? data : nil
45
+ end
46
+
47
+ private
48
+
49
+ SchemaMismatchError = Class.new(StandardError)
50
+
51
+ def find_and_cast_into_type(klass, data)
52
+ return if data.nil?
53
+
54
+ case klass.to_s
55
+ when "Boolean"
56
+ return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
57
+ when "Float"
58
+ return data if data.instance_of?(Float)
59
+ when "Integer"
60
+ return data if data.instance_of?(Integer)
61
+ when "Time"
62
+ return Time.parse(data)
63
+ when "Date"
64
+ return Date.parse(data)
65
+ when "String"
66
+ return data if data.instance_of?(String)
67
+ # "type: object"
68
+ when "Object"
69
+ return data if data.instance_of?(Hash)
70
+ # "type: array"
71
+ when /\AArray<(?<sub_type>.+)>\z/
72
+ if data.instance_of?(Array)
73
+ sub_type = Regexp.last_match[:sub_type]
74
+ return data.map { |item| find_and_cast_into_type(sub_type, item) }
75
+ end
76
+ # "type: object" with "additionalProperties: { ... }"
77
+ when /\AHash<String, (?<sub_type>.+)>\z/
78
+ if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
79
+ sub_type = Regexp.last_match[:sub_type]
80
+ return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
81
+ end
82
+ # model
83
+ else
84
+ const = Algolia::Composition.const_get(klass)
85
+ if const
86
+ if const.respond_to?(:openapi_one_of)
87
+ # nested oneOf model
88
+ model = const.build(data)
89
+ elsif const.respond_to?(:discriminator_attributes)
90
+ if const.discriminator_attributes.all? { |attr| data.key?(attr) }
91
+ model = const.build_from_hash(data)
92
+ end
93
+ else
94
+ # maybe it's an enum, or doens't have discriminators
95
+ model = const.build_from_hash(data)
96
+ end
97
+
98
+ return model if model
99
+ end
100
+ end
101
+
102
+ # if no match by now, raise
103
+ raise
104
+ rescue
105
+ raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
106
+ end
107
+ end
108
+ end
109
+
110
+ end
111
+ end
@@ -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 Composition
10
+ class InjectedItem
11
+ # injected Item unique identifier.
12
+ attr_accessor :key
13
+
14
+ attr_accessor :source
15
+
16
+ attr_accessor :position
17
+
18
+ attr_accessor :length
19
+
20
+ attr_accessor :metadata
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :key => :key,
26
+ :source => :source,
27
+ :position => :position,
28
+ :length => :length,
29
+ :metadata => :metadata
30
+ }
31
+ end
32
+
33
+ # Attribute type mapping.
34
+ def self.types_mapping
35
+ {
36
+ :key => :"String",
37
+ :source => :"InjectedItemSource",
38
+ :position => :"Integer",
39
+ :length => :"Integer",
40
+ :metadata => :"InjectedItemMetadata"
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::InjectedItem` 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::InjectedItem`. 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?(:key)
75
+ self.key = attributes[:key]
76
+ else
77
+ self.key = nil
78
+ end
79
+
80
+ if attributes.key?(:source)
81
+ self.source = attributes[:source]
82
+ else
83
+ self.source = nil
84
+ end
85
+
86
+ if attributes.key?(:position)
87
+ self.position = attributes[:position]
88
+ else
89
+ self.position = nil
90
+ end
91
+
92
+ if attributes.key?(:length)
93
+ self.length = attributes[:length]
94
+ else
95
+ self.length = nil
96
+ end
97
+
98
+ if attributes.key?(:metadata)
99
+ self.metadata = attributes[:metadata]
100
+ end
101
+ end
102
+
103
+ # Checks equality by comparing each attribute.
104
+ # @param [Object] Object to be compared
105
+ def ==(other)
106
+ return true if self.equal?(other)
107
+ self.class == other.class &&
108
+ key == other.key &&
109
+ source == other.source &&
110
+ position == other.position &&
111
+ length == other.length &&
112
+ metadata == other.metadata
113
+ end
114
+
115
+ # @see the `==` method
116
+ # @param [Object] Object to be compared
117
+ def eql?(other)
118
+ self == other
119
+ end
120
+
121
+ # Calculates hash code according to all attributes.
122
+ # @return [Integer] Hash code
123
+ def hash
124
+ [key, source, position, length, metadata].hash
125
+ end
126
+
127
+ # Builds the object from hash
128
+ # @param [Hash] attributes Model attributes in the form of hash
129
+ # @return [Object] Returns the model itself
130
+ def self.build_from_hash(attributes)
131
+ return nil unless attributes.is_a?(Hash)
132
+ attributes = attributes.transform_keys(&:to_sym)
133
+ transformed_hash = {}
134
+ types_mapping.each_pair do |key, type|
135
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
136
+ transformed_hash[key.to_sym] = nil
137
+ elsif type =~ /\AArray<(.*)>/i
138
+ # check to ensure the input is an array given that the attribute
139
+ # is documented as an array but the input is not
140
+ if attributes[attribute_map[key]].is_a?(Array)
141
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
142
+ _deserialize(::Regexp.last_match(1), v)
143
+ }
144
+ end
145
+ elsif !attributes[attribute_map[key]].nil?
146
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
147
+ end
148
+ end
149
+
150
+ new(transformed_hash)
151
+ end
152
+
153
+ # Deserializes the data based on type
154
+ # @param string type Data type
155
+ # @param string value Value to be deserialized
156
+ # @return [Object] Deserialized data
157
+ def self._deserialize(type, value)
158
+ case type.to_sym
159
+ when :Time
160
+ Time.parse(value)
161
+ when :Date
162
+ Date.parse(value)
163
+ when :String
164
+ value.to_s
165
+ when :Integer
166
+ value.to_i
167
+ when :Float
168
+ value.to_f
169
+ when :Boolean
170
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
171
+ true
172
+ else
173
+ false
174
+ end
175
+
176
+ when :Object
177
+ # generic object (usually a Hash), return directly
178
+ value
179
+ when /\AArray<(?<inner_type>.+)>\z/
180
+ inner_type = Regexp.last_match[:inner_type]
181
+ value.map { |v| _deserialize(inner_type, v) }
182
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
183
+ k_type = Regexp.last_match[:k_type]
184
+ v_type = Regexp.last_match[:v_type]
185
+ {}.tap do |hash|
186
+ value.each do |k, v|
187
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
188
+ end
189
+ end
190
+ # model
191
+ else
192
+ # models (e.g. Pet) or oneOf
193
+ klass = Algolia::Composition.const_get(type)
194
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
195
+ .build_from_hash(value)
196
+ end
197
+ end
198
+
199
+ # Returns the string representation of the object
200
+ # @return [String] String presentation of the object
201
+ def to_s
202
+ to_hash.to_s
203
+ end
204
+
205
+ # to_body is an alias to to_hash (backward compatibility)
206
+ # @return [Hash] Returns the object in the form of hash
207
+ def to_body
208
+ to_hash
209
+ end
210
+
211
+ def to_json(*_args)
212
+ to_hash.to_json
213
+ end
214
+
215
+ # Returns the object in the form of hash
216
+ # @return [Hash] Returns the object in the form of hash
217
+ def to_hash
218
+ hash = {}
219
+ self.class.attribute_map.each_pair do |attr, param|
220
+ value = send(attr)
221
+ if value.nil?
222
+ is_nullable = self.class.openapi_nullable.include?(attr)
223
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
224
+ end
225
+
226
+ hash[param] = _to_hash(value)
227
+ end
228
+
229
+ hash
230
+ end
231
+
232
+ # Outputs non-array value in the form of hash
233
+ # For object, use to_hash. Otherwise, just return the value
234
+ # @param [Object] value Any valid value
235
+ # @return [Hash] Returns the value in the form of hash
236
+ def _to_hash(value)
237
+ if value.is_a?(Array)
238
+ value.compact.map { |v| _to_hash(v) }
239
+ elsif value.is_a?(Hash)
240
+ {}.tap do |hash|
241
+ value.each { |k, v| hash[k] = _to_hash(v) }
242
+ end
243
+ elsif value.respond_to?(:to_hash)
244
+ value.to_hash
245
+ else
246
+ value
247
+ end
248
+ end
249
+
250
+ end
251
+
252
+ end
253
+ end