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,110 @@
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 AssistantPartV4
11
+ class << self
12
+ # List of class defined in oneOf (OpenAPI v3)
13
+ def openapi_one_of
14
+ [
15
+ :"ReasoningPartV4",
16
+ :"StepStartPartV4",
17
+ :"TextPartV4",
18
+ :"ToolInvocationPartV4"
19
+ ]
20
+ end
21
+
22
+ # Builds the object
23
+ # @param [Mixed] Data to be matched against the list of oneOf items
24
+ # @return [Object] Returns the model or the data itself
25
+ def build(data)
26
+ # Go through the list of oneOf items and attempt to identify the appropriate one.
27
+ # Note:
28
+ # - We do not attempt to check whether exactly one item matches.
29
+ # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
30
+ # due to the way the deserialization is made in the base_object template (it just casts without verifying).
31
+ # - TODO: scalar values are de facto behaving as if they were nullable.
32
+ # - TODO: logging when debugging is set.
33
+ openapi_one_of.each do |klass|
34
+ begin
35
+ # "nullable: true"
36
+ next if klass == :AnyType
37
+ typed_data = find_and_cast_into_type(klass, data)
38
+ return typed_data if typed_data
39
+ # rescue all errors so we keep iterating even if the current item lookup raises
40
+ rescue
41
+ end
42
+ end
43
+
44
+ openapi_one_of.include?(:AnyType) ? data : nil
45
+ end
46
+
47
+ private
48
+
49
+ SchemaMismatchError = Class.new(StandardError)
50
+
51
+ def find_and_cast_into_type(klass, data)
52
+ return if data.nil?
53
+
54
+ case klass.to_s
55
+ when "Boolean"
56
+ return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
57
+ when "Float"
58
+ return data if data.instance_of?(Float)
59
+ when "Integer"
60
+ return data if data.instance_of?(Integer)
61
+ when "Time"
62
+ return Time.parse(data)
63
+ when "Date"
64
+ return Date.parse(data)
65
+ when "String"
66
+ return data if data.instance_of?(String)
67
+ # "type: object"
68
+ when "Object"
69
+ return data if data.instance_of?(Hash)
70
+ # "type: array"
71
+ when /\AArray<(?<sub_type>.+)>\z/
72
+ if data.instance_of?(Array)
73
+ sub_type = Regexp.last_match[:sub_type]
74
+ return data.map { |item| find_and_cast_into_type(sub_type, item) }
75
+ end
76
+ # "type: object" with "additionalProperties: { ... }"
77
+ when /\AHash<String, (?<sub_type>.+)>\z/
78
+ if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
79
+ sub_type = Regexp.last_match[:sub_type]
80
+ return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
81
+ end
82
+ # model
83
+ else
84
+ const = Algolia::AgentStudio.const_get(klass)
85
+ if const
86
+ if const.respond_to?(:openapi_one_of)
87
+ # nested oneOf model
88
+ model = const.build(data)
89
+ elsif const.respond_to?(:discriminator_attributes)
90
+ if const.discriminator_attributes.all? { |attr| data.key?(attr) }
91
+ model = const.build_from_hash(data)
92
+ end
93
+ else
94
+ # maybe it's an enum, or doens't have discriminators
95
+ model = const.build_from_hash(data)
96
+ end
97
+
98
+ return model if model
99
+ end
100
+ end
101
+
102
+ # if no match by now, raise
103
+ raise
104
+ rescue
105
+ raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
106
+ end
107
+ end
108
+ end
109
+ end
110
+ end
@@ -0,0 +1,110 @@
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 AssistantPartV5
11
+ class << self
12
+ # List of class defined in oneOf (OpenAPI v3)
13
+ def openapi_one_of
14
+ [
15
+ :"ReasoningPartV5",
16
+ :"StepStartPartV5",
17
+ :"TextPartV5",
18
+ :"ToolPartV5"
19
+ ]
20
+ end
21
+
22
+ # Builds the object
23
+ # @param [Mixed] Data to be matched against the list of oneOf items
24
+ # @return [Object] Returns the model or the data itself
25
+ def build(data)
26
+ # Go through the list of oneOf items and attempt to identify the appropriate one.
27
+ # Note:
28
+ # - We do not attempt to check whether exactly one item matches.
29
+ # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
30
+ # due to the way the deserialization is made in the base_object template (it just casts without verifying).
31
+ # - TODO: scalar values are de facto behaving as if they were nullable.
32
+ # - TODO: logging when debugging is set.
33
+ openapi_one_of.each do |klass|
34
+ begin
35
+ # "nullable: true"
36
+ next if klass == :AnyType
37
+ typed_data = find_and_cast_into_type(klass, data)
38
+ return typed_data if typed_data
39
+ # rescue all errors so we keep iterating even if the current item lookup raises
40
+ rescue
41
+ end
42
+ end
43
+
44
+ openapi_one_of.include?(:AnyType) ? data : nil
45
+ end
46
+
47
+ private
48
+
49
+ SchemaMismatchError = Class.new(StandardError)
50
+
51
+ def find_and_cast_into_type(klass, data)
52
+ return if data.nil?
53
+
54
+ case klass.to_s
55
+ when "Boolean"
56
+ return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
57
+ when "Float"
58
+ return data if data.instance_of?(Float)
59
+ when "Integer"
60
+ return data if data.instance_of?(Integer)
61
+ when "Time"
62
+ return Time.parse(data)
63
+ when "Date"
64
+ return Date.parse(data)
65
+ when "String"
66
+ return data if data.instance_of?(String)
67
+ # "type: object"
68
+ when "Object"
69
+ return data if data.instance_of?(Hash)
70
+ # "type: array"
71
+ when /\AArray<(?<sub_type>.+)>\z/
72
+ if data.instance_of?(Array)
73
+ sub_type = Regexp.last_match[:sub_type]
74
+ return data.map { |item| find_and_cast_into_type(sub_type, item) }
75
+ end
76
+ # "type: object" with "additionalProperties: { ... }"
77
+ when /\AHash<String, (?<sub_type>.+)>\z/
78
+ if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
79
+ sub_type = Regexp.last_match[:sub_type]
80
+ return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
81
+ end
82
+ # model
83
+ else
84
+ const = Algolia::AgentStudio.const_get(klass)
85
+ if const
86
+ if const.respond_to?(:openapi_one_of)
87
+ # nested oneOf model
88
+ model = const.build(data)
89
+ elsif const.respond_to?(:discriminator_attributes)
90
+ if const.discriminator_attributes.all? { |attr| data.key?(attr) }
91
+ model = const.build_from_hash(data)
92
+ end
93
+ else
94
+ # maybe it's an enum, or doens't have discriminators
95
+ model = const.build_from_hash(data)
96
+ end
97
+
98
+ return model if model
99
+ end
100
+ end
101
+
102
+ # if no match by now, raise
103
+ raise
104
+ rescue
105
+ raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
106
+ end
107
+ end
108
+ end
109
+ end
110
+ end
@@ -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
+ # Azure OpenAI-specific provider input.
11
+ class AzureOpenAIProviderInput
12
+ attr_accessor :api_key
13
+
14
+ attr_accessor :azure_endpoint
15
+
16
+ # Azure model deployment name is required.
17
+ attr_accessor :azure_deployment
18
+
19
+ attr_accessor :api_version
20
+
21
+ # Attribute mapping from ruby-style variable name to JSON key.
22
+ def self.attribute_map
23
+ {
24
+ :api_key => :apiKey,
25
+ :azure_endpoint => :azureEndpoint,
26
+ :azure_deployment => :azureDeployment,
27
+ :api_version => :apiVersion
28
+ }
29
+ end
30
+
31
+ # Attribute type mapping.
32
+ def self.types_mapping
33
+ {
34
+ :api_key => :"String",
35
+ :azure_endpoint => :"String",
36
+ :azure_deployment => :"String",
37
+ :api_version => :"String"
38
+ }
39
+ end
40
+
41
+ # List of attributes with nullable: true
42
+ def self.openapi_nullable
43
+ Set.new(
44
+ [
45
+ :api_version
46
+ ]
47
+ )
48
+ end
49
+
50
+ # Initializes the object
51
+ # @param [Hash] attributes Model attributes in the form of hash
52
+ def initialize(attributes = {})
53
+ if (!attributes.is_a?(Hash))
54
+ raise(
55
+ ArgumentError,
56
+ "The input argument (attributes) must be a hash in `Algolia::AzureOpenAIProviderInput` initialize method"
57
+ )
58
+ end
59
+
60
+ # check to see if the attribute exists and convert string to symbol for hash key
61
+ attributes = attributes.each_with_object({}) { |(k, v), h|
62
+ if (!self.class.attribute_map.key?(k.to_sym))
63
+ raise(
64
+ ArgumentError,
65
+ "`#{k}` is not a valid attribute in `Algolia::AzureOpenAIProviderInput`. Please check the name to make sure it's valid. List of attributes: " +
66
+ self.class.attribute_map.keys.inspect
67
+ )
68
+ end
69
+
70
+ h[k.to_sym] = v
71
+ }
72
+
73
+ if attributes.key?(:api_key)
74
+ self.api_key = attributes[:api_key]
75
+ else
76
+ self.api_key = nil
77
+ end
78
+
79
+ if attributes.key?(:azure_endpoint)
80
+ self.azure_endpoint = attributes[:azure_endpoint]
81
+ else
82
+ self.azure_endpoint = nil
83
+ end
84
+
85
+ if attributes.key?(:azure_deployment)
86
+ self.azure_deployment = attributes[:azure_deployment]
87
+ else
88
+ self.azure_deployment = nil
89
+ end
90
+
91
+ if attributes.key?(:api_version)
92
+ self.api_version = attributes[:api_version]
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
+ api_key == other.api_key &&
102
+ azure_endpoint == other.azure_endpoint &&
103
+ azure_deployment == other.azure_deployment &&
104
+ api_version == other.api_version
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
+ [api_key, azure_endpoint, azure_deployment, api_version].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,209 @@
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
+ # Base input that all providers must have.
11
+ class BaseProviderInput
12
+ attr_accessor :api_key
13
+
14
+ # Attribute mapping from ruby-style variable name to JSON key.
15
+ def self.attribute_map
16
+ {
17
+ :api_key => :apiKey
18
+ }
19
+ end
20
+
21
+ # Attribute type mapping.
22
+ def self.types_mapping
23
+ {
24
+ :api_key => :"String"
25
+ }
26
+ end
27
+
28
+ # List of attributes with nullable: true
29
+ def self.openapi_nullable
30
+ Set.new(
31
+ []
32
+ )
33
+ end
34
+
35
+ # Initializes the object
36
+ # @param [Hash] attributes Model attributes in the form of hash
37
+ def initialize(attributes = {})
38
+ if (!attributes.is_a?(Hash))
39
+ raise(
40
+ ArgumentError,
41
+ "The input argument (attributes) must be a hash in `Algolia::BaseProviderInput` initialize method"
42
+ )
43
+ end
44
+
45
+ # check to see if the attribute exists and convert string to symbol for hash key
46
+ attributes = attributes.each_with_object({}) { |(k, v), h|
47
+ if (!self.class.attribute_map.key?(k.to_sym))
48
+ raise(
49
+ ArgumentError,
50
+ "`#{k}` is not a valid attribute in `Algolia::BaseProviderInput`. Please check the name to make sure it's valid. List of attributes: " +
51
+ self.class.attribute_map.keys.inspect
52
+ )
53
+ end
54
+
55
+ h[k.to_sym] = v
56
+ }
57
+
58
+ if attributes.key?(:api_key)
59
+ self.api_key = attributes[:api_key]
60
+ else
61
+ self.api_key = nil
62
+ end
63
+ end
64
+
65
+ # Checks equality by comparing each attribute.
66
+ # @param [Object] Object to be compared
67
+ def ==(other)
68
+ return true if self.equal?(other)
69
+ self.class == other.class &&
70
+ api_key == other.api_key
71
+ end
72
+
73
+ # @see the `==` method
74
+ # @param [Object] Object to be compared
75
+ def eql?(other)
76
+ self == other
77
+ end
78
+
79
+ # Calculates hash code according to all attributes.
80
+ # @return [Integer] Hash code
81
+ def hash
82
+ [api_key].hash
83
+ end
84
+
85
+ # Builds the object from hash
86
+ # @param [Hash] attributes Model attributes in the form of hash
87
+ # @return [Object] Returns the model itself
88
+ def self.build_from_hash(attributes)
89
+ return nil unless attributes.is_a?(Hash)
90
+ attributes = attributes.transform_keys(&:to_sym)
91
+ transformed_hash = {}
92
+ types_mapping.each_pair do |key, type|
93
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
94
+ transformed_hash[key.to_sym] = nil
95
+ elsif type =~ /\AArray<(.*)>/i
96
+ # check to ensure the input is an array given that the attribute
97
+ # is documented as an array but the input is not
98
+ if attributes[attribute_map[key]].is_a?(Array)
99
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
100
+ _deserialize(::Regexp.last_match(1), v)
101
+ }
102
+ end
103
+ elsif !attributes[attribute_map[key]].nil?
104
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
105
+ end
106
+ end
107
+
108
+ new(transformed_hash)
109
+ end
110
+
111
+ # Deserializes the data based on type
112
+ # @param string type Data type
113
+ # @param string value Value to be deserialized
114
+ # @return [Object] Deserialized data
115
+ def self._deserialize(type, value)
116
+ case type.to_sym
117
+ when :Time
118
+ Time.parse(value)
119
+ when :Date
120
+ Date.parse(value)
121
+ when :String
122
+ value.to_s
123
+ when :Integer
124
+ value.to_i
125
+ when :Float
126
+ value.to_f
127
+ when :Boolean
128
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
129
+ true
130
+ else
131
+ false
132
+ end
133
+
134
+ when :Object
135
+ # generic object (usually a Hash), return directly
136
+ value
137
+ when /\AArray<(?<inner_type>.+)>\z/
138
+ inner_type = Regexp.last_match[:inner_type]
139
+ value.map { |v| _deserialize(inner_type, v) }
140
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
141
+ k_type = Regexp.last_match[:k_type]
142
+ v_type = Regexp.last_match[:v_type]
143
+ {}.tap do |hash|
144
+ value.each do |k, v|
145
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
146
+ end
147
+ end
148
+ # model
149
+ else
150
+ # models (e.g. Pet) or oneOf
151
+ klass = Algolia::AgentStudio.const_get(type)
152
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
153
+ .build_from_hash(value)
154
+ end
155
+ end
156
+
157
+ # Returns the string representation of the object
158
+ # @return [String] String presentation of the object
159
+ def to_s
160
+ to_hash.to_s
161
+ end
162
+
163
+ # to_body is an alias to to_hash (backward compatibility)
164
+ # @return [Hash] Returns the object in the form of hash
165
+ def to_body
166
+ to_hash
167
+ end
168
+
169
+ def to_json(*_args)
170
+ to_hash.to_json
171
+ end
172
+
173
+ # Returns the object in the form of hash
174
+ # @return [Hash] Returns the object in the form of hash
175
+ def to_hash
176
+ hash = {}
177
+ self.class.attribute_map.each_pair do |attr, param|
178
+ value = send(attr)
179
+ if value.nil?
180
+ is_nullable = self.class.openapi_nullable.include?(attr)
181
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
182
+ end
183
+
184
+ hash[param] = _to_hash(value)
185
+ end
186
+
187
+ hash
188
+ end
189
+
190
+ # Outputs non-array value in the form of hash
191
+ # For object, use to_hash. Otherwise, just return the value
192
+ # @param [Object] value Any valid value
193
+ # @return [Hash] Returns the value in the form of hash
194
+ def _to_hash(value)
195
+ if value.is_a?(Array)
196
+ value.compact.map { |v| _to_hash(v) }
197
+ elsif value.is_a?(Hash)
198
+ {}.tap do |hash|
199
+ value.each { |k, v| hash[k] = _to_hash(v) }
200
+ end
201
+ elsif value.respond_to?(:to_hash)
202
+ value.to_hash
203
+ else
204
+ value
205
+ end
206
+ end
207
+ end
208
+ end
209
+ end