algolia 3.0.0.beta.12 → 3.0.0.beta.14

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,259 @@
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
+ class DockerStreams
9
+ # The name of the stream to fetch the data from (e.g. table name).
10
+ attr_accessor :name
11
+
12
+ # The properties of the stream to select (e.g. column).
13
+ attr_accessor :properties
14
+
15
+ attr_accessor :sync_mode
16
+
17
+ class EnumAttributeValidator
18
+ attr_reader :datatype
19
+ attr_reader :allowable_values
20
+
21
+ def initialize(datatype, allowable_values)
22
+ @allowable_values = allowable_values.map do |value|
23
+ case datatype.to_s
24
+ when /Integer/i
25
+ value.to_i
26
+ when /Float/i
27
+ value.to_f
28
+ else
29
+ value
30
+ end
31
+ end
32
+ end
33
+
34
+ def valid?(value)
35
+ !value || allowable_values.include?(value)
36
+ end
37
+ end
38
+
39
+ # Attribute mapping from ruby-style variable name to JSON key.
40
+ def self.attribute_map
41
+ {
42
+ :name => :name,
43
+ :properties => :properties,
44
+ :sync_mode => :syncMode
45
+ }
46
+ end
47
+
48
+ # Returns all the JSON keys this model knows about
49
+ def self.acceptable_attributes
50
+ attribute_map.values
51
+ end
52
+
53
+ # Attribute type mapping.
54
+ def self.types_mapping
55
+ {
56
+ :name => :"String",
57
+ :properties => :"Array<String>",
58
+ :sync_mode => :"DockerStreamsSyncMode"
59
+ }
60
+ end
61
+
62
+ # List of attributes with nullable: true
63
+ def self.openapi_nullable
64
+ Set.new(
65
+ []
66
+ )
67
+ end
68
+
69
+ # Initializes the object
70
+ # @param [Hash] attributes Model attributes in the form of hash
71
+ def initialize(attributes = {})
72
+ if (!attributes.is_a?(Hash))
73
+ raise(
74
+ ArgumentError,
75
+ "The input argument (attributes) must be a hash in `Algolia::DockerStreams` initialize method"
76
+ )
77
+ end
78
+
79
+ # check to see if the attribute exists and convert string to symbol for hash key
80
+ attributes = attributes.each_with_object({}) { |(k, v), h|
81
+ if (!self.class.attribute_map.key?(k.to_sym))
82
+ raise(
83
+ ArgumentError,
84
+ "`#{k}` is not a valid attribute in `Algolia::DockerStreams`. Please check the name to make sure it's valid. List of attributes: " +
85
+ self.class.attribute_map.keys.inspect
86
+ )
87
+ end
88
+
89
+ h[k.to_sym] = v
90
+ }
91
+
92
+ if attributes.key?(:name)
93
+ self.name = attributes[:name]
94
+ else
95
+ self.name = nil
96
+ end
97
+
98
+ if attributes.key?(:properties)
99
+ if (value = attributes[:properties]).is_a?(Array)
100
+ self.properties = value
101
+ end
102
+ end
103
+
104
+ if attributes.key?(:sync_mode)
105
+ self.sync_mode = attributes[:sync_mode]
106
+ else
107
+ self.sync_mode = nil
108
+ end
109
+ end
110
+
111
+ # Checks equality by comparing each attribute.
112
+ # @param [Object] Object to be compared
113
+ def ==(other)
114
+ return true if self.equal?(other)
115
+ self.class == other.class &&
116
+ name == other.name &&
117
+ properties == other.properties &&
118
+ sync_mode == other.sync_mode
119
+ end
120
+
121
+ # @see the `==` method
122
+ # @param [Object] Object to be compared
123
+ def eql?(other)
124
+ self == other
125
+ end
126
+
127
+ # Calculates hash code according to all attributes.
128
+ # @return [Integer] Hash code
129
+ def hash
130
+ [name, properties, sync_mode].hash
131
+ end
132
+
133
+ # Builds the object from hash
134
+ # @param [Hash] attributes Model attributes in the form of hash
135
+ # @return [Object] Returns the model itself
136
+ def self.build_from_hash(attributes)
137
+ return nil unless attributes.is_a?(Hash)
138
+ attributes = attributes.transform_keys(&:to_sym)
139
+ transformed_hash = {}
140
+ types_mapping.each_pair do |key, type|
141
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
142
+ transformed_hash[key.to_sym] = nil
143
+ elsif type =~ /\AArray<(.*)>/i
144
+ # check to ensure the input is an array given that the attribute
145
+ # is documented as an array but the input is not
146
+ if attributes[attribute_map[key]].is_a?(Array)
147
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
148
+ _deserialize(::Regexp.last_match(1), v)
149
+ }
150
+ end
151
+ elsif !attributes[attribute_map[key]].nil?
152
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
153
+ end
154
+ end
155
+
156
+ new(transformed_hash)
157
+ end
158
+
159
+ # Deserializes the data based on type
160
+ # @param string type Data type
161
+ # @param string value Value to be deserialized
162
+ # @return [Object] Deserialized data
163
+ def self._deserialize(type, value)
164
+ case type.to_sym
165
+ when :Time
166
+ Time.parse(value)
167
+ when :Date
168
+ Date.parse(value)
169
+ when :String
170
+ value.to_s
171
+ when :Integer
172
+ value.to_i
173
+ when :Float
174
+ value.to_f
175
+ when :Boolean
176
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
177
+ true
178
+ else
179
+ false
180
+ end
181
+
182
+ when :Object
183
+ # generic object (usually a Hash), return directly
184
+ value
185
+ when /\AArray<(?<inner_type>.+)>\z/
186
+ inner_type = Regexp.last_match[:inner_type]
187
+ value.map { |v| _deserialize(inner_type, v) }
188
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
189
+ k_type = Regexp.last_match[:k_type]
190
+ v_type = Regexp.last_match[:v_type]
191
+ {}.tap do |hash|
192
+ value.each do |k, v|
193
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
194
+ end
195
+ end
196
+ # model
197
+ else
198
+ # models (e.g. Pet) or oneOf
199
+ klass = Algolia::Ingestion.const_get(type)
200
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
201
+ .build_from_hash(value)
202
+ end
203
+ end
204
+
205
+ # Returns the string representation of the object
206
+ # @return [String] String presentation of the object
207
+ def to_s
208
+ to_hash.to_s
209
+ end
210
+
211
+ # to_body is an alias to to_hash (backward compatibility)
212
+ # @return [Hash] Returns the object in the form of hash
213
+ def to_body
214
+ to_hash
215
+ end
216
+
217
+ def to_json(*_args)
218
+ to_hash.to_json
219
+ end
220
+
221
+ # Returns the object in the form of hash
222
+ # @return [Hash] Returns the object in the form of hash
223
+ def to_hash
224
+ hash = {}
225
+ self.class.attribute_map.each_pair do |attr, param|
226
+ value = send(attr)
227
+ if value.nil?
228
+ is_nullable = self.class.openapi_nullable.include?(attr)
229
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
230
+ end
231
+
232
+ hash[param] = _to_hash(value)
233
+ end
234
+
235
+ hash
236
+ end
237
+
238
+ # Outputs non-array value in the form of hash
239
+ # For object, use to_hash. Otherwise, just return the value
240
+ # @param [Object] value Any valid value
241
+ # @return [Hash] Returns the value in the form of hash
242
+ def _to_hash(value)
243
+ if value.is_a?(Array)
244
+ value.compact.map { |v| _to_hash(v) }
245
+ elsif value.is_a?(Hash)
246
+ {}.tap do |hash|
247
+ value.each { |k, v| hash[k] = _to_hash(v) }
248
+ end
249
+ elsif value.respond_to?(:to_hash)
250
+ value.to_hash
251
+ else
252
+ value
253
+ end
254
+ end
255
+
256
+ end
257
+
258
+ end
259
+ end
@@ -24,7 +24,7 @@ module Algolia
24
24
  # Attribute type mapping.
