algolia 3.16.0 → 3.18.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.
@@ -0,0 +1,213 @@
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 Ingestion
10
+ # Input for a no-code transformation that contains a series of steps.
11
+ class TransformationNoCode
12
+ attr_accessor :steps
13
+
14
+ # Attribute mapping from ruby-style variable name to JSON key.
15
+ def self.attribute_map
16
+ {
17
+ :steps => :steps
18
+ }
19
+ end
20
+
21
+ # Attribute type mapping.
22
+ def self.types_mapping
23
+ {
24
+ :steps => :"Array<Object>"
25
+ }
26
+ end
27
+
28
+ # List of attributes with nullable: true
29
+ def self.openapi_nullable
30
+ Set.new(
31
+ []
32
+ )
33
+ end
34
+
35
+ # Initializes the object
36
+ # @param [Hash] attributes Model attributes in the form of hash
37
+ def initialize(attributes = {})
38
+ if (!attributes.is_a?(Hash))
39
+ raise(
40
+ ArgumentError,
41
+ "The input argument (attributes) must be a hash in `Algolia::TransformationNoCode` initialize method"
42
+ )
43
+ end
44
+
45
+ # check to see if the attribute exists and convert string to symbol for hash key
46
+ attributes = attributes.each_with_object({}) { |(k, v), h|
47
+ if (!self.class.attribute_map.key?(k.to_sym))
48
+ raise(
49
+ ArgumentError,
50
+ "`#{k}` is not a valid attribute in `Algolia::TransformationNoCode`. Please check the name to make sure it's valid. List of attributes: " +
51
+ self.class.attribute_map.keys.inspect
52
+ )
53
+ end
54
+
55
+ h[k.to_sym] = v
56
+ }
57
+
58
+ if attributes.key?(:steps)
59
+ if (value = attributes[:steps]).is_a?(Array)
60
+ self.steps = value
61
+ end
62
+ else
63
+ self.steps = nil
64
+ end
65
+ end
66
+
67
+ # Checks equality by comparing each attribute.
68
+ # @param [Object] Object to be compared
69
+ def ==(other)
70
+ return true if self.equal?(other)
71
+ self.class == other.class &&
72
+ steps == other.steps
73
+ end
74
+
75
+ # @see the `==` method
76
+ # @param [Object] Object to be compared
77
+ def eql?(other)
78
+ self == other
79
+ end
80
+
81
+ # Calculates hash code according to all attributes.
82
+ # @return [Integer] Hash code
83
+ def hash
84
+ [steps].hash
85
+ end
86
+
87
+ # Builds the object from hash
88
+ # @param [Hash] attributes Model attributes in the form of hash
89
+ # @return [Object] Returns the model itself
90
+ def self.build_from_hash(attributes)
91
+ return nil unless attributes.is_a?(Hash)
92
+ attributes = attributes.transform_keys(&:to_sym)
93
+ transformed_hash = {}
94
+ types_mapping.each_pair do |key, type|
95
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
96
+ transformed_hash[key.to_sym] = nil
97
+ elsif type =~ /\AArray<(.*)>/i
98
+ # check to ensure the input is an array given that the attribute
99
+ # is documented as an array but the input is not
100
+ if attributes[attribute_map[key]].is_a?(Array)
101
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
102
+ _deserialize(::Regexp.last_match(1), v)
103
+ }
104
+ end
105
+ elsif !attributes[attribute_map[key]].nil?
106
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
107
+ end
108
+ end
109
+
110
+ new(transformed_hash)
111
+ end
112
+
113
+ # Deserializes the data based on type
114
+ # @param string type Data type
115
+ # @param string value Value to be deserialized
116
+ # @return [Object] Deserialized data
117
+ def self._deserialize(type, value)
118
+ case type.to_sym
119
+ when :Time
120
+ Time.parse(value)
121
+ when :Date
122
+ Date.parse(value)
123
+ when :String
124
+ value.to_s
125
+ when :Integer
126
+ value.to_i
127
+ when :Float
128
+ value.to_f
129
+ when :Boolean
130
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
131
+ true
132
+ else
133
+ false
134
+ end
135
+
136
+ when :Object
137
+ # generic object (usually a Hash), return directly
138
+ value
139
+ when /\AArray<(?<inner_type>.+)>\z/
140
+ inner_type = Regexp.last_match[:inner_type]
141
+ value.map { |v| _deserialize(inner_type, v) }
142
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
143
+ k_type = Regexp.last_match[:k_type]
144
+ v_type = Regexp.last_match[:v_type]
145
+ {}.tap do |hash|
146
+ value.each do |k, v|
147
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
148
+ end
149
+ end
150
+ # model
151
+ else
152
+ # models (e.g. Pet) or oneOf
153
+ klass = Algolia::Ingestion.const_get(type)
154
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
155
+ .build_from_hash(value)
156
+ end
157
+ end
158
+
159
+ # Returns the string representation of the object
160
+ # @return [String] String presentation of the object
161
+ def to_s
162
+ to_hash.to_s
163
+ end
164
+
165
+ # to_body is an alias to to_hash (backward compatibility)
166
+ # @return [Hash] Returns the object in the form of hash
167
+ def to_body
168
+ to_hash
169
+ end
170
+
171
+ def to_json(*_args)
172
+ to_hash.to_json
173
+ end
174
+
175
+ # Returns the object in the form of hash
176
+ # @return [Hash] Returns the object in the form of hash
177
+ def to_hash
178
+ hash = {}
179
+ self.class.attribute_map.each_pair do |attr, param|
180
+ value = send(attr)
181
+ if value.nil?
182
+ is_nullable = self.class.openapi_nullable.include?(attr)
183
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
184
+ end
185
+
186
+ hash[param] = _to_hash(value)
187
+ end
188
+
189
+ hash
190
+ end
191
+
192
+ # Outputs non-array value in the form of hash
193
+ # For object, use to_hash. Otherwise, just return the value
194
+ # @param [Object] value Any valid value
195
+ # @return [Hash] Returns the value in the form of hash
196
+ def _to_hash(value)
197
+ if value.is_a?(Array)
198
+ value.compact.map { |v| _to_hash(v) }
199
+ elsif value.is_a?(Hash)
200
+ {}.tap do |hash|
201
+ value.each { |k, v| hash[k] = _to_hash(v) }
202
+ end
203
+ elsif value.respond_to?(:to_hash)
204
+ value.to_hash
205
+ else
206
+ value
207
+ end
208
+ end
209
+
210
+ end
211
+
212
+ end
213
+ end
@@ -8,7 +8,7 @@ require "time"
8
8
  module Algolia
