algolia 3.16.0 → 3.18.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.
- checksums.yaml +4 -4
- data/.github/workflows/release.yml +1 -1
- data/CHANGELOG.md +14 -0
- data/Gemfile.lock +1 -1
- data/lib/algolia/api/ingestion_client.rb +63 -4
- data/lib/algolia/api/search_client.rb +2 -2
- data/lib/algolia/models/ingestion/transformation.rb +20 -2
- data/lib/algolia/models/ingestion/transformation_code.rb +212 -0
- data/lib/algolia/models/ingestion/transformation_create.rb +24 -4
- data/lib/algolia/models/ingestion/transformation_input.rb +110 -0
- data/lib/algolia/models/ingestion/transformation_no_code.rb +213 -0
- data/lib/algolia/models/ingestion/transformation_try.rb +1 -1
- data/lib/algolia/models/ingestion/transformation_type.rb +34 -0
- data/lib/algolia/models/ingestion/watch_response.rb +27 -7
- data/lib/algolia/models/recommend/typo_tolerance_enum.rb +3 -1
- data/lib/algolia/models/search/event.rb +281 -0
- data/lib/algolia/models/search/event_status.rb +38 -0
- data/lib/algolia/models/search/event_type.rb +36 -0
- data/lib/algolia/models/search/typo_tolerance_enum.rb +3 -1
- data/lib/algolia/models/search/watch_response.rb +265 -0
- data/lib/algolia/version.rb +1 -1
- metadata +9 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9cfef852f09fa892158dfa5646a677e6f5bd6a47aa649d79fe72e300585a69a2
|
4
|
+
data.tar.gz: 56d4eaeff8861511b24bb147044242d50db46efdf8316c2948507eae857d7574
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d7b274ed915307ed33e727e98d8203be3b1617bd12fa5969e6db593079616ead2de5ce062e8fc17c605e64777c6da7695eb5b92bfaa3305598032f33c61e9fe
|
7
|
+
data.tar.gz: 4b0149c96e2a05b5c8cbca0d336fadb398fa28e939909526c0d340d841a9ede02b79dc3695084f465d004412450448e56dbac727d40fe6d5e8f6f8b867c6b083
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
## [3.18.0](https://github.com/algolia/algoliasearch-client-ruby/compare/3.17.0...3.18.0)
|
2
|
+
|
3
|
+
- [835daccb48](https://github.com/algolia/api-clients-automation/commit/835daccb48) feat(specs): add with transformation helpers ([#4931](https://github.com/algolia/api-clients-automation/pull/4931)) by [@shortcuts](https://github.com/shortcuts/)
|
4
|
+
|
5
|
+
## [3.17.0](https://github.com/algolia/algoliasearch-client-ruby/compare/3.16.0...3.17.0)
|
6
|
+
|
7
|
+
- [9db03b532b](https://github.com/algolia/api-clients-automation/commit/9db03b532b) fix(specs): typo ([#4854](https://github.com/algolia/api-clients-automation/pull/4854)) by [@kai687](https://github.com/kai687/)
|
8
|
+
- [db02a51d50](https://github.com/algolia/api-clients-automation/commit/db02a51d50) chore(deps): dependencies 2025-05-19 ([#4853](https://github.com/algolia/api-clients-automation/pull/4853)) by [@algolia-bot](https://github.com/algolia-bot/)
|
9
|
+
- [90b49b1e1b](https://github.com/algolia/api-clients-automation/commit/90b49b1e1b) feat(specs): add global push endpoint ([#4855](https://github.com/algolia/api-clients-automation/pull/4855)) by [@shortcuts](https://github.com/shortcuts/)
|
10
|
+
- [cf416e6b91](https://github.com/algolia/api-clients-automation/commit/cf416e6b91) fix(specs): updated watchResponse ([#4879](https://github.com/algolia/api-clients-automation/pull/4879)) by [@shortcuts](https://github.com/shortcuts/)
|
11
|
+
- [06ad06e4a8](https://github.com/algolia/api-clients-automation/commit/06ad06e4a8) feat(specs): update transformation specs for no-code ([#4901](https://github.com/algolia/api-clients-automation/pull/4901)) by [@mehmetaligok](https://github.com/mehmetaligok/)
|
12
|
+
- [4ec0e13e28](https://github.com/algolia/api-clients-automation/commit/4ec0e13e28) fix(specs): more indexing actions to push ([#4930](https://github.com/algolia/api-clients-automation/pull/4930)) by [@shortcuts](https://github.com/shortcuts/)
|
13
|
+
- [1951e4d127](https://github.com/algolia/api-clients-automation/commit/1951e4d127) fix(specs): wrong ACL for getSettings ([#4933](https://github.com/algolia/api-clients-automation/pull/4933)) by [@kai687](https://github.com/kai687/)
|
14
|
+
|
1
15
|
## [3.16.0](https://github.com/algolia/algoliasearch-client-ruby/compare/3.15.5...3.16.0)
|
2
16
|
|
3
17
|
- [bebb56e0b9](https://github.com/algolia/api-clients-automation/commit/bebb56e0b9) fix(specs): add x-acl to insights endpoints ([#4822](https://github.com/algolia/api-clients-automation/pull/4822)) by [@kai687](https://github.com/kai687/)
|
data/Gemfile.lock
CHANGED
@@ -2138,14 +2138,73 @@ module Algolia
|
|
2138
2138
|
)
|
2139
2139
|
end
|
2140
2140
|
|
2141
|
-
#
|
2141
|
+
# Pushes records through the Pipeline, directly to an index. You can make the call synchronous by providing the `watch` parameter, for asynchronous calls, you can use the observability endpoints and/or debugger dashboard to see the status of your task. If you want to leverage the [pre-indexing data transformation](https://www.algolia.com/doc/guides/sending-and-managing-data/send-and-update-your-data/how-to/transform-your-data/), this is the recommended way of ingesting your records. This method is similar to `pushTask`, but requires an `indexName` instead of a `taskID`. If zero or many tasks are found, an error will be returned.
|
2142
|
+
#
|
2143
|
+
# Required API Key ACLs:
|
2144
|
+
# - addObject
|
2145
|
+
# - deleteIndex
|
2146
|
+
# - editSettings
|
2147
|
+
# @param index_name [String] Name of the index on which to perform the operation. (required)
|
2148
|
+
# @param push_task_payload [PushTaskPayload] (required)
|
2149
|
+
# @param watch [Boolean] When provided, the push operation will be synchronous and the API will wait for the ingestion to be finished before responding.
|
2150
|
+
# @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)
|
2151
|
+
# @return [Http::Response] the response
|
2152
|
+
def push_with_http_info(index_name, push_task_payload, watch = nil, request_options = {})
|
2153
|
+
# verify the required parameter 'index_name' is set
|
2154
|
+
if @api_client.config.client_side_validation && index_name.nil?
|
2155
|
+
raise ArgumentError, "Parameter `index_name` is required when calling `push`."
|
2156
|
+
end
|
2157
|
+
# verify the required parameter 'push_task_payload' is set
|
2158
|
+
if @api_client.config.client_side_validation && push_task_payload.nil?
|
2159
|
+
raise ArgumentError, "Parameter `push_task_payload` is required when calling `push`."
|
2160
|
+
end
|
2161
|
+
|
2162
|
+
path = "/1/push/{indexName}".sub("{" + "indexName" + "}", Transport.encode_uri(index_name.to_s))
|
2163
|
+
query_params = {}
|
2164
|
+
query_params[:watch] = watch unless watch.nil?
|
2165
|
+
query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
|
2166
|
+
header_params = {}
|
2167
|
+
header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?
|
2168
|
+
request_options[:timeout] ||= 180000
|
2169
|
+
request_options[:connect_timeout] ||= 180000
|
2170
|
+
|
2171
|
+
post_body = request_options[:debug_body] || @api_client.object_to_http_body(push_task_payload)
|
2172
|
+
|
2173
|
+
new_options = request_options.merge(
|
2174
|
+
:operation => :"IngestionClient.push",
|
2175
|
+
:header_params => header_params,
|
2176
|
+
:query_params => query_params,
|
2177
|
+
:body => post_body,
|
2178
|
+
:use_read_transporter => false
|
2179
|
+
)
|
2180
|
+
|
2181
|
+
@api_client.call_api(:POST, path, new_options)
|
2182
|
+
end
|
2183
|
+
|
2184
|
+
# Pushes records through the Pipeline, directly to an index. You can make the call synchronous by providing the `watch` parameter, for asynchronous calls, you can use the observability endpoints and/or debugger dashboard to see the status of your task. If you want to leverage the [pre-indexing data transformation](https://www.algolia.com/doc/guides/sending-and-managing-data/send-and-update-your-data/how-to/transform-your-data/), this is the recommended way of ingesting your records. This method is similar to `pushTask`, but requires an `indexName` instead of a `taskID`. If zero or many tasks are found, an error will be returned.
|
2185
|
+
#
|
2186
|
+
# Required API Key ACLs:
|
2187
|
+
# - addObject
|
2188
|
+
# - deleteIndex
|
2189
|
+
# - editSettings
|
2190
|
+
# @param index_name [String] Name of the index on which to perform the operation. (required)
|
2191
|
+
# @param push_task_payload [PushTaskPayload] (required)
|
2192
|
+
# @param watch [Boolean] When provided, the push operation will be synchronous and the API will wait for the ingestion to be finished before responding.
|
2193
|
+
# @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)
|
2194
|
+
# @return [WatchResponse]
|
2195
|
+
def push(index_name, push_task_payload, watch = nil, request_options = {})
|
2196
|
+
response = push_with_http_info(index_name, push_task_payload, watch, request_options)
|
2197
|
+
@api_client.deserialize(response.body, request_options[:debug_return_type] || "Ingestion::WatchResponse")
|
2198
|
+
end
|
2199
|
+
|
2200
|
+
# Pushes records through the Pipeline, directly to an index. You can make the call synchronous by providing the `watch` parameter, for asynchronous calls, you can use the observability endpoints and/or debugger dashboard to see the status of your task. If you want to leverage the [pre-indexing data transformation](https://www.algolia.com/doc/guides/sending-and-managing-data/send-and-update-your-data/how-to/transform-your-data/), this is the recommended way of ingesting your records. This method is similar to `push`, but requires a `taskID` instead of a `indexName`, which is useful when many `destinations` target the same `indexName`.
|
2142
2201
|
#
|
2143
2202
|
# Required API Key ACLs:
|
2144
2203
|
# - addObject
|
2145
2204
|
# - deleteIndex
|
2146
2205
|
# - editSettings
|
2147
2206
|
# @param task_id [String] Unique identifier of a task. (required)
|
2148
|
-
# @param push_task_payload [PushTaskPayload]
|
2207
|
+
# @param push_task_payload [PushTaskPayload] (required)
|
2149
2208
|
# @param watch [Boolean] When provided, the push operation will be synchronous and the API will wait for the ingestion to be finished before responding.
|
2150
2209
|
# @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)
|
2151
2210
|
# @return [Http::Response] the response
|
@@ -2181,14 +2240,14 @@ module Algolia
|
|
2181
2240
|
@api_client.call_api(:POST, path, new_options)
|
2182
2241
|
end
|
2183
2242
|
|
2184
|
-
#
|
2243
|
+
# Pushes records through the Pipeline, directly to an index. You can make the call synchronous by providing the `watch` parameter, for asynchronous calls, you can use the observability endpoints and/or debugger dashboard to see the status of your task. If you want to leverage the [pre-indexing data transformation](https://www.algolia.com/doc/guides/sending-and-managing-data/send-and-update-your-data/how-to/transform-your-data/), this is the recommended way of ingesting your records. This method is similar to `push`, but requires a `taskID` instead of a `indexName`, which is useful when many `destinations` target the same `indexName`.
|
2185
2244
|
#
|
2186
2245
|
# Required API Key ACLs:
|
2187
2246
|
# - addObject
|
2188
2247
|
# - deleteIndex
|
2189
2248
|
# - editSettings
|
2190
2249
|
# @param task_id [String] Unique identifier of a task. (required)
|
2191
|
-
# @param push_task_payload [PushTaskPayload]
|
2250
|
+
# @param push_task_payload [PushTaskPayload] (required)
|
2192
2251
|
# @param watch [Boolean] When provided, the push operation will be synchronous and the API will wait for the ingestion to be finished before responding.
|
2193
2252
|
# @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)
|
2194
2253
|
# @return [WatchResponse]
|
@@ -1501,7 +1501,7 @@ module Algolia
|
|
1501
1501
|
# Retrieves an object with non-null index settings.
|
1502
1502
|
#
|
1503
1503
|
# Required API Key ACLs:
|
1504
|
-
# -
|
1504
|
+
# - settings
|
1505
1505
|
# @param index_name [String] Name of the index on which to perform the operation. (required)
|
1506
1506
|
# @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)
|
1507
1507
|
# @return [Http::Response] the response
|
@@ -1533,7 +1533,7 @@ module Algolia
|
|
1533
1533
|
# Retrieves an object with non-null index settings.
|
1534
1534
|
#
|
1535
1535
|
# Required API Key ACLs:
|
1536
|
-
# -
|
1536
|
+
# - settings
|
1537
1537
|
# @param index_name [String] Name of the index on which to perform the operation. (required)
|
1538
1538
|
# @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)
|
1539
1539
|
# @return [SettingsResponse]
|
@@ -14,9 +14,13 @@ module Algolia
|
|
14
14
|
# The authentications associated with the current transformation.
|
15
15
|
attr_accessor :authentication_ids
|
16
16
|
|
17
|
-
#
|
17
|
+
# It is deprecated. Use the `input` field with proper `type` instead to specify the transformation code.
|
18
18
|
attr_accessor :code
|
19
19
|
|
20
|
+
attr_accessor :type
|
21
|
+
|
22
|
+
attr_accessor :input
|
23
|
+
|
20
24
|
# The uniquely identified name of your transformation.
|
21
25
|
attr_accessor :name
|
22
26
|
|
@@ -38,6 +42,8 @@ module Algolia
|
|
38
42
|
:transformation_id => :transformationID,
|
39
43
|
:authentication_ids => :authenticationIDs,
|
40
44
|
:code => :code,
|
45
|
+
:type => :type,
|
46
|
+
:input => :input,
|
41
47
|
:name => :name,
|
42
48
|
:description => :description,
|
43
49
|
:owner => :owner,
|
@@ -52,6 +58,8 @@ module Algolia
|
|
52
58
|
:transformation_id => :"String",
|
53
59
|
:authentication_ids => :"Array<String>",
|
54
60
|
:code => :"String",
|
61
|
+
:type => :"TransformationType",
|
62
|
+
:input => :"TransformationInput",
|
55
63
|
:name => :"String",
|
56
64
|
:description => :"String",
|
57
65
|
:owner => :"String",
|
@@ -110,6 +118,14 @@ module Algolia
|
|
110
118
|
self.code = nil
|
111
119
|
end
|
112
120
|
|
121
|
+
if attributes.key?(:type)
|
122
|
+
self.type = attributes[:type]
|
123
|
+
end
|
124
|
+
|
125
|
+
if attributes.key?(:input)
|
126
|
+
self.input = attributes[:input]
|
127
|
+
end
|
128
|
+
|
113
129
|
if attributes.key?(:name)
|
114
130
|
self.name = attributes[:name]
|
115
131
|
else
|
@@ -145,6 +161,8 @@ module Algolia
|
|
145
161
|
transformation_id == other.transformation_id &&
|
146
162
|
authentication_ids == other.authentication_ids &&
|
147
163
|
code == other.code &&
|
164
|
+
type == other.type &&
|
165
|
+
input == other.input &&
|
148
166
|
name == other.name &&
|
149
167
|
description == other.description &&
|
150
168
|
owner == other.owner &&
|
@@ -161,7 +179,7 @@ module Algolia
|
|
161
179
|
# Calculates hash code according to all attributes.
|
162
180
|
# @return [Integer] Hash code
|
163
181
|
def hash
|
164
|
-
[transformation_id, authentication_ids, code, name, description, owner, created_at, updated_at].hash
|
182
|
+
[transformation_id, authentication_ids, code, type, input, name, description, owner, created_at, updated_at].hash
|
165
183
|
end
|
166
184
|
|
167
185
|
# Builds the object from hash
|
@@ -0,0 +1,212 @@
|
|
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 Ingestion
|
10
|
+
# Input for a transformation that contains the source code of the transformation.
|
11
|
+
class TransformationCode
|
12
|
+
# The source code of the transformation.
|
13
|
+
attr_accessor :code
|
14
|
+
|
15
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
16
|
+
def self.attribute_map
|
17
|
+
{
|
18
|
+
:code => :code
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
# Attribute type mapping.
|
23
|
+
def self.types_mapping
|
24
|
+
{
|
25
|
+
:code => :"String"
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
# List of attributes with nullable: true
|
30
|
+
def self.openapi_nullable
|
31
|
+
Set.new(
|
32
|
+
[]
|
33
|
+
)
|
34
|
+
end
|
35
|
+
|
36
|
+
# Initializes the object
|
37
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
38
|
+
def initialize(attributes = {})
|
39
|
+
if (!attributes.is_a?(Hash))
|
40
|
+
raise(
|
41
|
+
ArgumentError,
|
42
|
+
"The input argument (attributes) must be a hash in `Algolia::TransformationCode` initialize method"
|
43
|
+
)
|
44
|
+
end
|
45
|
+
|
46
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
47
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
48
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
49
|
+
raise(
|
50
|
+
ArgumentError,
|
51
|
+
"`#{k}` is not a valid attribute in `Algolia::TransformationCode`. Please check the name to make sure it's valid. List of attributes: " +
|
52
|
+
self.class.attribute_map.keys.inspect
|
53
|
+
)
|
54
|
+
end
|
55
|
+
|
56
|
+
h[k.to_sym] = v
|
57
|
+
}
|
58
|
+
|
59
|
+
if attributes.key?(:code)
|
60
|
+
self.code = attributes[:code]
|
61
|
+
else
|
62
|
+
self.code = nil
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# Checks equality by comparing each attribute.
|
67
|
+
# @param [Object] Object to be compared
|
68
|
+
def ==(other)
|
69
|
+
return true if self.equal?(other)
|
70
|
+
self.class == other.class &&
|
71
|
+
code == other.code
|
72
|
+
end
|
73
|
+
|
74
|
+
# @see the `==` method
|
75
|
+
# @param [Object] Object to be compared
|
76
|
+
def eql?(other)
|
77
|
+
self == other
|
78
|
+
end
|
79
|
+
|
80
|
+
# Calculates hash code according to all attributes.
|
81
|
+
# @return [Integer] Hash code
|
82
|
+
def hash
|
83
|
+
[code].hash
|
84
|
+
end
|
85
|
+
|
86
|
+
# Builds the object from hash
|
87
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
88
|
+
# @return [Object] Returns the model itself
|
89
|
+
def self.build_from_hash(attributes)
|
90
|
+
return nil unless attributes.is_a?(Hash)
|
91
|
+
attributes = attributes.transform_keys(&:to_sym)
|
92
|
+
transformed_hash = {}
|
93
|
+
types_mapping.each_pair do |key, type|
|
94
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
95
|
+
transformed_hash[key.to_sym] = nil
|
96
|
+
elsif type =~ /\AArray<(.*)>/i
|
97
|
+
# check to ensure the input is an array given that the attribute
|
98
|
+
# is documented as an array but the input is not
|
99
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
100
|
+
transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
|
101
|
+
_deserialize(::Regexp.last_match(1), v)
|
102
|
+
}
|
103
|
+
end
|
104
|
+
elsif !attributes[attribute_map[key]].nil?
|
105
|
+
transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
new(transformed_hash)
|
110
|
+
end
|
111
|
+
|
112
|
+
# Deserializes the data based on type
|
113
|
+
# @param string type Data type
|
114
|
+
# @param string value Value to be deserialized
|
115
|
+
# @return [Object] Deserialized data
|
116
|
+
def self._deserialize(type, value)
|
117
|
+
case type.to_sym
|
118
|
+
when :Time
|
119
|
+
Time.parse(value)
|
120
|
+
when :Date
|
121
|
+
Date.parse(value)
|
122
|
+
when :String
|
123
|
+
value.to_s
|
124
|
+
when :Integer
|
125
|
+
value.to_i
|
126
|
+
when :Float
|
127
|
+
value.to_f
|
128
|
+
when :Boolean
|
129
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
130
|
+
true
|
131
|
+
else
|
132
|
+
false
|
133
|
+
end
|
134
|
+
|
135
|
+
when :Object
|
136
|
+
# generic object (usually a Hash), return directly
|
137
|
+
value
|
138
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
139
|
+
inner_type = Regexp.last_match[:inner_type]
|
140
|
+
value.map { |v| _deserialize(inner_type, v) }
|
141
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
142
|
+
k_type = Regexp.last_match[:k_type]
|
143
|
+
v_type = Regexp.last_match[:v_type]
|
144
|
+
{}.tap do |hash|
|
145
|
+
value.each do |k, v|
|
146
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
147
|
+
end
|
148
|
+
end
|
149
|
+
# model
|
150
|
+
else
|
151
|
+
# models (e.g. Pet) or oneOf
|
152
|
+
klass = Algolia::Ingestion.const_get(type)
|
153
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
|
154
|
+
.build_from_hash(value)
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
# Returns the string representation of the object
|
159
|
+
# @return [String] String presentation of the object
|
160
|
+
def to_s
|
161
|
+
to_hash.to_s
|
162
|
+
end
|
163
|
+
|
164
|
+
# to_body is an alias to to_hash (backward compatibility)
|
165
|
+
# @return [Hash] Returns the object in the form of hash
|
166
|
+
def to_body
|
167
|
+
to_hash
|
168
|
+
end
|
169
|
+
|
170
|
+
def to_json(*_args)
|
171
|
+
to_hash.to_json
|
172
|
+
end
|
173
|
+
|
174
|
+
# Returns the object in the form of hash
|
175
|
+
# @return [Hash] Returns the object in the form of hash
|
176
|
+
def to_hash
|
177
|
+
hash = {}
|
178
|
+
self.class.attribute_map.each_pair do |attr, param|
|
179
|
+
value = send(attr)
|
180
|
+
if value.nil?
|
181
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
182
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
183
|
+
end
|
184
|
+
|
185
|
+
hash[param] = _to_hash(value)
|
186
|
+
end
|
187
|
+
|
188
|
+
hash
|
189
|
+
end
|
190
|
+
|
191
|
+
# Outputs non-array value in the form of hash
|
192
|
+
# For object, use to_hash. Otherwise, just return the value
|
193
|
+
# @param [Object] value Any valid value
|
194
|
+
# @return [Hash] Returns the value in the form of hash
|
195
|
+
def _to_hash(value)
|
196
|
+
if value.is_a?(Array)
|
197
|
+
value.compact.map { |v| _to_hash(v) }
|
198
|
+
elsif value.is_a?(Hash)
|
199
|
+
{}.tap do |hash|
|
200
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
201
|
+
end
|
202
|
+
elsif value.respond_to?(:to_hash)
|
203
|
+
value.to_hash
|
204
|
+
else
|
205
|
+
value
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
end
|
210
|
+
|
211
|
+
end
|
212
|
+
end
|
@@ -9,12 +9,16 @@ module Algolia
|
|
9
9
|
module Ingestion
|
10
10
|
# API request body for creating a transformation.
|
11
11
|
class TransformationCreate
|
12
|
-
#
|
12
|
+
# It is deprecated. Use the `input` field with proper `type` instead to specify the transformation code.
|
13
13
|
attr_accessor :code
|
14
14
|
|
15
15
|
# The uniquely identified name of your transformation.
|
16
16
|
attr_accessor :name
|
17
17
|
|
18
|
+
attr_accessor :type
|
19
|
+
|
20
|
+
attr_accessor :input
|
21
|
+
|
18
22
|
# A descriptive name for your transformation of what it does.
|
19
23
|
attr_accessor :description
|
20
24
|
|
@@ -26,6 +30,8 @@ module Algolia
|
|
26
30
|
{
|
27
31
|
:code => :code,
|
28
32
|
:name => :name,
|
33
|
+
:type => :type,
|
34
|
+
:input => :input,
|
29
35
|
:description => :description,
|
30
36
|
:authentication_ids => :authenticationIDs
|
31
37
|
}
|
@@ -36,6 +42,8 @@ module Algolia
|
|
36
42
|
{
|
37
43
|
:code => :"String",
|
38
44
|
:name => :"String",
|
45
|
+
:type => :"TransformationType",
|
46
|
+
:input => :"TransformationInput",
|
39
47
|
:description => :"String",
|
40
48
|
:authentication_ids => :"Array<String>"
|
41
49
|
}
|
@@ -73,8 +81,6 @@ module Algolia
|
|
73
81
|
|
74
82
|
if attributes.key?(:code)
|
75
83
|
self.code = attributes[:code]
|
76
|
-
else
|
77
|
-
self.code = nil
|
78
84
|
end
|
79
85
|
|
80
86
|
if attributes.key?(:name)
|
@@ -83,6 +89,18 @@ module Algolia
|
|
83
89
|
self.name = nil
|
84
90
|
end
|
85
91
|
|
92
|
+
if attributes.key?(:type)
|
93
|
+
self.type = attributes[:type]
|
94
|
+
else
|
95
|
+
self.type = nil
|
96
|
+
end
|
97
|
+
|
98
|
+
if attributes.key?(:input)
|
99
|
+
self.input = attributes[:input]
|
100
|
+
else
|
101
|
+
self.input = nil
|
102
|
+
end
|
103
|
+
|
86
104
|
if attributes.key?(:description)
|
87
105
|
self.description = attributes[:description]
|
88
106
|
end
|
@@ -101,6 +119,8 @@ module Algolia
|
|
101
119
|
self.class == other.class &&
|
102
120
|
code == other.code &&
|
103
121
|
name == other.name &&
|
122
|
+
type == other.type &&
|
123
|
+
input == other.input &&
|
104
124
|
description == other.description &&
|
105
125
|
authentication_ids == other.authentication_ids
|
106
126
|
end
|
@@ -114,7 +134,7 @@ module Algolia
|
|
114
134
|
# Calculates hash code according to all attributes.
|
115
135
|
# @return [Integer] Hash code
|
116
136
|
def hash
|
117
|
-
[code, name, description, authentication_ids].hash
|
137
|
+
[code, name, type, input, description, authentication_ids].hash
|
118
138
|
end
|
119
139
|
|
120
140
|
# Builds the object from hash
|
@@ -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 Ingestion
|
10
|
+
# The input for the transformation, which can be either code or a no-code configuration.
|
11
|
+
module TransformationInput
|
12
|
+
class << self
|
13
|
+
# List of class defined in oneOf (OpenAPI v3)
|
14
|
+
def openapi_one_of
|
15
|
+
[
|
16
|
+
:"TransformationCode",
|
17
|
+
:"TransformationNoCode"
|
18
|
+
]
|
19
|
+
end
|
20
|
+
|
21
|
+
# Builds the object
|
22
|
+
# @param [Mixed] Data to be matched against the list of oneOf items
|
23
|
+
# @return [Object] Returns the model or the data itself
|
24
|
+
def build(data)
|
25
|
+
# Go through the list of oneOf items and attempt to identify the appropriate one.
|
26
|
+
# Note:
|
27
|
+
# - We do not attempt to check whether exactly one item matches.
|
28
|
+
# - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
|
29
|
+
# due to the way the deserialization is made in the base_object template (it just casts without verifying).
|
30
|
+
# - TODO: scalar values are de facto behaving as if they were nullable.
|
31
|
+
# - TODO: logging when debugging is set.
|
32
|
+
openapi_one_of.each do |klass|
|
33
|
+
begin
|
34
|
+
# "nullable: true"
|
35
|
+
next if klass == :AnyType
|
36
|
+
typed_data = find_and_cast_into_type(klass, data)
|
37
|
+
return typed_data if typed_data
|
38
|
+
# rescue all errors so we keep iterating even if the current item lookup raises
|
39
|
+
rescue
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
openapi_one_of.include?(:AnyType) ? data : nil
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
SchemaMismatchError = Class.new(StandardError)
|
49
|
+
|
50
|
+
def find_and_cast_into_type(klass, data)
|
51
|
+
return if data.nil?
|
52
|
+
|
53
|
+
case klass.to_s
|
54
|
+
when "Boolean"
|
55
|
+
return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
|
56
|
+
when "Float"
|
57
|
+
return data if data.instance_of?(Float)
|
58
|
+
when "Integer"
|
59
|
+
return data if data.instance_of?(Integer)
|
60
|
+
when "Time"
|
61
|
+
return Time.parse(data)
|
62
|
+
when "Date"
|
63
|
+
return Date.parse(data)
|
64
|
+
when "String"
|
65
|
+
return data if data.instance_of?(String)
|
66
|
+
# "type: object"
|
67
|
+
when "Object"
|
68
|
+
return data if data.instance_of?(Hash)
|
69
|
+
# "type: array"
|
70
|
+
when /\AArray<(?<sub_type>.+)>\z/
|
71
|
+
if data.instance_of?(Array)
|
72
|
+
sub_type = Regexp.last_match[:sub_type]
|
73
|
+
return data.map { |item| find_and_cast_into_type(sub_type, item) }
|
74
|
+
end
|
75
|
+
# "type: object" with "additionalProperties: { ... }"
|
76
|
+
when /\AHash<String, (?<sub_type>.+)>\z/
|
77
|
+
if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
|
78
|
+
sub_type = Regexp.last_match[:sub_type]
|
79
|
+
return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
|
80
|
+
end
|
81
|
+
# model
|
82
|
+
else
|
83
|
+
const = Algolia::Ingestion.const_get(klass)
|
84
|
+
if const
|
85
|
+
if const.respond_to?(:openapi_one_of)
|
86
|
+
# nested oneOf model
|
87
|
+
model = const.build(data)
|
88
|
+
elsif const.respond_to?(:discriminator_attributes)
|
89
|
+
if const.discriminator_attributes.all? { |attr| data.key?(attr) }
|
90
|
+
model = const.build_from_hash(data)
|
91
|
+
end
|
92
|
+
else
|
93
|
+
# maybe it's an enum, or doens't have discriminators
|
94
|
+
model = const.build_from_hash(data)
|
95
|
+
end
|
96
|
+
|
97
|
+
return model if model
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
# if no match by now, raise
|
102
|
+
raise
|
103
|
+
rescue
|
104
|
+
raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|
110
|
+
end
|