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

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.
@@ -10,7 +10,8 @@ module Algolia
10
10
  # Universally unique identifier (UUID) of a destination resource.
11
11
  attr_accessor :destination_id
12
12
 
13
- attr_accessor :trigger
13
+ # Cron expression for the task's schedule.
14
+ attr_accessor :cron
14
15
 
15
16
  attr_accessor :input
16
17
 
@@ -24,7 +25,7 @@ module Algolia
24
25
  def self.attribute_map
25
26
  {
26
27
  :destination_id => :destinationID,
27
- :trigger => :trigger,
28
+ :cron => :cron,
28
29
  :input => :input,
29
30
  :enabled => :enabled,
30
31
  :failure_threshold => :failureThreshold
@@ -40,7 +41,7 @@ module Algolia
40
41
  def self.types_mapping
41
42
  {
42
43
  :destination_id => :"String",
43
- :trigger => :"TriggerUpdateInput",
44
+ :cron => :"String",
44
45
  :input => :"TaskInput",
45
46
  :enabled => :"Boolean",
46
47
  :failure_threshold => :"Integer"
@@ -81,8 +82,8 @@ module Algolia
81
82
  self.destination_id = attributes[:destination_id]
82
83
  end
83
84
 
84
- if attributes.key?(:trigger)
85
- self.trigger = attributes[:trigger]
85
+ if attributes.key?(:cron)
86
+ self.cron = attributes[:cron]
86
87
  end
87
88
 
88
89
  if attributes.key?(:input)
@@ -122,7 +123,7 @@ module Algolia
122
123
  return true if self.equal?(other)
123
124
  self.class == other.class &&
124
125
  destination_id == other.destination_id &&
125
- trigger == other.trigger &&
126
+ cron == other.cron &&
126
127
  input == other.input &&
127
128
  enabled == other.enabled &&
128
129
  failure_threshold == other.failure_threshold
@@ -137,7 +138,7 @@ module Algolia
137
138
  # Calculates hash code according to all attributes.
138
139
  # @return [Integer] Hash code
139
140
  def hash
140
- [destination_id, trigger, input, enabled, failure_threshold].hash
141
+ [destination_id, cron, input, enabled, failure_threshold].hash
141
142
  end
142
143
 
143
144
  # Builds the object from hash
@@ -0,0 +1,269 @@
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 Ingestion
8
+ # API request body for updating a task using the V1 shape, please use methods and types that don't contain the V1 suffix.
9
+ class TaskUpdateV1
10
+ # Universally unique identifier (UUID) of a destination resource.
11
+ attr_accessor :destination_id
12
+
13
+ attr_accessor :trigger
14
+
15
+ attr_accessor :input
16
+
17
+ # Whether the task is enabled.
18
+ attr_accessor :enabled
19
+
20
+ # Maximum accepted percentage of failures for a task run to finish successfully.
21
+ attr_accessor :failure_threshold
22
+
23
+ # Attribute mapping from ruby-style variable name to JSON key.
24
+ def self.attribute_map
25
+ {
26
+ :destination_id => :destinationID,
27
+ :trigger => :trigger,
28
+ :input => :input,
29
+ :enabled => :enabled,
30
+ :failure_threshold => :failureThreshold
31
+ }
32
+ end
33
+
34
+ # Returns all the JSON keys this model knows about
35
+ def self.acceptable_attributes
36
+ attribute_map.values
37
+ end
38
+
39
+ # Attribute type mapping.
40
+ def self.types_mapping
41
+ {
42
+ :destination_id => :"String",
43
+ :trigger => :"TriggerUpdateInput",
44
+ :input => :"TaskInput",
45
+ :enabled => :"Boolean",
46
+ :failure_threshold => :"Integer"
47
+ }
48
+ end
49
+
50
+ # List of attributes with nullable: true
51
+ def self.openapi_nullable
52
+ Set.new(
53
+ []
54
+ )
55
+ end
56
+
57
+ # Initializes the object
58
+ # @param [Hash] attributes Model attributes in the form of hash
59
+ def initialize(attributes = {})
60
+ if (!attributes.is_a?(Hash))
61
+ raise(
62
+ ArgumentError,
63
+ "The input argument (attributes) must be a hash in `Algolia::TaskUpdateV1` initialize method"
64
+ )
65
+ end
66
+
67
+ # check to see if the attribute exists and convert string to symbol for hash key
68
+ attributes = attributes.each_with_object({}) { |(k, v), h|
69
+ if (!self.class.attribute_map.key?(k.to_sym))
70
+ raise(
71
+ ArgumentError,
72
+ "`#{k}` is not a valid attribute in `Algolia::TaskUpdateV1`. Please check the name to make sure it's valid. List of attributes: " +
73
+ self.class.attribute_map.keys.inspect
74
+ )
75
+ end
76
+
77
+ h[k.to_sym] = v
78
+ }
79
+
80
+ if attributes.key?(:destination_id)
81
+ self.destination_id = attributes[:destination_id]
82
+ end
83
+
84
+ if attributes.key?(:trigger)
85
+ self.trigger = attributes[:trigger]
86
+ end
87
+
88
+ if attributes.key?(:input)
89
+ self.input = attributes[:input]
90
+ end
91
+
92
+ if attributes.key?(:enabled)
93
+ self.enabled = attributes[:enabled]
94
+ end
95
+
96
+ if attributes.key?(:failure_threshold)
97
+ self.failure_threshold = attributes[:failure_threshold]
98
+ end
99
+ end
100
+
101
+ # Custom attribute writer method with validation
102
+ # @param [Object] failure_threshold Value to be assigned
103
+ def failure_threshold=(failure_threshold)
104
+ if failure_threshold.nil?
105
+ raise ArgumentError, "failure_threshold cannot be nil"
106
+ end
107
+
108
+ if failure_threshold > 100
109
+ raise ArgumentError, "invalid value for \"failure_threshold\", must be smaller than or equal to 100."
110
+ end
111
+
112
+ if failure_threshold < 0
113
+ raise ArgumentError, "invalid value for \"failure_threshold\", must be greater than or equal to 0."
114
+ end
115
+
116
+ @failure_threshold = failure_threshold
117
+ end
118
+
119
+ # Checks equality by comparing each attribute.
120
+ # @param [Object] Object to be compared
121
+ def ==(other)
122
+ return true if self.equal?(other)
123
+ self.class == other.class &&
124
+ destination_id == other.destination_id &&
125
+ trigger == other.trigger &&
126
+ input == other.input &&
127
+ enabled == other.enabled &&
128
+ failure_threshold == other.failure_threshold
129
+ end
130
+
131
+ # @see the `==` method
132
+ # @param [Object] Object to be compared
133
+ def eql?(other)
134
+ self == other
135
+ end
136
+
137
+ # Calculates hash code according to all attributes.
138
+ # @return [Integer] Hash code
139
+ def hash
140
+ [destination_id, trigger, input, enabled, failure_threshold].hash
141
+ end
142
+
143
+ # Builds the object from hash
144
+ # @param [Hash] attributes Model attributes in the form of hash
145
+ # @return [Object] Returns the model itself
146
+ def self.build_from_hash(attributes)
147
+ return nil unless attributes.is_a?(Hash)
148
+ attributes = attributes.transform_keys(&:to_sym)
149
+ transformed_hash = {}
150
+ types_mapping.each_pair do |key, type|
151
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
152
+ transformed_hash[key.to_sym] = nil
153
+ elsif type =~ /\AArray<(.*)>/i
154
+ # check to ensure the input is an array given that the attribute
155
+ # is documented as an array but the input is not
156
+ if attributes[attribute_map[key]].is_a?(Array)
157
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
158
+ _deserialize(::Regexp.last_match(1), v)
159
+ }
160
+ end
161
+ elsif !attributes[attribute_map[key]].nil?
162
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
163
+ end
164
+ end
165
+
166
+ new(transformed_hash)
167
+ end
168
+
169
+ # Deserializes the data based on type
170
+ # @param string type Data type
171
+ # @param string value Value to be deserialized
172
+ # @return [Object] Deserialized data
173
+ def self._deserialize(type, value)
174
+ case type.to_sym
175
+ when :Time
176
+ Time.parse(value)
177
+ when :Date
178
+ Date.parse(value)
179
+ when :String
180
+ value.to_s
181
+ when :Integer
182
+ value.to_i
183
+ when :Float
184
+ value.to_f
185
+ when :Boolean
186
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
187
+ true
188
+ else
189
+ false
190
+ end
191
+
192
+ when :Object
193
+ # generic object (usually a Hash), return directly
194
+ value
195
+ when /\AArray<(?<inner_type>.+)>\z/
196
+ inner_type = Regexp.last_match[:inner_type]
197
+ value.map { |v| _deserialize(inner_type, v) }
198
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
199
+ k_type = Regexp.last_match[:k_type]
200
+ v_type = Regexp.last_match[:v_type]
201
+ {}.tap do |hash|
202
+ value.each do |k, v|
203
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
204
+ end
205
+ end
206
+ # model
207
+ else
208
+ # models (e.g. Pet) or oneOf
209
+ klass = Algolia::Ingestion.const_get(type)
210
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
211
+ .build_from_hash(value)
212
+ end
213
+ end
214
+
215
+ # Returns the string representation of the object
216
+ # @return [String] String presentation of the object
217
+ def to_s
218
+ to_hash.to_s
219
+ end
220
+
221
+ # to_body is an alias to to_hash (backward compatibility)
222
+ # @return [Hash] Returns the object in the form of hash
223
+ def to_body
224
+ to_hash
225
+ end
226
+
227
+ def to_json(*_args)
228
+ to_hash.to_json
229
+ end
230
+
231
+ # Returns the object in the form of hash
232
+ # @return [Hash] Returns the object in the form of hash
233
+ def to_hash
234
+ hash = {}
235
+ self.class.attribute_map.each_pair do |attr, param|
236
+ value = send(attr)
237
+ if value.nil?
238
+ is_nullable = self.class.openapi_nullable.include?(attr)
239
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
240
+ end
241
+
242
+ hash[param] = _to_hash(value)
243
+ end
244
+
245
+ hash
246
+ end
247
+
248
+ # Outputs non-array value in the form of hash
249
+ # For object, use to_hash. Otherwise, just return the value
250
+ # @param [Object] value Any valid value
251
+ # @return [Hash] Returns the value in the form of hash
252
+ def _to_hash(value)
253
+ if value.is_a?(Array)
254
+ value.compact.map { |v| _to_hash(v) }
255
+ elsif value.is_a?(Hash)
256
+ {}.tap do |hash|
257
+ value.each { |k, v| hash[k] = _to_hash(v) }
258
+ end
259
+ elsif value.respond_to?(:to_hash)
260
+ value.to_hash
261
+ else
262
+ value
263
+ end
264
+ end
265
+
266
+ end
267
+
268
+ end
269
+ end
@@ -0,0 +1,373 @@
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 Ingestion
8
+ # The V1 task object, please use methods and types that don't contain the V1 suffix.
9
+ class TaskV1
10
+ # Universally unique identifier (UUID) of a task.
11
+ attr_accessor :task_id
12
+
13
+ # Universally uniqud identifier (UUID) of a source.
14
+ attr_accessor :source_id
15
+
16
+ # Universally unique identifier (UUID) of a destination resource.
17
+ attr_accessor :destination_id
18
+
19
+ attr_accessor :trigger
20
+
21
+ attr_accessor :input
22
+
23
+ # Whether the task is enabled.
24
+ attr_accessor :enabled
25
+
26
+ # Maximum accepted percentage of failures for a task run to finish successfully.
27
+ attr_accessor :failure_threshold
28
+
29
+ attr_accessor :action
30
+
31
+ # Date of the last cursor in RFC 3339 format.
32
+ attr_accessor :cursor
33
+
34
+ # Date of creation in RFC 3339 format.
35
+ attr_accessor :created_at
36
+
37
+ # Date of last update in RFC 3339 format.
38
+ attr_accessor :updated_at
39
+
40
+ class EnumAttributeValidator
41
+ attr_reader :datatype
42
+ attr_reader :allowable_values
43
+
44
+ def initialize(datatype, allowable_values)
45
+ @allowable_values = allowable_values.map do |value|
46
+ case datatype.to_s
47
+ when /Integer/i
48
+ value.to_i
49
+ when /Float/i
50
+ value.to_f
51
+ else
52
+ value
53
+ end
54
+ end
55
+ end
56
+
57
+ def valid?(value)
58
+ !value || allowable_values.include?(value)
59
+ end
60
+ end
61
+
62
+ # Attribute mapping from ruby-style variable name to JSON key.
63
+ def self.attribute_map
64
+ {
65
+ :task_id => :taskID,
66
+ :source_id => :sourceID,
67
+ :destination_id => :destinationID,
68
+ :trigger => :trigger,
69
+ :input => :input,
70
+ :enabled => :enabled,
71
+ :failure_threshold => :failureThreshold,
72
+ :action => :action,
73
+ :cursor => :cursor,
74
+ :created_at => :createdAt,
75
+ :updated_at => :updatedAt
76
+ }
77
+ end
78
+
79
+ # Returns all the JSON keys this model knows about
80
+ def self.acceptable_attributes
81
+ attribute_map.values
82
+ end
83
+
84
+ # Attribute type mapping.
85
+ def self.types_mapping
86
+ {
87
+ :task_id => :"String",
88
+ :source_id => :"String",
89
+ :destination_id => :"String",
90
+ :trigger => :"Trigger",
91
+ :input => :"TaskInput",
92
+ :enabled => :"Boolean",
93
+ :failure_threshold => :"Integer",
94
+ :action => :"ActionType",
95
+ :cursor => :"String",
96
+ :created_at => :"String",
97
+ :updated_at => :"String"
98
+ }
99
+ end
100
+
101
+ # List of attributes with nullable: true
102
+ def self.openapi_nullable
103
+ Set.new(
104
+ []
105
+ )
106
+ end
107
+
108
+ # Initializes the object
109
+ # @param [Hash] attributes Model attributes in the form of hash
110
+ def initialize(attributes = {})
111
+ if (!attributes.is_a?(Hash))
112
+ raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::TaskV1` initialize method"
113
+ end
114
+
115
+ # check to see if the attribute exists and convert string to symbol for hash key
116
+ attributes = attributes.each_with_object({}) { |(k, v), h|
117
+ if (!self.class.attribute_map.key?(k.to_sym))
118
+ raise(
119
+ ArgumentError,
120
+ "`#{k}` is not a valid attribute in `Algolia::TaskV1`. Please check the name to make sure it's valid. List of attributes: " +
121
+ self.class.attribute_map.keys.inspect
122
+ )
123
+ end
124
+
125
+ h[k.to_sym] = v
126
+ }
127
+
128
+ if attributes.key?(:task_id)
129
+ self.task_id = attributes[:task_id]
130
+ else
131
+ self.task_id = nil
132
+ end
133
+
134
+ if attributes.key?(:source_id)
135
+ self.source_id = attributes[:source_id]
136
+ else
137
+ self.source_id = nil
138
+ end
139
+
140
+ if attributes.key?(:destination_id)
141
+ self.destination_id = attributes[:destination_id]
142
+ else
143
+ self.destination_id = nil
144
+ end
145
+
146
+ if attributes.key?(:trigger)
147
+ self.trigger = attributes[:trigger]
148
+ else
149
+ self.trigger = nil
150
+ end
151
+
152
+ if attributes.key?(:input)
153
+ self.input = attributes[:input]
154
+ end
155
+
156
+ if attributes.key?(:enabled)
157
+ self.enabled = attributes[:enabled]
158
+ else
159
+ self.enabled = nil
160
+ end
161
+
162
+ if attributes.key?(:failure_threshold)
163
+ self.failure_threshold = attributes[:failure_threshold]
164
+ end
165
+
166
+ if attributes.key?(:action)
167
+ self.action = attributes[:action]
168
+ else
169
+ self.action = nil
170
+ end
171
+
172
+ if attributes.key?(:cursor)
173
+ self.cursor = attributes[:cursor]
174
+ end
175
+
176
+ if attributes.key?(:created_at)
177
+ self.created_at = attributes[:created_at]
178
+ else
179
+ self.created_at = nil
180
+ end
181
+
182
+ if attributes.key?(:updated_at)
183
+ self.updated_at = attributes[:updated_at]
184
+ end
185
+ end
186
+
187
+ # Custom attribute writer method with validation
188
+ # @param [Object] failure_threshold Value to be assigned
189
+ def failure_threshold=(failure_threshold)
190
+ if failure_threshold.nil?
191
+ raise ArgumentError, "failure_threshold cannot be nil"
192
+ end
193
+
194
+ if failure_threshold > 100
195
+ raise ArgumentError, "invalid value for \"failure_threshold\", must be smaller than or equal to 100."
196
+ end
197
+
198
+ if failure_threshold < 0
199
+ raise ArgumentError, "invalid value for \"failure_threshold\", must be greater than or equal to 0."
200
+ end
201
+
202
+ @failure_threshold = failure_threshold
203
+ end
204
+
205
+ # Checks equality by comparing each attribute.
206
+ # @param [Object] Object to be compared
207
+ def ==(other)
208
+ return true if self.equal?(other)
209
+ self.class == other.class &&
210
+ task_id == other.task_id &&
211
+ source_id == other.source_id &&
212
+ destination_id == other.destination_id &&
213
+ trigger == other.trigger &&
214
+ input == other.input &&
215
+ enabled == other.enabled &&
216
+ failure_threshold == other.failure_threshold &&
217
+ action == other.action &&
218
+ cursor == other.cursor &&
219
+ created_at == other.created_at &&
220
+ updated_at == other.updated_at
221
+ end
222
+
223
+ # @see the `==` method
224
+ # @param [Object] Object to be compared
225
+ def eql?(other)
226
+ self == other
227
+ end
228
+
229
+ # Calculates hash code according to all attributes.
230
+ # @return [Integer] Hash code
231
+ def hash
232
+ [
233
+ task_id,
234
+ source_id,
235
+ destination_id,
236
+ trigger,
237
+ input,
238
+ enabled,
239
+ failure_threshold,
240
+ action,
241
+ cursor,
242
+ created_at,
243
+ updated_at
244
+ ].hash
245
+ end
246
+
247
+ # Builds the object from hash
248
+ # @param [Hash] attributes Model attributes in the form of hash
249
+ # @return [Object] Returns the model itself
250
+ def self.build_from_hash(attributes)
251
+ return nil unless attributes.is_a?(Hash)
252
+ attributes = attributes.transform_keys(&:to_sym)
253
+ transformed_hash = {}
254
+ types_mapping.each_pair do |key, type|
255
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
256
+ transformed_hash[key.to_sym] = nil
257
+ elsif type =~ /\AArray<(.*)>/i
258
+ # check to ensure the input is an array given that the attribute
259
+ # is documented as an array but the input is not
260
+ if attributes[attribute_map[key]].is_a?(Array)
261
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
262
+ _deserialize(::Regexp.last_match(1), v)
263
+ }
264
+ end
265
+ elsif !attributes[attribute_map[key]].nil?
266
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
267
+ end
268
+ end
269
+
270
+ new(transformed_hash)
271
+ end
272
+
273
+ # Deserializes the data based on type
274
+ # @param string type Data type
275
+ # @param string value Value to be deserialized
276
+ # @return [Object] Deserialized data
277
+ def self._deserialize(type, value)
278
+ case type.to_sym
279
+ when :Time
280
+ Time.parse(value)
281
+ when :Date
282
+ Date.parse(value)
283
+ when :String
284
+ value.to_s
285
+ when :Integer
286
+ value.to_i
287
+ when :Float
288
+ value.to_f
289
+ when :Boolean
290
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
291
+ true
292
+ else
293
+ false
294
+ end
295
+
296
+ when :Object
297
+ # generic object (usually a Hash), return directly
298
+ value
299
+ when /\AArray<(?<inner_type>.+)>\z/
300
+ inner_type = Regexp.last_match[:inner_type]
301
+ value.map { |v| _deserialize(inner_type, v) }
302
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
303
+ k_type = Regexp.last_match[:k_type]
304
+ v_type = Regexp.last_match[:v_type]
305
+ {}.tap do |hash|
306
+ value.each do |k, v|
307
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
308
+ end
309
+ end
310
+ # model
311
+ else
312
+ # models (e.g. Pet) or oneOf
313
+ klass = Algolia::Ingestion.const_get(type)
314
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
315
+ .build_from_hash(value)
316
+ end
317
+ end
318
+
319
+ # Returns the string representation of the object
320
+ # @return [String] String presentation of the object
321
+ def to_s
322
+ to_hash.to_s
323
+ end
324
+
325
+ # to_body is an alias to to_hash (backward compatibility)
326
+ # @return [Hash] Returns the object in the form of hash
327
+ def to_body
328
+ to_hash
329
+ end
330
+
331
+ def to_json(*_args)
332
+ to_hash.to_json
333
+ end
334
+
335
+ # Returns the object in the form of hash
336
+ # @return [Hash] Returns the object in the form of hash
337
+ def to_hash
338
+ hash = {}
339
+ self.class.attribute_map.each_pair do |attr, param|
340
+ value = send(attr)
341
+ if value.nil?
342
+ is_nullable = self.class.openapi_nullable.include?(attr)
343
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
344
+ end
345
+
346
+ hash[param] = _to_hash(value)
347
+ end
348
+
349
+ hash
350
+ end
351
+
352
+ # Outputs non-array value in the form of hash
353
+ # For object, use to_hash. Otherwise, just return the value
354
+ # @param [Object] value Any valid value
355
+ # @return [Hash] Returns the value in the form of hash
356
+ def _to_hash(value)
357
+ if value.is_a?(Array)
358
+ value.compact.map { |v| _to_hash(v) }
359
+ elsif value.is_a?(Hash)
360
+ {}.tap do |hash|
361
+ value.each { |k, v| hash[k] = _to_hash(v) }
362
+ end
363
+ elsif value.respond_to?(:to_hash)
364
+ value.to_hash
365
+ else
366
+ value
367
+ end
368
+ end
369
+
370
+ end
371
+
372
+ end
373
+ end