9
9
  module Ingestion
10
10
  class TransformationTry
11
- # The source code of the transformation.
11
+ # It is deprecated. Use the `input` field with proper `type` instead to specify the transformation code.
12
12
  attr_accessor :code
13
13
 
14
14
  # The record to apply the given code to.
@@ -0,0 +1,34 @@
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 Ingestion
10
+ class TransformationType
11
+ CODE = "code".freeze
12
+ NO_CODE = "noCode".freeze
13
+
14
+ def self.all_vars
15
+ @all_vars ||= [CODE, NO_CODE].freeze
16
+ end
17
+
18
+ # Builds the enum from string
19
+ # @param [String] The enum value in the form of the string
20
+ # @return [String] The enum value
21
+ def self.build_from_hash(value)
22
+ new.build_from_hash(value)
23
+ end
24
+
25
+ # Builds the enum from string
26
+ # @param [String] The enum value in the form of the string
27
+ # @return [String] The enum value
28
+ def build_from_hash(value)
29
+ return value if TransformationType.all_vars.include?(value)
30
+ raise "Invalid ENUM value #{value} for class #TransformationType"
31
+ end
32
+ end
33
+ end
34
+ end
@@ -11,22 +11,30 @@ module Algolia
11
11
  # Universally unique identifier (UUID) of a task run.
12
12
  attr_accessor :run_id
13
13
 
14
- # when used with discovering or validating sources, the sampled data of your source is returned.
14
+ # Universally unique identifier (UUID) of an event.
15
+ attr_accessor :event_id
16
+
17
+ # This field is always null when used with the Push endpoint. When used for a source discover or source validate run, it will include the sampled data of the source.
15
18
  attr_accessor :data
16
19
 
17
- # in case of error, observability events will be added to the response, if any.
20
+ # in case of error, observability events will be added to the response.
18
21
  attr_accessor :events
19
22
 
