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