manticore-client 1.0.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.
Files changed (113) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +39 -0
  3. data/.openapi-generator/FILES +149 -0
  4. data/.openapi-generator/VERSION +1 -0
  5. data/.openapi-generator-ignore +5 -0
  6. data/.rspec +2 -0
  7. data/.rubocop.yml +160 -0
  8. data/Gemfile +12 -0
  9. data/Gemfile.lock +103 -0
  10. data/LICENSE.txt +21 -0
  11. data/README.md +136 -0
  12. data/Rakefile +10 -0
  13. data/docs/AggComposite.md +20 -0
  14. data/docs/AggCompositeSource.md +18 -0
  15. data/docs/AggCompositeTerm.md +18 -0
  16. data/docs/AggTerms.md +20 -0
  17. data/docs/Aggregation.md +22 -0
  18. data/docs/AutocompleteRequest.md +22 -0
  19. data/docs/BoolFilter.md +22 -0
  20. data/docs/BulkResponse.md +26 -0
  21. data/docs/DeleteDocumentRequest.md +24 -0
  22. data/docs/DeleteResponse.md +26 -0
  23. data/docs/ErrorResponse.md +20 -0
  24. data/docs/FulltextFilter.md +24 -0
  25. data/docs/GeoDistance.md +24 -0
  26. data/docs/GeoDistanceLocationAnchor.md +20 -0
  27. data/docs/Highlight.md +62 -0
  28. data/docs/HighlightAllOfFields.md +15 -0
  29. data/docs/HighlightFieldOption.md +26 -0
  30. data/docs/HitsHits.md +22 -0
  31. data/docs/IndexApi.md +401 -0
  32. data/docs/InsertDocumentRequest.md +24 -0
  33. data/docs/Join.md +24 -0
  34. data/docs/JoinCond.md +22 -0
  35. data/docs/JoinOn.md +22 -0
  36. data/docs/KnnQuery.md +28 -0
  37. data/docs/Match.md +22 -0
  38. data/docs/MatchAll.md +18 -0
  39. data/docs/PercolateRequest.md +18 -0
  40. data/docs/PercolateRequestQuery.md +18 -0
  41. data/docs/QueryFilter.md +34 -0
  42. data/docs/Range.md +24 -0
  43. data/docs/ReplaceDocumentRequest.md +18 -0
  44. data/docs/ResponseError.md +49 -0
  45. data/docs/ResponseErrorDetails.md +22 -0
  46. data/docs/SearchApi.md +204 -0
  47. data/docs/SearchQuery.md +36 -0
  48. data/docs/SearchRequest.md +46 -0
  49. data/docs/SearchResponse.md +30 -0
  50. data/docs/SearchResponseHits.md +24 -0
  51. data/docs/SourceRules.md +20 -0
  52. data/docs/SqlResponse.md +49 -0
  53. data/docs/SuccessResponse.md +28 -0
  54. data/docs/UpdateDocumentRequest.md +26 -0
  55. data/docs/UpdateResponse.md +24 -0
  56. data/docs/UtilsApi.md +76 -0
  57. data/lib/manticore/client/api/index_api.rb +442 -0
  58. data/lib/manticore/client/api/search_api.rb +232 -0
  59. data/lib/manticore/client/api/utils_api.rb +93 -0
  60. data/lib/manticore/client/api_client.rb +437 -0
  61. data/lib/manticore/client/api_error.rb +58 -0
  62. data/lib/manticore/client/configuration.rb +385 -0
  63. data/lib/manticore/client/models/agg_composite.rb +233 -0
  64. data/lib/manticore/client/models/agg_composite_source.rb +238 -0
  65. data/lib/manticore/client/models/agg_composite_term.rb +239 -0
  66. data/lib/manticore/client/models/agg_terms.rb +249 -0
  67. data/lib/manticore/client/models/aggregation.rb +240 -0
  68. data/lib/manticore/client/models/autocomplete_request.rb +276 -0
  69. data/lib/manticore/client/models/bool_filter.rb +247 -0
  70. data/lib/manticore/client/models/bulk_response.rb +264 -0
  71. data/lib/manticore/client/models/delete_document_request.rb +269 -0
  72. data/lib/manticore/client/models/delete_response.rb +262 -0
  73. data/lib/manticore/client/models/error_response.rb +250 -0
  74. data/lib/manticore/client/models/fulltext_filter.rb +252 -0
  75. data/lib/manticore/client/models/geo_distance.rb +306 -0
  76. data/lib/manticore/client/models/geo_distance_location_anchor.rb +232 -0
  77. data/lib/manticore/client/models/highlight.rb +525 -0
  78. data/lib/manticore/client/models/highlight_all_of_fields.rb +105 -0
  79. data/lib/manticore/client/models/highlight_field_option.rb +262 -0
  80. data/lib/manticore/client/models/hits_hits.rb +242 -0
  81. data/lib/manticore/client/models/insert_document_request.rb +286 -0
  82. data/lib/manticore/client/models/join.rb +327 -0
  83. data/lib/manticore/client/models/join_cond.rb +276 -0
  84. data/lib/manticore/client/models/join_on.rb +272 -0
  85. data/lib/manticore/client/models/knn_query.rb +307 -0
  86. data/lib/manticore/client/models/match.rb +290 -0
  87. data/lib/manticore/client/models/match_all.rb +262 -0
  88. data/lib/manticore/client/models/percolate_request.rb +238 -0
  89. data/lib/manticore/client/models/percolate_request_query.rb +238 -0
  90. data/lib/manticore/client/models/query_filter.rb +307 -0
  91. data/lib/manticore/client/models/range.rb +252 -0
  92. data/lib/manticore/client/models/replace_document_request.rb +239 -0
  93. data/lib/manticore/client/models/response_error.rb +105 -0
  94. data/lib/manticore/client/models/response_error_details.rb +261 -0
  95. data/lib/manticore/client/models/search_query.rb +316 -0
  96. data/lib/manticore/client/models/search_request.rb +382 -0
  97. data/lib/manticore/client/models/search_response.rb +281 -0
  98. data/lib/manticore/client/models/search_response_hits.rb +254 -0
  99. data/lib/manticore/client/models/source_rules.rb +236 -0
  100. data/lib/manticore/client/models/sql_response.rb +106 -0
  101. data/lib/manticore/client/models/success_response.rb +272 -0
  102. data/lib/manticore/client/models/update_document_request.rb +296 -0
  103. data/lib/manticore/client/models/update_response.rb +252 -0
  104. data/lib/manticore/client/version.rb +7 -0
  105. data/lib/manticore/client.rb +32 -0
  106. data/lib/manticore-client.rb +3 -0
  107. data/manticore-client.gemspec +34 -0
  108. data/spec/api/index_api_spec.rb +179 -0
  109. data/spec/api/search_api_spec.rb +94 -0
  110. data/spec/api/utils_api_spec.rb +100 -0
  111. data/spec/spec_helper.rb +92 -0
  112. data/spec/support/manticore_sql_helper.rb +33 -0
  113. metadata +218 -0