25
25
  def self.types_mapping
26
26
  {
27
- :streams => :"Object"
27
+ :streams => :"Array<DockerStreams>"
28
28
  }
29
29
  end
30
30
 
@@ -59,7 +59,9 @@ module Algolia
59
59
  }
60
60
 
61
61
  if attributes.key?(:streams)
62
- self.streams = attributes[:streams]
62
+ if (value = attributes[:streams]).is_a?(Array)
63
+ self.streams = value
64
+ end
63
65
  else
64
66
  self.streams = nil
65
67
  end
@@ -0,0 +1,32 @@
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
+ class DockerStreamsSyncMode
9
+ INCREMENTAL = "incremental".freeze
10
+ FULL_TABLE = "fullTable".freeze
11
+
12
+ def self.all_vars
13
+ @all_vars ||= [INCREMENTAL, FULL_TABLE].freeze
14
+ end
15
+
16
+ # Builds the enum from string
17
+ # @param [String] The enum value in the form of the string
18
+ # @return [String] The enum value
19
+ def self.build_from_hash(value)
20
+ new.build_from_hash(value)
21
+ end
22
+
23
+ # Builds the enum from string
24
+ # @param [String] The enum value in the form of the string
25
+ # @return [String] The enum value
26
+ def build_from_hash(value)
27
+ return value if DockerStreamsSyncMode.all_vars.include?(value)
28
+ raise "Invalid ENUM value #{value} for class #DockerStreamsSyncMode"
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,32 @@
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
+ class EntityType
9
+ PRODUCT = "product".freeze
10
+ COLLECTION = "collection".freeze
11
+
12
+ def self.all_vars
13
+ @all_vars ||= [PRODUCT, COLLECTION].freeze
14
+ end
15
+
16
+ # Builds the enum from string
17
+ # @param [String] The enum value in the form of the string
18
+ # @return [String] The enum value
19
+ def self.build_from_hash(value)
20
+ new.build_from_hash(value)
21
+ end
22
+
23
+ # Builds the enum from string
24
+ # @param [String] The enum value in the form of the string
25
+ # @return [String] The enum value
26
+ def build_from_hash(value)
27
+ return value if EntityType.all_vars.include?(value)
28
+ raise "Invalid ENUM value #{value} for class #EntityType"
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,233 @@
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
+ class GenerateTransformationCodePayload
9
+ attr_accessor :id
10
+
11
+ attr_accessor :system_prompt
12
+
13
+ attr_accessor :user_prompt
14
+
15
+ # Attribute mapping from ruby-style variable name to JSON key.
16
+ def self.attribute_map
17
+ {
18
+ :id => :id,
19
+ :system_prompt => :systemPrompt,
20
+ :user_prompt => :userPrompt
21
+ }
22
+ end
23
+
24
+ # Returns all the JSON keys this model knows about
25
+ def self.acceptable_attributes
26
+ attribute_map.values
27
+ end
28
+
29
+ # Attribute type mapping.
30
+ def self.types_mapping
31
+ {
32
+ :id => :"String",
33
+ :system_prompt => :"String",
34
+ :user_prompt => :"String"
35
+ }
36
+ end
37
+
38
+ # List of attributes with nullable: true
39
+ def self.openapi_nullable
40
+ Set.new(
41
+ []
42
+ )
43
+ end
44
+
45
+ # Initializes the object
46
+ # @param [Hash] attributes Model attributes in the form of hash
47
+ def initialize(attributes = {})
48
+ if (!attributes.is_a?(Hash))
49
+ raise(
50
+ ArgumentError,
51
+ "The input argument (attributes) must be a hash in `Algolia::GenerateTransformationCodePayload` initialize method"
52
+ )
53
+ end
54
+
55
+ # check to see if the attribute exists and convert string to symbol for hash key
56
+ attributes = attributes.each_with_object({}) { |(k, v), h|
57
+ if (!self.class.attribute_map.key?(k.to_sym))
58
+ raise(
59
+ ArgumentError,
60
+ "`#{k}` is not a valid attribute in `Algolia::GenerateTransformationCodePayload`. Please check the name to make sure it's valid. List of attributes: " +
61
+ self.class.attribute_map.keys.inspect
62
+ )
63
+ end
64
+
65
+ h[k.to_sym] = v
66
+ }
67
+
68
+ if attributes.key?(:id)
69
+ self.id = attributes[:id]
70
+ else
71
+ self.id = nil
72
+ end
73
+
74
+ if attributes.key?(:system_prompt)
75
+ self.system_prompt = attributes[:system_prompt]
76
+ end
77
+
78
+ if attributes.key?(:user_prompt)
79
+ self.user_prompt = attributes[:user_prompt]
80
+ else
81
+ self.user_prompt = nil
82
+ end
83
+ end
84
+
85
+ # Checks equality by comparing each attribute.
86
+ # @param [Object] Object to be compared
87
+ def ==(other)
88
+ return true if self.equal?(other)
89
+ self.class == other.class &&
90
+ id == other.id &&
91
+ system_prompt == other.system_prompt &&
92
+ user_prompt == other.user_prompt
93
+ end
94
+
95
+ # @see the `==` method
96
+ # @param [Object] Object to be compared
97
+ def eql?(other)
98
+ self == other
99
+ end
100
+
101
+ # Calculates hash code according to all attributes.
102
+ # @return [Integer] Hash code
103
+ def hash
104
+ [id, system_prompt, user_prompt].hash
105
+ end
106
+
107
+ # Builds the object from hash
108
+ # @param [Hash] attributes Model attributes in the form of hash
109
+ # @return [Object] Returns the model itself
110
+ def self.build_from_hash(attributes)
111
+ return nil unless attributes.is_a?(Hash)
112
+ attributes = attributes.transform_keys(&:to_sym)
113
+ transformed_hash = {}
114
+ types_mapping.each_pair do |key, type|
115
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
116
+ transformed_hash[key.to_sym] = nil
117
+ elsif type =~ /\AArray<(.*)>/i
118
+ # check to ensure the input is an array given that the attribute
119
+ # is documented as an array but the input is not
120
+ if attributes[attribute_map[key]].is_a?(Array)
121
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
122
+ _deserialize(::Regexp.last_match(1), v)
123
+ }
124
+ end
125
+ elsif !attributes[attribute_map[key]].nil?
126
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
127
+ end
128
+ end
129
+
130
+ new(transformed_hash)
131
+ end
132
+
133
+ # Deserializes the data based on type
134
+ # @param string type Data type
135
+ # @param string value Value to be deserialized
136
+ # @return [Object] Deserialized data
137
+ def self._deserialize(type, value)
138
+ case type.to_sym
139
+ when :Time
140
+ Time.parse(value)
141
+ when :Date
142
+ Date.parse(value)
143
+ when :String
144
+ value.to_s
145
+ when :Integer
146
+ value.to_i
147
+ when :Float
148
+ value.to_f
149
+ when :Boolean
150
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
151
+ true
152
+ else
153
+ false
154
+ end
155
+
156
+ when :Object
157
+ # generic object (usually a Hash), return directly
158
+ value
159
+ when /\AArray<(?<inner_type>.+)>\z/
160
+ inner_type = Regexp.last_match[:inner_type]
161
+ value.map { |v| _deserialize(inner_type, v) }
162
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
163
+ k_type = Regexp.last_match[:k_type]
164
+ v_type = Regexp.last_match[:v_type]
165
+ {}.tap do |hash|
166
+ value.each do |k, v|
167
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
168
+ end
169
+ end
170
+ # model
171
+ else
172
+ # models (e.g. Pet) or oneOf
173
+ klass = Algolia::Ingestion.const_get(type)
174
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
175
+ .build_from_hash(value)
176
+ end
177
+ end
178
+
179
+ # Returns the string representation of the object
180
+ # @return [String] String presentation of the object
181
+ def to_s
182
+ to_hash.to_s
183
+ end
184
+
185
+ # to_body is an alias to to_hash (backward compatibility)
186
+ # @return [Hash] Returns the object in the form of hash
187
+ def to_body
188
+ to_hash
189
+ end
190
+
191
+ def to_json(*_args)
192
+ to_hash.to_json
193
+ end
194
+
195
+ # Returns the object in the form of hash
196
+ # @return [Hash] Returns the object in the form of hash
197
+ def to_hash
198
+ hash = {}
199
+ self.class.attribute_map.each_pair do |attr, param|
200
+ value = send(attr)
201
+ if value.nil?
202
+ is_nullable = self.class.openapi_nullable.include?(attr)
203
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
204
+ end
205
+
206
+ hash[param] = _to_hash(value)
207
+ end
208
+
209
+ hash
210
+ end
211
+
212
+ # Outputs non-array value in the form of hash
213
+ # For object, use to_hash. Otherwise, just return the value
214
+ # @param [Object] value Any valid value
215
+ # @return [Hash] Returns the value in the form of hash
216
+ def _to_hash(value)
217
+ if value.is_a?(Array)
218
+ value.compact.map { |v| _to_hash(v) }
219
+ elsif value.is_a?(Hash)
220
+ {}.tap do |hash|
221
+ value.each { |k, v| hash[k] = _to_hash(v) }
222
+ end
223
+ elsif value.respond_to?(:to_hash)
224
+ value.to_hash
225
+ else
226
+ value
227
+ end
228
+ end
229
+
230
+ end
231
+
232
+ end
233
+ end