20
- # a message describing the outcome of a validate run.
23
+ # a message describing the outcome of the operation that has been ran (push, discover or validate) run.
21
24
  attr_accessor :message
22
25
 
26
+ # Date of creation in RFC 3339 format.
27
+ attr_accessor :created_at
28
+
23
29
  # Attribute mapping from ruby-style variable name to JSON key.
24
30
  def self.attribute_map
25
31
  {
26
32
  :run_id => :runID,
33
+ :event_id => :eventID,
27
34
  :data => :data,
28
35
  :events => :events,
29
- :message => :message
36
+ :message => :message,
37
+ :created_at => :createdAt
30
38
  }
31
39
  end
32
40
 
@@ -34,9 +42,11 @@ module Algolia
34
42
  def self.types_mapping
35
43
  {
36
44
  :run_id => :"String",
45
+ :event_id => :"String",
37
46
  :data => :"Array<Object>",
38
47
  :events => :"Array<Event>",
39
- :message => :"String"
48
+ :message => :"String",
49
+ :created_at => :"String"
40
50
  }
41
51
  end
42
52
 
@@ -76,6 +86,10 @@ module Algolia
76
86
  self.run_id = nil
77
87
  end
78
88
 
89
+ if attributes.key?(:event_id)
90
+ self.event_id = attributes[:event_id]
91
+ end
92
+
79
93
  if attributes.key?(:data)
80
94
  if (value = attributes[:data]).is_a?(Array)
81
95
  self.data = value
@@ -91,6 +105,10 @@ module Algolia
91
105
  if attributes.key?(:message)
92
106
  self.message = attributes[:message]
93
107
  end
108
+
109
+ if attributes.key?(:created_at)
110
+ self.created_at = attributes[:created_at]
111
+ end
94
112
  end
95
113
 
96
114
  # Checks equality by comparing each attribute.
@@ -99,9 +117,11 @@ module Algolia
99
117
  return true if self.equal?(other)
100
118
  self.class == other.class &&
101
119
  run_id == other.run_id &&
120
+ event_id == other.event_id &&
102
121
  data == other.data &&
103
122
  events == other.events &&
104
- message == other.message
123
+ message == other.message &&
124
+ created_at == other.created_at
105
125
  end
106
126
 
107
127
  # @see the `==` method
@@ -113,7 +133,7 @@ module Algolia
113
133
  # Calculates hash code according to all attributes.
114
134
  # @return [Integer] Hash code
115
135
  def hash
116
- [run_id, data, events, message].hash
136
+ [run_id, event_id, data, events, message, created_at].hash
117
137
  end
118
138
 
119
139
  # Builds the object from hash
@@ -10,9 +10,11 @@ module Algolia
10
10
  class TypoToleranceEnum
11
11
  MIN = "min".freeze
12
12
  STRICT = "strict".freeze
13
+ TRUE = "true".freeze
14
+ FALSE = "false".freeze
13
15
 
14
16
  def self.all_vars
15
- @all_vars ||= [MIN, STRICT].freeze
17
+ @all_vars ||= [MIN, STRICT, TRUE, FALSE].freeze
16
18
  end
17
19
 
18
20
  # Builds the enum from string