@@ -0,0 +1,382 @@
1
+ =begin
2
+ #Manticore Search Client
3
+
4
+ #Сlient for Manticore Search.
5
+
6
+ The version of the OpenAPI document: 5.0.0
7
+ Contact: info@manticoresearch.com
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.13.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Manticore::Client
17
+ # Request object for search operation
18
+ class SearchRequest
19
+ # The table to perform the search on
20
+ attr_accessor :table
21
+
22
+ attr_accessor :query
23
+
24
+ # Join clause to combine search data from multiple tables
25
+ attr_accessor :join
26
+
27
+ attr_accessor :highlight
28
+
29
+ # Maximum number of results to return
30
+ attr_accessor :limit
31
+
32
+ attr_accessor :knn
33
+
34
+ # Defines aggregation settings for grouping results
35
+ attr_accessor :aggs
36
+
37
+ # Expressions to calculate additional values for the result
38
+ attr_accessor :expressions
39
+
40
+ # Maximum number of matches allowed in the result
41
+ attr_accessor :max_matches
42
+
43
+ # Starting point for pagination of the result
44
+ attr_accessor :offset
45
+
46
+ # Additional search options
47
+ attr_accessor :options
48
+
49
+ # Enable or disable profiling of the search request
50
+ attr_accessor :profile
51
+
52
+ attr_accessor :sort
53
+
54
+ attr_accessor :_source
55
+
56
+ # Enable or disable result weight calculation used for sorting
57
+ attr_accessor :track_scores
58
+
59
+ # Attribute mapping from ruby-style variable name to JSON key.
60
+ def self.attribute_map
61
+ {
62
+ :'table' => :'table',
63
+ :'query' => :'query',
64
+ :'join' => :'join',
65
+ :'highlight' => :'highlight',
66
+ :'limit' => :'limit',
67
+ :'knn' => :'knn',
68
+ :'aggs' => :'aggs',
69
+ :'expressions' => :'expressions',
70
+ :'max_matches' => :'max_matches',
71
+ :'offset' => :'offset',
72
+ :'options' => :'options',
73
+ :'profile' => :'profile',
74
+ :'sort' => :'sort',
75
+ :'_source' => :'_source',
76
+ :'track_scores' => :'track_scores'
77
+ }
78
+ end
79
+
80
+ # Returns attribute mapping this model knows about
81
+ def self.acceptable_attribute_map
82
+ attribute_map
83
+ end
84
+
85
+ # Returns all the JSON keys this model knows about
86
+ def self.acceptable_attributes
87
+ acceptable_attribute_map.values
88
+ end
89
+
90
+ # Attribute type mapping.
91
+ def self.openapi_types
92
+ {
93
+ :'table' => :'String',
94
+ :'query' => :'SearchQuery',
95
+ :'join' => :'Array<Join>',
96
+ :'highlight' => :'Highlight',
97
+ :'limit' => :'Integer',
98
+ :'knn' => :'KnnQuery',
99
+ :'aggs' => :'Hash<String, Aggregation>',
100
+ :'expressions' => :'Hash<String, String>',
101
+ :'max_matches' => :'Integer',
102
+ :'offset' => :'Integer',
103
+ :'options' => :'Object',
104
+ :'profile' => :'Boolean',
105
+ :'sort' => :'Object',
106
+ :'_source' => :'Object',
107
+ :'track_scores' => :'Boolean'
108
+ }
109
+ end
110
+
111
+ # List of attributes with nullable: true
112
+ def self.openapi_nullable
113
+ Set.new([
114
+ :'sort',
115
+ :'_source',
116
+ ])
117
+ end
118
+
119
+ # Initializes the object
120
+ # @param [Hash] attributes Model attributes in the form of hash
121
+ def initialize(attributes = {})
122
+ if (!attributes.is_a?(Hash))
123
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Manticore::Client::SearchRequest` initialize method"
124
+ end
125
+
126
+ # check to see if the attribute exists and convert string to symbol for hash key
127
+ acceptable_attribute_map = self.class.acceptable_attribute_map
128
+ attributes = attributes.each_with_object({}) { |(k, v), h|
129
+ if (!acceptable_attribute_map.key?(k.to_sym))
130
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Manticore::Client::SearchRequest`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
131
+ end
132
+ h[k.to_sym] = v
133
+ }
134
+
135
+ if attributes.key?(:'table')
136
+ self.table = attributes[:'table']
137
+ else
138
+ self.table = nil
139
+ end
140
+
141
+ if attributes.key?(:'query')
142
+ self.query = attributes[:'query']
143
+ end
144
+
145
+ if attributes.key?(:'join')
146
+ if (value = attributes[:'join']).is_a?(Array)
147
+ self.join = value
148
+ end
149
+ end
150
+
151
+ if attributes.key?(:'highlight')
152
+ self.highlight = attributes[:'highlight']
153
+ end
154
+
155
+ if attributes.key?(:'limit')
156
+ self.limit = attributes[:'limit']
157
+ end
158
+
159
+ if attributes.key?(:'knn')
160
+ self.knn = attributes[:'knn']
161
+ end
162
+
163
+ if attributes.key?(:'aggs')
164
+ if (value = attributes[:'aggs']).is_a?(Hash)
165
+ self.aggs = value
166
+ end
167
+ end
168
+
169
+ if attributes.key?(:'expressions')
170
+ if (value = attributes[:'expressions']).is_a?(Hash)
171
+ self.expressions = value
172
+ end
173
+ end
174
+
175
+ if attributes.key?(:'max_matches')
176
+ self.max_matches = attributes[:'max_matches']
177
+ end
178
+
179
+ if attributes.key?(:'offset')
180
+ self.offset = attributes[:'offset']
181
+ end
182
+
183
+ if attributes.key?(:'options')
184
+ self.options = attributes[:'options']
185
+ end
186
+
187
+ if attributes.key?(:'profile')
188
+ self.profile = attributes[:'profile']
189
+ end
190
+
191
+ if attributes.key?(:'sort')
192
+ self.sort = attributes[:'sort']
193
+ end
194
+
195
+ if attributes.key?(:'_source')
196
+ self._source = attributes[:'_source']
197
+ end
198
+
199
+ if attributes.key?(:'track_scores')
200
+ self.track_scores = attributes[:'track_scores']
201
+ end
202
+ end
203
+
204
+ # Show invalid properties with the reasons. Usually used together with valid?
205
+ # @return Array for valid properties with the reasons
206
+ def list_invalid_properties
207
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
208
+ invalid_properties = Array.new
209
+ if @table.nil?
210
+ invalid_properties.push('invalid value for "table", table cannot be nil.')
211
+ end
212
+
213
+ invalid_properties
214
+ end
215
+
216
+ # Check to see if the all the properties in the model are valid
217
+ # @return true if the model is valid
218
+ def valid?
219
+ warn '[DEPRECATED] the `valid?` method is obsolete'
220
+ return false if @table.nil?
221
+ true
222
+ end
223
+
224
+ # Custom attribute writer method with validation
225
+ # @param [Object] table Value to be assigned
226
+ def table=(table)
227
+ if table.nil?
228
+ fail ArgumentError, 'table cannot be nil'
229
+ end
230
+
231
+ @table = table
232
+ end
233
+
234
+ # Checks equality by comparing each attribute.
235
+ # @param [Object] Object to be compared
236
+ def ==(o)
237
+ return true if self.equal?(o)
238
+ self.class == o.class &&
239
+ table == o.table &&
240
+ query == o.query &&
241
+ join == o.join &&
242
+ highlight == o.highlight &&
243
+ limit == o.limit &&
244
+ knn == o.knn &&
245
+ aggs == o.aggs &&
246
+ expressions == o.expressions &&
247
+ max_matches == o.max_matches &&
248
+ offset == o.offset &&
249
+ options == o.options &&
250
+ profile == o.profile &&
251
+ sort == o.sort &&
252
+ _source == o._source &&
253
+ track_scores == o.track_scores
254
+ end
255
+
256
+ # @see the `==` method
257
+ # @param [Object] Object to be compared
258
+ def eql?(o)
259
+ self == o
260
+ end
261
+
262
+ # Calculates hash code according to all attributes.
263
+ # @return [Integer] Hash code
264
+ def hash
265
+ [table, query, join, highlight, limit, knn, aggs, expressions, max_matches, offset, options, profile, sort, _source, track_scores].hash
266
+ end
267
+
268
+ # Builds the object from hash
269
+ # @param [Hash] attributes Model attributes in the form of hash
270
+ # @return [Object] Returns the model itself
271
+ def self.build_from_hash(attributes)
272
+ return nil unless attributes.is_a?(Hash)
273
+ attributes = attributes.transform_keys(&:to_sym)
274
+ transformed_hash = {}
275
+ openapi_types.each_pair do |key, type|
276
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
277
+ transformed_hash["#{key}"] = nil
278
+ elsif type =~ /\AArray<(.*)>/i
279
+ # check to ensure the input is an array given that the attribute
280
+ # is documented as an array but the input is not
281
+ if attributes[attribute_map[key]].is_a?(Array)
282
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
283
+ end
284
+ elsif !attributes[attribute_map[key]].nil?
285
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
286
+ end
287
+ end
288
+ new(transformed_hash)
289
+ end
290
+
291
+ # Deserializes the data based on type
292
+ # @param string type Data type
293
+ # @param string value Value to be deserialized
294
+ # @return [Object] Deserialized data
295
+ def self._deserialize(type, value)
296
+ case type.to_sym
297
+ when :Time
298
+ Time.parse(value)
299
+ when :Date
300
+ Date.parse(value)
301
+ when :String
302
+ value.to_s
303
+ when :Integer
304
+ value.to_i
305
+ when :Float
306
+ value.to_f
307
+ when :Boolean
308
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
309
+ true
310
+ else
311
+ false
312
+ end
313
+ when :Object
314
+ # generic object (usually a Hash), return directly
315
+ value
316
+ when /\AArray<(?<inner_type>.+)>\z/
317
+ inner_type = Regexp.last_match[:inner_type]
318
+ value.map { |v| _deserialize(inner_type, v) }
319
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
320
+ k_type = Regexp.last_match[:k_type]
321
+ v_type = Regexp.last_match[:v_type]
322
+ {}.tap do |hash|
323
+ value.each do |k, v|
324
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
325
+ end
326
+ end
327
+ else # model
328
+ # models (e.g. Pet) or oneOf
329
+ klass = Manticore::Client.const_get(type)
330
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
331
+ end
332
+ end
333
+
334
+ # Returns the string representation of the object
335
+ # @return [String] String presentation of the object
336
+ def to_s
337
+ to_hash.to_s
338
+ end
339
+
340
+ # to_body is an alias to to_hash (backward compatibility)
341
+ # @return [Hash] Returns the object in the form of hash
342
+ def to_body
343
+ to_hash
344
+ end
345
+
346
+ # Returns the object in the form of hash
347
+ # @return [Hash] Returns the object in the form of hash
348
+ def to_hash
349
+ hash = {}
350
+ self.class.attribute_map.each_pair do |attr, param|
351
+ value = self.send(attr)
352
+ if value.nil?
353
+ is_nullable = self.class.openapi_nullable.include?(attr)
354
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
355
+ end
356
+
357
+ hash[param] = _to_hash(value)
358
+ end
359
+ hash
360
+ end
361
+
362
+ # Outputs non-array value in the form of hash
363
+ # For object, use to_hash. Otherwise, just return the value
364
+ # @param [Object] value Any valid value
365
+ # @return [Hash] Returns the value in the form of hash
366
+ def _to_hash(value)
367
+ if value.is_a?(Array)
368
+ value.compact.map { |v| _to_hash(v) }
369
+ elsif value.is_a?(Hash)
370
+ {}.tap do |hash|
371
+ value.each { |k, v| hash[k] = _to_hash(v) }
372
+ end
373
+ elsif value.respond_to? :to_hash
374
+ value.to_hash
375
+ else
376
+ value
377
+ end
378
+ end
379
+
380
+ end
381
+
382
+ end
@@ -0,0 +1,281 @@
1
+ =begin
2
+ #Manticore Search Client
3
+
4
+ #Сlient for Manticore Search.
5
+
6
+ The version of the OpenAPI document: 5.0.0
7
+ Contact: info@manticoresearch.com
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.13.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Manticore::Client
17
+ # Response object containing the results of a search request
18
+ class SearchResponse
19
+ # Time taken to execute the search
20
+ attr_accessor :took
21
+
22
+ # Indicates whether the search operation timed out
23
+ attr_accessor :timed_out
24
+
25
+ # Aggregated search results grouped by the specified criteria
26
+ attr_accessor :aggregations
27
+
28
+ attr_accessor :hits
29
+
30
+ # Profile information about the search execution, if profiling is enabled
31
+ attr_accessor :profile
32
+
33
+ # Scroll token to be used fo pagination
34
+ attr_accessor :scroll
35
+
36
+ # Warnings encountered during the search operation
37
+ attr_accessor :warning
38
+
39
+ # Attribute mapping from ruby-style variable name to JSON key.
40
+ def self.attribute_map
41
+ {
42
+ :'took' => :'took',
43
+ :'timed_out' => :'timed_out',
44
+ :'aggregations' => :'aggregations',
45
+ :'hits' => :'hits',
46
+ :'profile' => :'profile',
47
+ :'scroll' => :'scroll',
48
+ :'warning' => :'warning'
49
+ }
50
+ end
51
+
52
+ # Returns attribute mapping this model knows about
53
+ def self.acceptable_attribute_map
54
+ attribute_map
55
+ end
56
+
57
+ # Returns all the JSON keys this model knows about
58
+ def self.acceptable_attributes
59
+ acceptable_attribute_map.values
60
+ end
61
+
62
+ # Attribute type mapping.
63
+ def self.openapi_types
64
+ {
65
+ :'took' => :'Integer',
66
+ :'timed_out' => :'Boolean',
67
+ :'aggregations' => :'Object',
68
+ :'hits' => :'SearchResponseHits',
69
+ :'profile' => :'Object',
70
+ :'scroll' => :'String',
71
+ :'warning' => :'Object'
72
+ }
73
+ end
74
+
75
+ # List of attributes with nullable: true
76
+ def self.openapi_nullable
77
+ Set.new([
78
+ ])
79
+ end
80
+
81
+ # Initializes the object
82
+ # @param [Hash] attributes Model attributes in the form of hash
83
+ def initialize(attributes = {})
84
+ if (!attributes.is_a?(Hash))
85
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Manticore::Client::SearchResponse` initialize method"
86
+ end
87
+
88
+ # check to see if the attribute exists and convert string to symbol for hash key
89
+ acceptable_attribute_map = self.class.acceptable_attribute_map
90
+ attributes = attributes.each_with_object({}) { |(k, v), h|
91
+ if (!acceptable_attribute_map.key?(k.to_sym))
92
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Manticore::Client::SearchResponse`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
93
+ end
94
+ h[k.to_sym] = v
95
+ }
96
+
97
+ if attributes.key?(:'took')
98
+ self.took = attributes[:'took']
99
+ end
100
+
101
+ if attributes.key?(:'timed_out')
102
+ self.timed_out = attributes[:'timed_out']
103
+ end
104
+
105
+ if attributes.key?(:'aggregations')
106
+ self.aggregations = attributes[:'aggregations']
107
+ end
108
+
109
+ if attributes.key?(:'hits')
110
+ self.hits = attributes[:'hits']
111
+ end
112
+
113
+ if attributes.key?(:'profile')
114
+ self.profile = attributes[:'profile']
115
+ end
116
+
117
+ if attributes.key?(:'scroll')
118
+ self.scroll = attributes[:'scroll']
119
+ end
120
+
121
+ if attributes.key?(:'warning')
122
+ self.warning = attributes[:'warning']
123
+ end
124
+ end
125
+
126
+ # Show invalid properties with the reasons. Usually used together with valid?
127
+ # @return Array for valid properties with the reasons
128
+ def list_invalid_properties
129
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
130
+ invalid_properties = Array.new
131
+ invalid_properties
132
+ end
133
+
134
+ # Check to see if the all the properties in the model are valid
135
+ # @return true if the model is valid
136
+ def valid?
137
+ warn '[DEPRECATED] the `valid?` method is obsolete'
138
+ true
139
+ end
140
+
141
+ # Checks equality by comparing each attribute.
142
+ # @param [Object] Object to be compared
143
+ def ==(o)
144
+ return true if self.equal?(o)
145
+ self.class == o.class &&
146
+ took == o.took &&
147
+ timed_out == o.timed_out &&
148
+ aggregations == o.aggregations &&
149
+ hits == o.hits &&
150
+ profile == o.profile &&
151
+ scroll == o.scroll &&
152
+ warning == o.warning
153
+ end
154
+
155
+ # @see the `==` method
156
+ # @param [Object] Object to be compared
157
+ def eql?(o)
158
+ self == o
159
+ end
160
+
161
+ # Calculates hash code according to all attributes.
162
+ # @return [Integer] Hash code
163
+ def hash
164
+ [took, timed_out, aggregations, hits, profile, scroll, warning].hash
165
+ end
166
+
167
+ # Builds the object from hash
168
+ # @param [Hash] attributes Model attributes in the form of hash
169
+ # @return [Object] Returns the model itself
170
+ def self.build_from_hash(attributes)
171
+ return nil unless attributes.is_a?(Hash)
172
+ attributes = attributes.transform_keys(&:to_sym)
173
+ transformed_hash = {}
174
+ openapi_types.each_pair do |key, type|
175
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
176
+ transformed_hash["#{key}"] = nil
177
+ elsif type =~ /\AArray<(.*)>/i
178
+ # check to ensure the input is an array given that the attribute
179
+ # is documented as an array but the input is not
180
+ if attributes[attribute_map[key]].is_a?(Array)
181
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
182
+ end
183
+ elsif !attributes[attribute_map[key]].nil?
184
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
185
+ end
186
+ end
187
+ new(transformed_hash)
188
+ end
189
+
190
+ # Deserializes the data based on type
191
+ # @param string type Data type
192
+ # @param string value Value to be deserialized
193
+ # @return [Object] Deserialized data
194
+ def self._deserialize(type, value)
195
+ case type.to_sym
196
+ when :Time
197
+ Time.parse(value)
198
+ when :Date
199
+ Date.parse(value)
200
+ when :String
201
+ value.to_s
202
+ when :Integer
203
+ value.to_i
204
+ when :Float
205
+ value.to_f
206
+ when :Boolean
207
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
208
+ true
209
+ else
210
+ false
211
+ end
212
+ when :Object
213
+ # generic object (usually a Hash), return directly
214
+ value
215
+ when /\AArray<(?<inner_type>.+)>\z/
216
+ inner_type = Regexp.last_match[:inner_type]
217
+ value.map { |v| _deserialize(inner_type, v) }
218
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
219
+ k_type = Regexp.last_match[:k_type]
220
+ v_type = Regexp.last_match[:v_type]
221
+ {}.tap do |hash|
222
+ value.each do |k, v|
223
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
224
+ end
225
+ end
226
+ else # model
227
+ # models (e.g. Pet) or oneOf
228
+ klass = Manticore::Client.const_get(type)
229
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
230
+ end
231
+ end
232
+
233
+ # Returns the string representation of the object
234
+ # @return [String] String presentation of the object
235
+ def to_s
236
+ to_hash.to_s
237
+ end
238
+
239
+ # to_body is an alias to to_hash (backward compatibility)
240
+ # @return [Hash] Returns the object in the form of hash
241
+ def to_body
242
+ to_hash
243
+ end
244
+
245
+ # Returns the object in the form of hash
246
+ # @return [Hash] Returns the object in the form of hash
247
+ def to_hash
248
+ hash = {}
249
+ self.class.attribute_map.each_pair do |attr, param|
250
+ value = self.send(attr)
251
+ if value.nil?
252
+ is_nullable = self.class.openapi_nullable.include?(attr)
253
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
254
+ end
255
+
256
+ hash[param] = _to_hash(value)
257
+ end
258
+ hash
259
+ end
260
+
261
+ # Outputs non-array value in the form of hash
262
+ # For object, use to_hash. Otherwise, just return the value
263
+ # @param [Object] value Any valid value
264
+ # @return [Hash] Returns the value in the form of hash
265
+ def _to_hash(value)
266
+ if value.is_a?(Array)
267
+ value.compact.map { |v| _to_hash(v) }
268
+ elsif value.is_a?(Hash)
269
+ {}.tap do |hash|
270
+ value.each { |k, v| hash[k] = _to_hash(v) }
271
+ end
272
+ elsif value.respond_to? :to_hash
273
+ value.to_hash
274
+ else
275
+ value
276
+ end
277
+ end
278
+
279
+ end
280
+
281
+ end