algolia 3.0.0.beta.10 → 3.0.0.beta.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,212 @@
1
+ # 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.
2
+
3
+ require "date"
4
+ require "time"
5
+
6
+ module Algolia
7
+ module Search
8
+ class WithPrimary
9
+ # Replica indices only: the name of the primary index for this replica.
10
+ attr_accessor :primary
11
+
12
+ # Attribute mapping from ruby-style variable name to JSON key.
13
+ def self.attribute_map
14
+ {
15
+ :primary => :primary
16
+ }
17
+ end
18
+
19
+ # Returns all the JSON keys this model knows about
20
+ def self.acceptable_attributes
21
+ attribute_map.values
22
+ end
23
+
24
+ # Attribute type mapping.
25
+ def self.types_mapping
26
+ {
27
+ :primary => :"String"
28
+ }
29
+ end
30
+
31
+ # List of attributes with nullable: true
32
+ def self.openapi_nullable
33
+ Set.new(
34
+ []
35
+ )
36
+ end
37
+
38
+ # Initializes the object
39
+ # @param [Hash] attributes Model attributes in the form of hash
40
+ def initialize(attributes = {})
41
+ if (!attributes.is_a?(Hash))
42
+ raise(
43
+ ArgumentError,
44
+ "The input argument (attributes) must be a hash in `Algolia::WithPrimary` initialize method"
45
+ )
46
+ end
47
+
48
+ # check to see if the attribute exists and convert string to symbol for hash key
49
+ attributes = attributes.each_with_object({}) { |(k, v), h|
50
+ if (!self.class.attribute_map.key?(k.to_sym))
51
+ raise(
52
+ ArgumentError,
53
+ "`#{k}` is not a valid attribute in `Algolia::WithPrimary`. Please check the name to make sure it's valid. List of attributes: " +
54
+ self.class.attribute_map.keys.inspect
55
+ )
56
+ end
57
+
58
+ h[k.to_sym] = v
59
+ }
60
+
61
+ if attributes.key?(:primary)
62
+ self.primary = attributes[:primary]
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
+ primary == other.primary
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
+ [primary].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
+
209
+ end
210
+
211
+ end
212
+ end
@@ -39,6 +39,8 @@ module Algolia
39
39
  # @return [Response] response of the request
40
40
  #
41
41
  def request(call_type, method, path, body, opts = {})
42
+ retry_errors = []
43
+
42
44
  @retry_strategy.get_tryable_hosts(call_type).each do |host|
43
45
  opts[:timeout] ||= get_timeout(call_type) * (host.retry_count + 1)
44
46
  opts[:connect_timeout] ||= @config.connect_timeout * (host.retry_count + 1)
@@ -71,10 +73,14 @@ module Algolia
71
73
  raise Algolia::AlgoliaHttpError.new(response.status, decoded_error[:message])
72
74
  end
73
75
 
74
- return response unless outcome == RETRY
76
+ if outcome == RETRY
77
+ retry_errors << {host: host.url, error: response.error}
78
+ else
79
+ return response
80
+ end
75
81
  end
76
82
 
77
- raise Algolia::AlgoliaUnreachableHostError, "Unreachable hosts"
83
+ raise Algolia::AlgoliaUnreachableHostError.new("Unreachable hosts.", retry_errors)
78
84
  end
79
85
 
80
86
  private
@@ -1,5 +1,5 @@
1
1
  # 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.
2
2
 
3
3
  module Algolia
4
- VERSION = "3.0.0.beta.10".freeze
4
+ VERSION = "3.0.0.beta.11".freeze
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: algolia
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.beta.10
4
+ version: 3.0.0.beta.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - https://alg.li/support
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-19 00:00:00.000000000 Z
11
+ date: 2024-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -218,6 +218,7 @@ files:
218
218
  - lib/algolia/models/analytics/top_searches_response.rb
219
219
  - lib/algolia/models/analytics/top_searches_response_with_analytics.rb
220
220
  - lib/algolia/models/analytics/top_searches_response_with_revenue_analytics.rb
221
+ - lib/algolia/models/ingestion/action.rb
221
222
  - lib/algolia/models/ingestion/action_type.rb
222
223
  - lib/algolia/models/ingestion/auth_algolia.rb
223
224
  - lib/algolia/models/ingestion/auth_algolia_insights.rb
@@ -241,6 +242,8 @@ files:
241
242
  - lib/algolia/models/ingestion/authentication_type.rb
242
243
  - lib/algolia/models/ingestion/authentication_update.rb
243
244
  - lib/algolia/models/ingestion/authentication_update_response.rb
245
+ - lib/algolia/models/ingestion/batch_request.rb
246
+ - lib/algolia/models/ingestion/batch_write_params.rb
244
247
  - lib/algolia/models/ingestion/big_commerce_channel.rb
245
248
  - lib/algolia/models/ingestion/big_commerce_metafield.rb
246
249
  - lib/algolia/models/ingestion/big_query_data_type.rb
@@ -270,6 +273,7 @@ files:
270
273
  - lib/algolia/models/ingestion/list_events_response.rb
271
274
  - lib/algolia/models/ingestion/list_sources_response.rb
272
275
  - lib/algolia/models/ingestion/list_tasks_response.rb
276
+ - lib/algolia/models/ingestion/list_tasks_response_v1.rb
273
277
  - lib/algolia/models/ingestion/list_transformations_response.rb
274
278
  - lib/algolia/models/ingestion/mapping_field_directive.rb
275
279
  - lib/algolia/models/ingestion/mapping_format_schema.rb
@@ -334,11 +338,14 @@ files:
334
338
  - lib/algolia/models/ingestion/task_create.rb
335
339
  - lib/algolia/models/ingestion/task_create_response.rb
336
340
  - lib/algolia/models/ingestion/task_create_trigger.rb
341
+ - lib/algolia/models/ingestion/task_create_v1.rb
337
342
  - lib/algolia/models/ingestion/task_input.rb
338
343
  - lib/algolia/models/ingestion/task_search.rb
339
344
  - lib/algolia/models/ingestion/task_sort_keys.rb
340
345
  - lib/algolia/models/ingestion/task_update.rb
341
346
  - lib/algolia/models/ingestion/task_update_response.rb
347
+ - lib/algolia/models/ingestion/task_update_v1.rb
348
+ - lib/algolia/models/ingestion/task_v1.rb
342
349
  - lib/algolia/models/ingestion/transformation.rb
343
350
  - lib/algolia/models/ingestion/transformation_create.rb
344
351
  - lib/algolia/models/ingestion/transformation_create_response.rb
@@ -664,6 +671,7 @@ files:
664
671
  - lib/algolia/models/search/search_user_ids_response.rb
665
672
  - lib/algolia/models/search/secured_api_key_restrictions.rb
666
673
  - lib/algolia/models/search/semantic_search.rb
674
+ - lib/algolia/models/search/settings_response.rb
667
675
  - lib/algolia/models/search/snippet_result.rb
668
676
  - lib/algolia/models/search/snippet_result_option.rb
669
677
  - lib/algolia/models/search/sort_remaining_by.rb
@@ -685,6 +693,7 @@ files:
685
693
  - lib/algolia/models/search/user_hit.rb
686
694
  - lib/algolia/models/search/user_id.rb
687
695
  - lib/algolia/models/search/value.rb
696
+ - lib/algolia/models/search/with_primary.rb
688
697
  - lib/algolia/models/usage/error_base.rb
689
698
  - lib/algolia/models/usage/get_usage200_response.rb
690
699
  - lib/algolia/models/usage/get_usage200_response_statistics_inner.rb