algolia 3.0.0.alpha.10 → 3.0.0.alpha.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.openapi-generator/FILES +2 -0
- data/CHANGELOG.md +9 -0
- data/Gemfile.lock +4 -4
- data/lib/algolia/models/ingestion/mapping_field_directive.rb +214 -0
- data/lib/algolia/models/ingestion/mapping_input.rb +213 -0
- data/lib/algolia/models/ingestion/mapping_kit_action.rb +235 -0
- data/lib/algolia/models/ingestion/on_demand_date_utils_input.rb +13 -4
- data/lib/algolia/models/ingestion/schedule_date_utils_input.rb +13 -4
- data/lib/algolia/models/recommend/base_search_response.rb +14 -4
- data/lib/algolia/models/recommend/recommendations_results.rb +11 -1
- data/lib/algolia/models/search/api_key_operation.rb +34 -0
- data/lib/algolia/models/search/base_search_response.rb +14 -4
- data/lib/algolia/models/search/browse_response.rb +11 -1
- data/lib/algolia/models/search/search_response.rb +11 -1
- data/lib/algolia/models/search/secured_api_key_restrictions.rb +248 -0
- data/lib/algolia/version.rb +1 -1
- metadata +7 -2
@@ -0,0 +1,248 @@
|
|
1
|
+
# Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
|
2
|
+
|
3
|
+
require 'date'
|
4
|
+
require 'time'
|
5
|
+
|
6
|
+
module Algolia
|
7
|
+
module Search
|
8
|
+
class SecuredAPIKeyRestrictions
|
9
|
+
attr_accessor :search_params
|
10
|
+
|
11
|
+
# Filters that apply to every search made with the secured API key. You can add extra filters at search time with the filters query parameter. For example, if you set the filter group:admin on your generated API key, and you add groups:press OR groups:visitors with the filters query parameter, your final search filter is equivalent to groups:admin AND (groups:press OR groups:visitors).
|
12
|
+
attr_accessor :filters
|
13
|
+
|
14
|
+
# Unix timestamp used to set the expiration date of the API key.
|
15
|
+
attr_accessor :valid_until
|
16
|
+
|
17
|
+
# Index names that can be queried.
|
18
|
+
attr_accessor :restrict_indices
|
19
|
+
|
20
|
+
# IPv4 network allowed to use the generated key. Use this to protect against API key leaking and reuse. You can only provide a single source, but you can specify a range of IPs (for example, 192.168.1.0/24).
|
21
|
+
attr_accessor :restrict_sources
|
22
|
+
|
23
|
+
# Unique user IP address. This can be useful when you want to impose a rate limit on specific users. By default, rate limits are set based on the IP address. This can become an issue when several users search from the same IP address. To avoid this, you can set a unique userToken for each user when generating their API key. This lets you restrict each user to a maximum number of API calls per hour, even if they share their IP with another user. Specifying the userToken in a secured API key is also a good security practice as it ensures users don't change it. Many features like Analytics, Personalization, and Dynamic Re-ranking rely on the authenticity of user identifiers. Setting the userToken at the API key level ensures that downstream services work as expected and prevents abuse.
|
24
|
+
attr_accessor :user_token
|
25
|
+
|
26
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
27
|
+
def self.attribute_map
|
28
|
+
{
|
29
|
+
:search_params => :searchParams,
|
30
|
+
:filters => :filters,
|
31
|
+
:valid_until => :validUntil,
|
32
|
+
:restrict_indices => :restrictIndices,
|
33
|
+
:restrict_sources => :restrictSources,
|
34
|
+
:user_token => :userToken
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
# Returns all the JSON keys this model knows about
|
39
|
+
def self.acceptable_attributes
|
40
|
+
attribute_map.values
|
41
|
+
end
|
42
|
+
|
43
|
+
# Attribute type mapping.
|
44
|
+
def self.types_mapping
|
45
|
+
{
|
46
|
+
:search_params => :SearchParamsObject,
|
47
|
+
:filters => :String,
|
48
|
+
:valid_until => :Integer,
|
49
|
+
:restrict_indices => :'Array<String>',
|
50
|
+
:restrict_sources => :String,
|
51
|
+
:user_token => :String
|
52
|
+
}
|
53
|
+
end
|
54
|
+
|
55
|
+
# List of attributes with nullable: true
|
56
|
+
def self.openapi_nullable
|
57
|
+
Set.new([])
|
58
|
+
end
|
59
|
+
|
60
|
+
# Initializes the object
|
61
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
62
|
+
def initialize(attributes = {})
|
63
|
+
unless attributes.is_a?(Hash)
|
64
|
+
raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::SecuredAPIKeyRestrictions` initialize method"
|
65
|
+
end
|
66
|
+
|
67
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
68
|
+
attributes = attributes.each_with_object({}) do |(k, v), h|
|
69
|
+
unless self.class.attribute_map.key?(k.to_sym)
|
70
|
+
raise ArgumentError,
|
71
|
+
"`#{k}` is not a valid attribute in `Algolia::SecuredAPIKeyRestrictions`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
72
|
+
end
|
73
|
+
|
74
|
+
h[k.to_sym] = v
|
75
|
+
end
|
76
|
+
|
77
|
+
if attributes.key?(:search_params)
|
78
|
+
self.search_params = attributes[:search_params]
|
79
|
+
end
|
80
|
+
|
81
|
+
if attributes.key?(:filters)
|
82
|
+
self.filters = attributes[:filters]
|
83
|
+
end
|
84
|
+
|
85
|
+
if attributes.key?(:valid_until)
|
86
|
+
self.valid_until = attributes[:valid_until]
|
87
|
+
end
|
88
|
+
|
89
|
+
if attributes.key?(:restrict_indices)
|
90
|
+
if (value = attributes[:restrict_indices]).is_a?(Array)
|
91
|
+
self.restrict_indices = value
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
if attributes.key?(:restrict_sources)
|
96
|
+
self.restrict_sources = attributes[:restrict_sources]
|
97
|
+
end
|
98
|
+
|
99
|
+
if attributes.key?(:user_token)
|
100
|
+
self.user_token = attributes[:user_token]
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
# Checks equality by comparing each attribute.
|
105
|
+
# @param [Object] Object to be compared
|
106
|
+
def ==(other)
|
107
|
+
return true if equal?(other)
|
108
|
+
|
109
|
+
self.class == other.class &&
|
110
|
+
search_params == other.search_params &&
|
111
|
+
filters == other.filters &&
|
112
|
+
valid_until == other.valid_until &&
|
113
|
+
restrict_indices == other.restrict_indices &&
|
114
|
+
restrict_sources == other.restrict_sources &&
|
115
|
+
user_token == other.user_token
|
116
|
+
end
|
117
|
+
|
118
|
+
# @see the `==` method
|
119
|
+
# @param [Object] Object to be compared
|
120
|
+
def eql?(other)
|
121
|
+
self == other
|
122
|
+
end
|
123
|
+
|
124
|
+
# Calculates hash code according to all attributes.
|
125
|
+
# @return [Integer] Hash code
|
126
|
+
def hash
|
127
|
+
[search_params, filters, valid_until, restrict_indices, restrict_sources, user_token].hash
|
128
|
+
end
|
129
|
+
|
130
|
+
# Builds the object from hash
|
131
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
132
|
+
# @return [Object] Returns the model itself
|
133
|
+
def self.build_from_hash(attributes)
|
134
|
+
return nil unless attributes.is_a?(Hash)
|
135
|
+
|
136
|
+
attributes = attributes.transform_keys(&:to_sym)
|
137
|
+
transformed_hash = {}
|
138
|
+
types_mapping.each_pair do |key, type|
|
139
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
140
|
+
transformed_hash[key.to_sym] = nil
|
141
|
+
elsif type =~ /\AArray<(.*)>/i
|
142
|
+
# check to ensure the input is an array given that the attribute
|
143
|
+
# is documented as an array but the input is not
|
144
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
145
|
+
transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v| _deserialize(::Regexp.last_match(1), v) }
|
146
|
+
end
|
147
|
+
elsif !attributes[attribute_map[key]].nil?
|
148
|
+
transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
|
149
|
+
end
|
150
|
+
end
|
151
|
+
new(transformed_hash)
|
152
|
+
end
|
153
|
+
|
154
|
+
# Deserializes the data based on type
|
155
|
+
# @param string type Data type
|
156
|
+
# @param string value Value to be deserialized
|
157
|
+
# @return [Object] Deserialized data
|
158
|
+
def self._deserialize(type, value)
|
159
|
+
case type.to_sym
|
160
|
+
when :Time
|
161
|
+
Time.parse(value)
|
162
|
+
when :Date
|
163
|
+
Date.parse(value)
|
164
|
+
when :String
|
165
|
+
value.to_s
|
166
|
+
when :Integer
|
167
|
+
value.to_i
|
168
|
+
when :Float
|
169
|
+
value.to_f
|
170
|
+
when :Boolean
|
171
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
172
|
+
true
|
173
|
+
else
|
174
|
+
false
|
175
|
+
end
|
176
|
+
when :Object
|
177
|
+
# generic object (usually a Hash), return directly
|
178
|
+
value
|
179
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
180
|
+
inner_type = Regexp.last_match[:inner_type]
|
181
|
+
value.map { |v| _deserialize(inner_type, v) }
|
182
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
183
|
+
k_type = Regexp.last_match[:k_type]
|
184
|
+
v_type = Regexp.last_match[:v_type]
|
185
|
+
{}.tap do |hash|
|
186
|
+
value.each do |k, v|
|
187
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
188
|
+
end
|
189
|
+
end
|
190
|
+
else # model
|
191
|
+
# models (e.g. Pet) or oneOf
|
192
|
+
klass = Algolia::Search.const_get(type)
|
193
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
# Returns the string representation of the object
|
198
|
+
# @return [String] String presentation of the object
|
199
|
+
def to_s
|
200
|
+
to_hash.to_s
|
201
|
+
end
|
202
|
+
|
203
|
+
# to_body is an alias to to_hash (backward compatibility)
|
204
|
+
# @return [Hash] Returns the object in the form of hash
|
205
|
+
def to_body
|
206
|
+
to_hash
|
207
|
+
end
|
208
|
+
|
209
|
+
def to_json(*_args)
|
210
|
+
to_hash.to_json
|
211
|
+
end
|
212
|
+
|
213
|
+
# Returns the object in the form of hash
|
214
|
+
# @return [Hash] Returns the object in the form of hash
|
215
|
+
def to_hash
|
216
|
+
hash = {}
|
217
|
+
self.class.attribute_map.each_pair do |attr, param|
|
218
|
+
value = send(attr)
|
219
|
+
if value.nil?
|
220
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
221
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
222
|
+
end
|
223
|
+
|
224
|
+
hash[param] = _to_hash(value)
|
225
|
+
end
|
226
|
+
hash
|
227
|
+
end
|
228
|
+
|
229
|
+
# Outputs non-array value in the form of hash
|
230
|
+
# For object, use to_hash. Otherwise, just return the value
|
231
|
+
# @param [Object] value Any valid value
|
232
|
+
# @return [Hash] Returns the value in the form of hash
|
233
|
+
def _to_hash(value)
|
234
|
+
if value.is_a?(Array)
|
235
|
+
value.compact.map { |v| _to_hash(v) }
|
236
|
+
elsif value.is_a?(Hash)
|
237
|
+
{}.tap do |hash|
|
238
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
239
|
+
end
|
240
|
+
elsif value.respond_to? :to_hash
|
241
|
+
value.to_hash
|
242
|
+
else
|
243
|
+
value
|
244
|
+
end
|
245
|
+
end
|
246
|
+
end
|
247
|
+
end
|
248
|
+
end
|
data/lib/algolia/version.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
|
2
2
|
|
3
3
|
module Algolia
|
4
|
-
VERSION = '3.0.0.alpha.
|
4
|
+
VERSION = '3.0.0.alpha.12'.freeze
|
5
5
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: algolia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.0.alpha.
|
4
|
+
version: 3.0.0.alpha.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Algolia
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -248,6 +248,9 @@ files:
|
|
248
248
|
- lib/algolia/models/ingestion/list_events_response.rb
|
249
249
|
- lib/algolia/models/ingestion/list_sources_response.rb
|
250
250
|
- lib/algolia/models/ingestion/list_tasks_response.rb
|
251
|
+
- lib/algolia/models/ingestion/mapping_field_directive.rb
|
252
|
+
- lib/algolia/models/ingestion/mapping_input.rb
|
253
|
+
- lib/algolia/models/ingestion/mapping_kit_action.rb
|
251
254
|
- lib/algolia/models/ingestion/mapping_type_csv.rb
|
252
255
|
- lib/algolia/models/ingestion/method_type.rb
|
253
256
|
- lib/algolia/models/ingestion/on_demand_date_utils_input.rb
|
@@ -474,6 +477,7 @@ files:
|
|
474
477
|
- lib/algolia/models/search/alternatives_as_exact.rb
|
475
478
|
- lib/algolia/models/search/anchoring.rb
|
476
479
|
- lib/algolia/models/search/api_key.rb
|
480
|
+
- lib/algolia/models/search/api_key_operation.rb
|
477
481
|
- lib/algolia/models/search/around_precision.rb
|
478
482
|
- lib/algolia/models/search/around_precision_from_value_inner.rb
|
479
483
|
- lib/algolia/models/search/around_radius.rb
|
@@ -608,6 +612,7 @@ files:
|
|
608
612
|
- lib/algolia/models/search/search_type_facet.rb
|
609
613
|
- lib/algolia/models/search/search_user_ids_params.rb
|
610
614
|
- lib/algolia/models/search/search_user_ids_response.rb
|
615
|
+
- lib/algolia/models/search/secured_api_key_restrictions.rb
|
611
616
|
- lib/algolia/models/search/semantic_search.rb
|
612
617
|
- lib/algolia/models/search/snippet_result.rb
|
613
618
|
- lib/algolia/models/search/snippet_result_option.rb
|