algolia 3.40.0 → 3.41.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 (130) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE/Bug_report.yml +1 -0
  3. data/CHANGELOG.md +5 -0
  4. data/Gemfile.lock +4 -4
  5. data/lib/algolia/api/agent_studio_client.rb +2364 -0
  6. data/lib/algolia/models/agent-studio/advanced_syntax_features.rb +34 -0
  7. data/lib/algolia/models/agent-studio/agent_completion_algolia_params.rb +221 -0
  8. data/lib/algolia/models/agent-studio/agent_completion_request.rb +247 -0
  9. data/lib/algolia/models/agent-studio/agent_config_create.rb +288 -0
  10. data/lib/algolia/models/agent-studio/agent_config_update.rb +294 -0
  11. data/lib/algolia/models/agent-studio/agent_status.rb +34 -0
  12. data/lib/algolia/models/agent-studio/agent_test_configuration.rb +271 -0
  13. data/lib/algolia/models/agent-studio/agent_with_version_response.rb +370 -0
  14. data/lib/algolia/models/agent-studio/algolia_display_results_tool_config.rb +254 -0
  15. data/lib/algolia/models/agent-studio/algolia_recommend_tool_config_input.rb +242 -0
  16. data/lib/algolia/models/agent-studio/algolia_recommend_tool_index_config.rb +228 -0
  17. data/lib/algolia/models/agent-studio/algolia_search_tool_config.rb +232 -0
  18. data/lib/algolia/models/agent-studio/algolia_search_tool_index_config.rb +249 -0
  19. data/lib/algolia/models/agent-studio/allowed_domain_bulk_delete.rb +212 -0
  20. data/lib/algolia/models/agent-studio/allowed_domain_bulk_insert.rb +212 -0
  21. data/lib/algolia/models/agent-studio/allowed_domain_create.rb +210 -0
  22. data/lib/algolia/models/agent-studio/allowed_domain_list_response.rb +211 -0
  23. data/lib/algolia/models/agent-studio/allowed_domain_response.rb +264 -0
  24. data/lib/algolia/models/agent-studio/alternatives_as_exact.rb +36 -0
  25. data/lib/algolia/models/agent-studio/anthropic_provider_input.rb +220 -0
  26. data/lib/algolia/models/agent-studio/application_config_patch.rb +209 -0
  27. data/lib/algolia/models/agent-studio/application_config_response.rb +208 -0
  28. data/lib/algolia/models/agent-studio/around_precision_union.rb +108 -0
  29. data/lib/algolia/models/agent-studio/around_radius_union.rb +108 -0
  30. data/lib/algolia/models/agent-studio/assistant_message_v4.rb +252 -0
  31. data/lib/algolia/models/agent-studio/assistant_message_v5.rb +228 -0
  32. data/lib/algolia/models/agent-studio/assistant_part_v4.rb +110 -0
  33. data/lib/algolia/models/agent-studio/assistant_part_v5.rb +110 -0
  34. data/lib/algolia/models/agent-studio/azure_open_ai_provider_input.rb +243 -0
  35. data/lib/algolia/models/agent-studio/base_provider_input.rb +209 -0
  36. data/lib/algolia/models/agent-studio/client_side_tool_config.rb +241 -0
  37. data/lib/algolia/models/agent-studio/client_tools_args_schema.rb +228 -0
  38. data/lib/algolia/models/agent-studio/compatibility_mode.rb +34 -0
  39. data/lib/algolia/models/agent-studio/conversation_base_response.rb +355 -0
  40. data/lib/algolia/models/agent-studio/conversation_full_response.rb +369 -0
  41. data/lib/algolia/models/agent-studio/conversation_metadata.rb +209 -0
  42. data/lib/algolia/models/agent-studio/distinct_union.rb +108 -0
  43. data/lib/algolia/models/agent-studio/episode.rb +243 -0
  44. data/lib/algolia/models/agent-studio/error_base.rb +207 -0
  45. data/lib/algolia/models/agent-studio/exact_on_single_word_query.rb +35 -0
  46. data/lib/algolia/models/agent-studio/facet_filters_union.rb +108 -0
  47. data/lib/algolia/models/agent-studio/facets.rb +208 -0
  48. data/lib/algolia/models/agent-studio/facets_param.rb +220 -0
  49. data/lib/algolia/models/agent-studio/facets_union.rb +108 -0
  50. data/lib/algolia/models/agent-studio/feedback_creation_request.rb +251 -0
  51. data/lib/algolia/models/agent-studio/feedback_response.rb +297 -0
  52. data/lib/algolia/models/agent-studio/ignore_plurals_union.rb +108 -0
  53. data/lib/algolia/models/agent-studio/index_search_parameters.rb +267 -0
  54. data/lib/algolia/models/agent-studio/inside_bounding_box_union.rb +108 -0
  55. data/lib/algolia/models/agent-studio/inside_polygon_union.rb +108 -0
  56. data/lib/algolia/models/agent-studio/location_item_union.rb +108 -0
  57. data/lib/algolia/models/agent-studio/mcp_server_tool_config.rb +276 -0
  58. data/lib/algolia/models/agent-studio/mcp_tool_config.rb +218 -0
  59. data/lib/algolia/models/agent-studio/memory_record.rb +368 -0
  60. data/lib/algolia/models/agent-studio/memory_type.rb +34 -0
  61. data/lib/algolia/models/agent-studio/message_part.rb +132 -0
  62. data/lib/algolia/models/agent-studio/message_response.rb +309 -0
  63. data/lib/algolia/models/agent-studio/message_role.rb +34 -0
  64. data/lib/algolia/models/agent-studio/message_v4.rb +117 -0
  65. data/lib/algolia/models/agent-studio/message_v5.rb +117 -0
  66. data/lib/algolia/models/agent-studio/messages_union.rb +108 -0
  67. data/lib/algolia/models/agent-studio/number_param.rb +230 -0
  68. data/lib/algolia/models/agent-studio/number_param_constraint.rb +219 -0
  69. data/lib/algolia/models/agent-studio/numeric_filters_union.rb +108 -0
  70. data/lib/algolia/models/agent-studio/open_ai_compatible_provider_input.rb +232 -0
  71. data/lib/algolia/models/agent-studio/open_ai_provider_input.rb +220 -0
  72. data/lib/algolia/models/agent-studio/optional_filters_union.rb +108 -0
  73. data/lib/algolia/models/agent-studio/optional_words_union.rb +108 -0
  74. data/lib/algolia/models/agent-studio/paginated_agents_response.rb +221 -0
  75. data/lib/algolia/models/agent-studio/paginated_conversations_response.rb +221 -0
  76. data/lib/algolia/models/agent-studio/paginated_provider_authentications_response.rb +221 -0
  77. data/lib/algolia/models/agent-studio/paginated_secret_keys_response.rb +221 -0
  78. data/lib/algolia/models/agent-studio/pagination_metadata.rb +241 -0
  79. data/lib/algolia/models/agent-studio/provider_authentication_create.rb +230 -0
  80. data/lib/algolia/models/agent-studio/provider_authentication_patch.rb +218 -0
  81. data/lib/algolia/models/agent-studio/provider_authentication_response.rb +274 -0
  82. data/lib/algolia/models/agent-studio/provider_input.rb +111 -0
  83. data/lib/algolia/models/agent-studio/provider_input_nullable.rb +111 -0
  84. data/lib/algolia/models/agent-studio/provider_name.rb +38 -0
  85. data/lib/algolia/models/agent-studio/query_type.rb +35 -0
  86. data/lib/algolia/models/agent-studio/re_ranking_apply_filter_union.rb +108 -0
  87. data/lib/algolia/models/agent-studio/reasoning_part.rb +219 -0
  88. data/lib/algolia/models/agent-studio/reasoning_part_v4.rb +217 -0
  89. data/lib/algolia/models/agent-studio/reasoning_part_v5.rb +217 -0
  90. data/lib/algolia/models/agent-studio/remove_stop_words_union.rb +108 -0
  91. data/lib/algolia/models/agent-studio/remove_words_if_no_results.rb +36 -0
  92. data/lib/algolia/models/agent-studio/search_parameters.rb +950 -0
  93. data/lib/algolia/models/agent-studio/search_parameters_overrides.rb +286 -0
  94. data/lib/algolia/models/agent-studio/secret_key_create.rb +222 -0
  95. data/lib/algolia/models/agent-studio/secret_key_patch.rb +223 -0
  96. data/lib/algolia/models/agent-studio/secret_key_response.rb +287 -0
  97. data/lib/algolia/models/agent-studio/start_part.rb +208 -0
  98. data/lib/algolia/models/agent-studio/start_step_part.rb +208 -0
  99. data/lib/algolia/models/agent-studio/step_start_part_v4.rb +206 -0
  100. data/lib/algolia/models/agent-studio/step_start_part_v5.rb +206 -0
  101. data/lib/algolia/models/agent-studio/string_array_param.rb +242 -0
  102. data/lib/algolia/models/agent-studio/string_array_param_constraint.rb +211 -0
  103. data/lib/algolia/models/agent-studio/supported_language.rb +169 -0
  104. data/lib/algolia/models/agent-studio/tag_filters_union.rb +108 -0
  105. data/lib/algolia/models/agent-studio/text_param.rb +220 -0
  106. data/lib/algolia/models/agent-studio/text_part.rb +216 -0
  107. data/lib/algolia/models/agent-studio/text_part_v4.rb +217 -0
  108. data/lib/algolia/models/agent-studio/text_part_v5.rb +217 -0
  109. data/lib/algolia/models/agent-studio/tool_approval_request_part.rb +285 -0
  110. data/lib/algolia/models/agent-studio/tool_call_part.rb +265 -0
  111. data/lib/algolia/models/agent-studio/tool_config.rb +108 -0
  112. data/lib/algolia/models/agent-studio/tool_config_input.rb +129 -0
  113. data/lib/algolia/models/agent-studio/tool_invocation_part_v4.rb +217 -0
  114. data/lib/algolia/models/agent-studio/tool_invocation_v4.rb +309 -0
  115. data/lib/algolia/models/agent-studio/tool_part_v5.rb +309 -0
  116. data/lib/algolia/models/agent-studio/tool_result_output.rb +221 -0
  117. data/lib/algolia/models/agent-studio/tool_result_output_type.rb +37 -0
  118. data/lib/algolia/models/agent-studio/tool_result_part.rb +254 -0
  119. data/lib/algolia/models/agent-studio/tool_state.rb +36 -0
  120. data/lib/algolia/models/agent-studio/typo_tolerance_enum.rb +36 -0
  121. data/lib/algolia/models/agent-studio/typo_tolerance_union.rb +108 -0
  122. data/lib/algolia/models/agent-studio/unknown_tool_config.rb +220 -0
  123. data/lib/algolia/models/agent-studio/user_data_response.rb +223 -0
  124. data/lib/algolia/models/agent-studio/user_message_metadata_v5.rb +209 -0
  125. data/lib/algolia/models/agent-studio/user_message_v4.rb +250 -0
  126. data/lib/algolia/models/agent-studio/user_message_v5.rb +237 -0
  127. data/lib/algolia/models/agent-studio/validation_error.rb +252 -0
  128. data/lib/algolia/models/agent-studio/vote_enum.rb +34 -0
  129. data/lib/algolia/version.rb +1 -1
  130. metadata +125 -1