@@ -0,0 +1,281 @@
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
+ # An event describe a step of the task execution flow..
11
+ class Event
12
+ # Universally unique identifier (UUID) of an event.
13
+ attr_accessor :event_id
14
+
15
+ # Universally unique identifier (UUID) of a task run.
16
+ attr_accessor :run_id
17
+
18
+ attr_accessor :status
19
+
20
+ attr_accessor :type
21
+
22
+ # The extracted record batch size.
23
+ attr_accessor :batch_size
24
+
25
+ attr_accessor :data
26
+
27
+ # Date of publish RFC 3339 format.
28
+ attr_accessor :published_at
29
+
30
+ # Attribute mapping from ruby-style variable name to JSON key.
31
+ def self.attribute_map
32
+ {
33
+ :event_id => :eventID,
34
+ :run_id => :runID,
35
+ :status => :status,
36
+ :type => :type,
37
+ :batch_size => :batchSize,
38
+ :data => :data,
39
+ :published_at => :publishedAt
40
+ }
41
+ end
42
+
43
+ # Attribute type mapping.
44
+ def self.types_mapping
45
+ {
46
+ :event_id => :"String",
47
+ :run_id => :"String",
48
+ :status => :"EventStatus",
49
+ :type => :"EventType",
50
+ :batch_size => :"Integer",
51
+ :data => :"Hash<String, Object>",
52
+ :published_at => :"String"
53
+ }
54
+ end
55
+
56
+ # List of attributes with nullable: true
57
+ def self.openapi_nullable
58
+ Set.new(
59
+ [
60
+ :status,
61
+ :data
62
+ ]
63
+ )
64
+ end
65
+
66
+ # Initializes the object
67
+ # @param [Hash] attributes Model attributes in the form of hash
68
+ def initialize(attributes = {})
69
+ if (!attributes.is_a?(Hash))
70
+ raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::Event` initialize method"
71
+ end
72
+
73
+ # check to see if the attribute exists and convert string to symbol for hash key
74
+ attributes = attributes.each_with_object({}) { |(k, v), h|
75
+ if (!self.class.attribute_map.key?(k.to_sym))
76
+ raise(
77
+ ArgumentError,
78
+ "`#{k}` is not a valid attribute in `Algolia::Event`. Please check the name to make sure it's valid. List of attributes: " +
79
+ self.class.attribute_map.keys.inspect
80
+ )
81
+ end
82
+
83
+ h[k.to_sym] = v
84
+ }
85
+
86
+ if attributes.key?(:event_id)
87
+ self.event_id = attributes[:event_id]
88
+ else
89
+ self.event_id = nil
90
+ end
91
+
92
+ if attributes.key?(:run_id)
93
+ self.run_id = attributes[:run_id]
94
+ else
95
+ self.run_id = nil
96
+ end
97
+
98
+ if attributes.key?(:status)
99
+ self.status = attributes[:status]
100
+ else
101
+ self.status = nil
102
+ end
103
+
104
+ if attributes.key?(:type)
105
+ self.type = attributes[:type]
106
+ else
107
+ self.type = nil
108
+ end
109
+
110
+ if attributes.key?(:batch_size)
111
+ self.batch_size = attributes[:batch_size]
112
+ else
113
+ self.batch_size = nil
114
+ end
115
+
116
+ if attributes.key?(:data)
117
+ if (value = attributes[:data]).is_a?(Hash)
118
+ self.data = value
119
+ end
120
+ end
121
+
122
+ if attributes.key?(:published_at)
123
+ self.published_at = attributes[:published_at]
124
+ else
125
+ self.published_at = nil
126
+ end
127
+ end
128
+
129
+ # Checks equality by comparing each attribute.
130
+ # @param [Object] Object to be compared
131
+ def ==(other)
132
+ return true if self.equal?(other)
133
+ self.class == other.class &&
134
+ event_id == other.event_id &&
135
+ run_id == other.run_id &&
136
+ status == other.status &&
137
+ type == other.type &&
138
+ batch_size == other.batch_size &&
139
+ data == other.data &&
140
+ published_at == other.published_at
141
+ end
142
+
143
+ # @see the `==` method
144
+ # @param [Object] Object to be compared
145
+ def eql?(other)
146
+ self == other
147
+ end
148
+
149
+ # Calculates hash code according to all attributes.
150
+ # @return [Integer] Hash code
151
+ def hash
152
+ [event_id, run_id, status, type, batch_size, data, published_at].hash
153
+ end
154
+
155
+ # Builds the object from hash
156
+ # @param [Hash] attributes Model attributes in the form of hash
157
+ # @return [Object] Returns the model itself
158
+ def self.build_from_hash(attributes)
159
+ return nil unless attributes.is_a?(Hash)
160
+ attributes = attributes.transform_keys(&:to_sym)
161
+ transformed_hash = {}
162
+ types_mapping.each_pair do |key, type|
163
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
164
+ transformed_hash[key.to_sym] = nil
165
+ elsif type =~ /\AArray<(.*)>/i
166
+ # check to ensure the input is an array given that the attribute
167
+ # is documented as an array but the input is not
168
+ if attributes[attribute_map[key]].is_a?(Array)
169
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
170
+ _deserialize(::Regexp.last_match(1), v)
171
+ }
172
+ end
173
+ elsif !attributes[attribute_map[key]].nil?
174
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
175
+ end
176
+ end
177
+
178
+ new(transformed_hash)
179
+ end
180
+
181
+ # Deserializes the data based on type
182
+ # @param string type Data type
183
+ # @param string value Value to be deserialized
184
+ # @return [Object] Deserialized data
185
+ def self._deserialize(type, value)
186
+ case type.to_sym
187
+ when :Time
188
+ Time.parse(value)
189
+ when :Date
190
+ Date.parse(value)
191
+ when :String
192
+ value.to_s
193
+ when :Integer
194
+ value.to_i
195
+ when :Float
196
+ value.to_f
197
+ when :Boolean
198
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
199
+ true
200
+ else
201
+ false
202
+ end
203
+
204
+ when :Object
205
+ # generic object (usually a Hash), return directly
206
+ value
207
+ when /\AArray<(?<inner_type>.+)>\z/
208
+ inner_type = Regexp.last_match[:inner_type]
209
+ value.map { |v| _deserialize(inner_type, v) }
210
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
211
+ k_type = Regexp.last_match[:k_type]
212
+ v_type = Regexp.last_match[:v_type]
213
+ {}.tap do |hash|
214
+ value.each do |k, v|
215
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
216
+ end
217
+ end
218
+ # model
219
+ else
220
+ # models (e.g. Pet) or oneOf
221
+ klass = Algolia::Search.const_get(type)
222
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
223
+ .build_from_hash(value)
224
+ end
225
+ end
226
+
227
+ # Returns the string representation of the object
228
+ # @return [String] String presentation of the object
229
+ def to_s
230
+ to_hash.to_s
231
+ end
232
+
233
+ # to_body is an alias to to_hash (backward compatibility)
234
+ # @return [Hash] Returns the object in the form of hash
235
+ def to_body
236
+ to_hash
237
+ end
238
+
239
+ def to_json(*_args)
240
+ to_hash.to_json
241
+ end
242
+
243
+ # Returns the object in the form of hash
244
+ # @return [Hash] Returns the object in the form of hash
245
+ def to_hash
246
+ hash = {}
247
+ self.class.attribute_map.each_pair do |attr, param|
248
+ value = send(attr)
249
+ if value.nil?
250
+ is_nullable = self.class.openapi_nullable.include?(attr)
251
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
252
+ end
253
+
254
+ hash[param] = _to_hash(value)
255
+ end
256
+
257
+ hash
258
+ end
259
+
260
+ # Outputs non-array value in the form of hash
261
+ # For object, use to_hash. Otherwise, just return the value
262
+ # @param [Object] value Any valid value
263
+ # @return [Hash] Returns the value in the form of hash
264
+ def _to_hash(value)
265
+ if value.is_a?(Array)
266
+ value.compact.map { |v| _to_hash(v) }
267
+ elsif value.is_a?(Hash)
268
+ {}.tap do |hash|
269
+ value.each { |k, v| hash[k] = _to_hash(v) }
270
+ end
271
+ elsif value.respond_to?(:to_hash)
272
+ value.to_hash
273
+ else
274
+ value
275
+ end
276
+ end
277
+
278
+ end
279
+
280
+ end
281
+ end
@@ -0,0 +1,38 @@
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
+ class EventStatus
11
+ CREATED = "created".freeze
12
+ STARTED = "started".freeze
13
+ RETRIED = "retried".freeze
14
+ FAILED = "failed".freeze
15
+ SUCCEEDED = "succeeded".freeze
16
+ CRITICAL = "critical".freeze
17
+
18
+ def self.all_vars
19
+ @all_vars ||= [CREATED, STARTED, RETRIED, FAILED, SUCCEEDED, CRITICAL].freeze
20
+ end
21
+
22
+ # Builds the enum from string
23
+ # @param [String] The enum value in the form of the string
24
+ # @return [String] The enum value
25
+ def self.build_from_hash(value)
26
+ new.build_from_hash(value)
27
+ end
28
+
29
+ # Builds the enum from string
30
+ # @param [String] The enum value in the form of the string
31
+ # @return [String] The enum value
32
+ def build_from_hash(value)
33
+ return value if EventStatus.all_vars.include?(value)
34
+ raise "Invalid ENUM value #{value} for class #EventStatus"
35
+ end
36
+ end
37
+ end
38
+ end