@@ -0,0 +1,243 @@
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 AgentStudio
10
+ # Episodic memory schema following LangMem's OTAR pattern: Observation → Thoughts → Action → Result Captures complete interaction experiences for agent learning. See https://langchain-ai.github.io/langmem/concepts/conceptual_guide/#episodic-memory-past-experiences.
11
+ class Episode
12
+ # What user wanted + key context (1-2 sentences). Include prior failed attempts if they informed the approach.
13
+ attr_accessor :observation
14
+
15
+ # WHY this approach was chosen, which constraints/preferences drove decisions (1-3 sentences). Capture reasoning that applies to similar future scenarios.
16
+ attr_accessor :thoughts
17
+
18
+ # What was done with PRECISE details (1-3 sentences). WITH tool calls: use arrow notation `tool(param:value) → feedback → tool(refined_param:new_value)`. WITHOUT tool calls: capture communication/workflow pattern.
19
+ attr_accessor :action
20
+
21
+ # Learned pattern + effectiveness (1-3 sentences). What worked and WHY it's replicable. Note efficiency: multi-turn refinements, which results were relevant, what made final attempt succeed. Use strict `param:value` syntax for learnings. Format: 'For [context], use [param:value] because [reason]'.
22
+ attr_accessor :result
23
+
24
+ # Attribute mapping from ruby-style variable name to JSON key.
25
+ def self.attribute_map
26
+ {
27
+ :observation => :observation,
28
+ :thoughts => :thoughts,
29
+ :action => :action,
30
+ :result => :result
31
+ }
32
+ end
33
+
34
+ # Attribute type mapping.
35
+ def self.types_mapping
36
+ {
37
+ :observation => :"String",
38
+ :thoughts => :"String",
39
+ :action => :"String",
40
+ :result => :"String"
41
+ }
42
+ end
43
+
44
+ # List of attributes with nullable: true
45
+ def self.openapi_nullable
46
+ Set.new(
47
+ []
48
+ )
49
+ end
50
+
51
+ # Initializes the object
52
+ # @param [Hash] attributes Model attributes in the form of hash
53
+ def initialize(attributes = {})
54
+ if (!attributes.is_a?(Hash))
55
+ raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::Episode` initialize method"
56
+ end
57
+
58
+ # check to see if the attribute exists and convert string to symbol for hash key
59
+ attributes = attributes.each_with_object({}) { |(k, v), h|
60
+ if (!self.class.attribute_map.key?(k.to_sym))
61
+ raise(
62
+ ArgumentError,
63
+ "`#{k}` is not a valid attribute in `Algolia::Episode`. Please check the name to make sure it's valid. List of attributes: " +
64
+ self.class.attribute_map.keys.inspect
65
+ )
66
+ end
67
+
68
+ h[k.to_sym] = v
69
+ }
70
+
71
+ if attributes.key?(:observation)
72
+ self.observation = attributes[:observation]
73
+ else
74
+ self.observation = nil
75
+ end
76
+
77
+ if attributes.key?(:thoughts)
78
+ self.thoughts = attributes[:thoughts]
79
+ else
80
+ self.thoughts = nil
81
+ end
82
+
83
+ if attributes.key?(:action)
84
+ self.action = attributes[:action]
85
+ else
86
+ self.action = nil
87
+ end
88
+
89
+ if attributes.key?(:result)
90
+ self.result = attributes[:result]
91
+ else
92
+ self.result = nil
93
+ end
94
+ end
95
+
96
+ # Checks equality by comparing each attribute.
97
+ # @param [Object] Object to be compared
98
+ def ==(other)
99
+ return true if self.equal?(other)
100
+ self.class == other.class &&
101
+ observation == other.observation &&
102
+ thoughts == other.thoughts &&
103
+ action == other.action &&
104
+ result == other.result
105
+ end
106
+
107
+ # @see the `==` method
108
+ # @param [Object] Object to be compared
109
+ def eql?(other)
110
+ self == other
111
+ end
112
+
113
+ # Calculates hash code according to all attributes.
114
+ # @return [Integer] Hash code
115
+ def hash
116
+ [observation, thoughts, action, result].hash
117
+ end
118
+
119
+ # Builds the object from hash
120
+ # @param [Hash] attributes Model attributes in the form of hash
121
+ # @return [Object] Returns the model itself
122
+ def self.build_from_hash(attributes)
123
+ return nil unless attributes.is_a?(Hash)
124
+ attributes = attributes.transform_keys(&:to_sym)
125
+ transformed_hash = {}
126
+ types_mapping.each_pair do |key, type|
127
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
128
+ transformed_hash[key.to_sym] = nil
129
+ elsif type =~ /\AArray<(.*)>/i
130
+ # check to ensure the input is an array given that the attribute
131
+ # is documented as an array but the input is not
132
+ if attributes[attribute_map[key]].is_a?(Array)
133
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
134
+ _deserialize(::Regexp.last_match(1), v)
135
+ }
136
+ end
137
+ elsif !attributes[attribute_map[key]].nil?
138
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
139
+ end
140
+ end
141
+
142
+ new(transformed_hash)
143
+ end
144
+
145
+ # Deserializes the data based on type
146
+ # @param string type Data type
147
+ # @param string value Value to be deserialized
148
+ # @return [Object] Deserialized data
149
+ def self._deserialize(type, value)
150
+ case type.to_sym
151
+ when :Time
152
+ Time.parse(value)
153
+ when :Date
154
+ Date.parse(value)
155
+ when :String
156
+ value.to_s
157
+ when :Integer
158
+ value.to_i
159
+ when :Float
160
+ value.to_f
161
+ when :Boolean
162
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
163
+ true
164
+ else
165
+ false
166
+ end
167
+
168
+ when :Object
169
+ # generic object (usually a Hash), return directly
170
+ value
171
+ when /\AArray<(?<inner_type>.+)>\z/
172
+ inner_type = Regexp.last_match[:inner_type]
173
+ value.map { |v| _deserialize(inner_type, v) }
174
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
175
+ k_type = Regexp.last_match[:k_type]
176
+ v_type = Regexp.last_match[:v_type]
177
+ {}.tap do |hash|
178
+ value.each do |k, v|
179
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
180
+ end
181
+ end
182
+ # model
183
+ else
184
+ # models (e.g. Pet) or oneOf
185
+ klass = Algolia::AgentStudio.const_get(type)
186
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
187
+ .build_from_hash(value)
188
+ end
189
+ end
190
+
191
+ # Returns the string representation of the object
192
+ # @return [String] String presentation of the object
193
+ def to_s
194
+ to_hash.to_s
195
+ end
196
+
197
+ # to_body is an alias to to_hash (backward compatibility)
198
+ # @return [Hash] Returns the object in the form of hash
199
+ def to_body
200
+ to_hash
201
+ end
202
+
203
+ def to_json(*_args)
204
+ to_hash.to_json
205
+ end
206
+
207
+ # Returns the object in the form of hash
208
+ # @return [Hash] Returns the object in the form of hash
209
+ def to_hash
210
+ hash = {}
211
+ self.class.attribute_map.each_pair do |attr, param|
212
+ value = send(attr)
213
+ if value.nil?
214
+ is_nullable = self.class.openapi_nullable.include?(attr)
215
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
216
+ end
217
+
218
+ hash[param] = _to_hash(value)
219
+ end
220
+
221
+ hash
222
+ end
223
+
224
+ # Outputs non-array value in the form of hash
225
+ # For object, use to_hash. Otherwise, just return the value
226
+ # @param [Object] value Any valid value
227
+ # @return [Hash] Returns the value in the form of hash
228
+ def _to_hash(value)
229
+ if value.is_a?(Array)
230
+ value.compact.map { |v| _to_hash(v) }
231
+ elsif value.is_a?(Hash)
232
+ {}.tap do |hash|
233
+ value.each { |k, v| hash[k] = _to_hash(v) }
234
+ end
235
+ elsif value.respond_to?(:to_hash)
236
+ value.to_hash
237
+ else
238
+ value
239
+ end
240
+ end
241
+ end
242
+ end
243
+ end
@@ -0,0 +1,207 @@
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 AgentStudio
10
+ # Error.
11
+ class ErrorBase
12
+ attr_accessor :message
13
+
14
+ attr_accessor :additional_properties
15
+
16
+ # Attribute mapping from ruby-style variable name to JSON key.
17
+ def self.attribute_map
18
+ {
19
+ :message => :message
20
+ }
21
+ end
22
+
23
+ # Attribute type mapping.
24
+ def self.types_mapping
25
+ {
26
+ :message => :"String"
27
+ }
28
+ end
29
+
30
+ # List of attributes with nullable: true
31
+ def self.openapi_nullable
32
+ Set.new(
33
+ []
34
+ )
35
+ end
36
+
37
+ # Initializes the object
38
+ # @param [Hash] attributes Model attributes in the form of hash
39
+ def initialize(attributes = {})
40
+ if (!attributes.is_a?(Hash))
41
+ raise(
42
+ ArgumentError,
43
+ "The input argument (attributes) must be a hash in `Algolia::ErrorBase` initialize method"
44
+ )
45
+ end
46
+
47
+ if attributes.key?(:message)
48
+ self.message = attributes[:message]
49
+ end
50
+
51
+ # add extra attribute to additional_properties
52
+ self.additional_properties ||= {}
53
+ self.additional_properties.merge!(attributes.reject { |k, _| self.class.attribute_map.key?(k.to_sym) })
54
+ end
55
+
56
+ # Checks equality by comparing each attribute.
57
+ # @param [Object] Object to be compared
58
+ def ==(other)
59
+ return true if self.equal?(other)
60
+ self.class == other.class &&
61
+ message == other.message
62
+ end
63
+
64
+ # @see the `==` method
65
+ # @param [Object] Object to be compared
66
+ def eql?(other)
67
+ self == other
68
+ end
69
+
70
+ # Calculates hash code according to all attributes.
71
+ # @return [Integer] Hash code
72
+ def hash
73
+ [message].hash
74
+ end
75
+
76
+ # Builds the object from hash
77
+ # @param [Hash] attributes Model attributes in the form of hash
78
+ # @return [Object] Returns the model itself
79
+ def self.build_from_hash(attributes)
80
+ return nil unless attributes.is_a?(Hash)
81
+ attributes = attributes.transform_keys(&:to_sym)
82
+ transformed_hash = {}
83
+ types_mapping.each_pair do |key, type|
84
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
85
+ transformed_hash[key.to_sym] = nil
86
+ elsif type =~ /\AArray<(.*)>/i
87
+ # check to ensure the input is an array given that the attribute
88
+ # is documented as an array but the input is not
89
+ if attributes[attribute_map[key]].is_a?(Array)
90
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
91
+ _deserialize(::Regexp.last_match(1), v)
92
+ }
93
+ end
94
+ elsif !attributes[attribute_map[key]].nil?
95
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
96
+ end
97
+ end
98
+
99
+ # add extra attribute to transformed_hash
100
+ transformed_hash.merge!(attributes.reject { |k, _| attribute_map.key?(k.to_sym) })
101
+ new(transformed_hash)
102
+ end
103
+
104
+ # Deserializes the data based on type
105
+ # @param string type Data type
106
+ # @param string value Value to be deserialized
107
+ # @return [Object] Deserialized data
108
+ def self._deserialize(type, value)
109
+ case type.to_sym
110
+ when :Time
111
+ Time.parse(value)
112
+ when :Date
113
+ Date.parse(value)
114
+ when :String
115
+ value.to_s
116
+ when :Integer
117
+ value.to_i
118
+ when :Float
119
+ value.to_f
120
+ when :Boolean
121
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
122
+ true
123
+ else
124
+ false
125
+ end
126
+
127
+ when :Object
128
+ # generic object (usually a Hash), return directly
129
+ value
130
+ when /\AArray<(?<inner_type>.+)>\z/
131
+ inner_type = Regexp.last_match[:inner_type]
132
+ value.map { |v| _deserialize(inner_type, v) }
133
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
134
+ k_type = Regexp.last_match[:k_type]
135
+ v_type = Regexp.last_match[:v_type]
136
+ {}.tap do |hash|
137
+ value.each do |k, v|
138
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
139
+ end
140
+ end
141
+ # model
142
+ else
143
+ # models (e.g. Pet) or oneOf
144
+ klass = Algolia::AgentStudio.const_get(type)
145
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
146
+ .build_from_hash(value)
147
+ end
148
+ end
149
+
150
+ # Returns the string representation of the object
151
+ # @return [String] String presentation of the object
152
+ def to_s
153
+ to_hash.to_s
154
+ end
155
+
156
+ # to_body is an alias to to_hash (backward compatibility)
157
+ # @return [Hash] Returns the object in the form of hash
158
+ def to_body
159
+ to_hash
160
+ end
161
+
162
+ def to_json(*_args)
163
+ to_hash.to_json
164
+ end
165
+
166
+ # Returns the object in the form of hash
167
+ # @return [Hash] Returns the object in the form of hash
168
+ def to_hash
169
+ hash = {}
170
+ self.class.attribute_map.each_pair do |attr, param|
171
+ value = send(attr)
172
+ if value.nil?
173
+ is_nullable = self.class.openapi_nullable.include?(attr)
174
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
175
+ end
176
+
177
+ hash[param] = _to_hash(value)
178
+ end
179
+
180
+ # also add attributes from additional_properties to hash
181
+ self.additional_properties&.each_pair do |k, v|
182
+ hash[k.to_sym] = _to_hash(v)
183
+ end
184
+
185
+ hash
186
+ end
187
+
188
+ # Outputs non-array value in the form of hash
189
+ # For object, use to_hash. Otherwise, just return the value
190
+ # @param [Object] value Any valid value
191
+ # @return [Hash] Returns the value in the form of hash
192
+ def _to_hash(value)
193
+ if value.is_a?(Array)
194
+ value.compact.map { |v| _to_hash(v) }
195
+ elsif value.is_a?(Hash)
196
+ {}.tap do |hash|
197
+ value.each { |k, v| hash[k] = _to_hash(v) }
198
+ end
199
+ elsif value.respond_to?(:to_hash)
200
+ value.to_hash
201
+ else
202
+ value
203
+ end
204
+ end
205
+ end
206
+ end
207
+ end
@@ -0,0 +1,35 @@
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 AgentStudio
10
+ class ExactOnSingleWordQuery
11
+ ATTRIBUTE = "attribute".freeze
12
+ NONE = "none".freeze
13
+ WORD = "word".freeze
14
+
15
+ def self.all_vars
16
+ @all_vars ||= [ATTRIBUTE, NONE, WORD].freeze
17
+ end
18
+
19
+ # Builds the enum from string
20
+ # @param [String] The enum value in the form of the string
21
+ # @return [String] The enum value
22
+ def self.build_from_hash(value)
23
+ new.build_from_hash(value)
24
+ end
25
+
26
+ # Builds the enum from string
27
+ # @param [String] The enum value in the form of the string
28
+ # @return [String] The enum value
29
+ def build_from_hash(value)
30
+ return value if ExactOnSingleWordQuery.all_vars.include?(value)
31
+ raise "Invalid ENUM value #{value} for class #ExactOnSingleWordQuery"
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,108 @@
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 AgentStudio
10
+ module FacetFiltersUnion
11
+ class << self
12
+ # List of class defined in oneOf (OpenAPI v3)
13
+ def openapi_one_of
14
+ [
15
+ :"Array<FacetFiltersUnion>",
16
+ :"String"
17
+ ]
18
+ end
19
+
20
+ # Builds the object
21
+ # @param [Mixed] Data to be matched against the list of oneOf items
22
+ # @return [Object] Returns the model or the data itself
23
+ def build(data)
24
+ # Go through the list of oneOf items and attempt to identify the appropriate one.
25
+ # Note:
26
+ # - We do not attempt to check whether exactly one item matches.
27
+ # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
28
+ # due to the way the deserialization is made in the base_object template (it just casts without verifying).
29
+ # - TODO: scalar values are de facto behaving as if they were nullable.
30
+ # - TODO: logging when debugging is set.
31
+ openapi_one_of.each do |klass|
32
+ begin
33
+ # "nullable: true"
34
+ next if klass == :AnyType
35
+ typed_data = find_and_cast_into_type(klass, data)
36
+ return typed_data if typed_data
37
+ # rescue all errors so we keep iterating even if the current item lookup raises
38
+ rescue
39
+ end
40
+ end
41
+
42
+ openapi_one_of.include?(:AnyType) ? data : nil
43
+ end
44
+
45
+ private
46
+
47
+ SchemaMismatchError = Class.new(StandardError)
48
+
49
+ def find_and_cast_into_type(klass, data)
50
+ return if data.nil?
51
+
52
+ case klass.to_s
53
+ when "Boolean"
54
+ return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
55
+ when "Float"
56
+ return data if data.instance_of?(Float)
57
+ when "Integer"
58
+ return data if data.instance_of?(Integer)
59
+ when "Time"
60
+ return Time.parse(data)
61
+ when "Date"
62
+ return Date.parse(data)
63
+ when "String"
64
+ return data if data.instance_of?(String)
65
+ # "type: object"
66
+ when "Object"
67
+ return data if data.instance_of?(Hash)
68
+ # "type: array"
69
+ when /\AArray<(?<sub_type>.+)>\z/
70
+ if data.instance_of?(Array)
71
+ sub_type = Regexp.last_match[:sub_type]
72
+ return data.map { |item| find_and_cast_into_type(sub_type, item) }
73
+ end
74
+ # "type: object" with "additionalProperties: { ... }"
75
+ when /\AHash<String, (?<sub_type>.+)>\z/
76
+ if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
77
+ sub_type = Regexp.last_match[:sub_type]
78
+ return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
79
+ end
80
+ # model
81
+ else
82
+ const = Algolia::AgentStudio.const_get(klass)
83
+ if const
84
+ if const.respond_to?(:openapi_one_of)
85
+ # nested oneOf model
86
+ model = const.build(data)
87
+ elsif const.respond_to?(:discriminator_attributes)
88
+ if const.discriminator_attributes.all? { |attr| data.key?(attr) }
89
+ model = const.build_from_hash(data)
90
+ end
91
+ else
92
+ # maybe it's an enum, or doens't have discriminators
93
+ model = const.build_from_hash(data)
94
+ end
95
+
96
+ return model if model
97
+ end
98
+ end
99
+
100
+ # if no match by now, raise
101
+ raise
102
+ rescue
103
+ raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
104
+ end
105
+ end
106
+ end
107
+ end
108
+ end