algolia 3.38.0 → 3.39.1

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.
@@ -9,8 +9,6 @@ module Algolia
9
9
  module Ingestion
10
10
  # API request body for updating a destination.
11
11
  class DestinationUpdate
12
- attr_accessor :type
13
-
14
12
  # Descriptive name for the resource.
15
13
  attr_accessor :name
16
14
 
@@ -24,7 +22,6 @@ module Algolia
24
22
  # Attribute mapping from ruby-style variable name to JSON key.
25
23
  def self.attribute_map
26
24
  {
27
- :type => :type,
28
25
  :name => :name,
29
26
  :input => :input,
30
27
  :authentication_id => :authenticationID,
@@ -35,9 +32,8 @@ module Algolia
35
32
  # Attribute type mapping.
36
33
  def self.types_mapping
37
34
  {
38
- :type => :"DestinationType",
39
35
  :name => :"String",
40
- :input => :"DestinationInput",
36
+ :input => :"DestinationUpdateInput",
41
37
  :authentication_id => :"String",
42
38
  :transformation_ids => :"Array<String>"
43
39
  }
@@ -73,10 +69,6 @@ module Algolia
73
69
  h[k.to_sym] = v
74
70
  }
75
71
 
76
- if attributes.key?(:type)
77
- self.type = attributes[:type]
78
- end
79
-
80
72
  if attributes.key?(:name)
81
73
  self.name = attributes[:name]
82
74
  end
@@ -101,7 +93,6 @@ module Algolia
101
93
  def ==(other)
102
94
  return true if self.equal?(other)
103
95
  self.class == other.class &&
104
- type == other.type &&
105
96
  name == other.name &&
106
97
  input == other.input &&
107
98
  authentication_id == other.authentication_id &&
@@ -117,7 +108,7 @@ module Algolia
117
108
  # Calculates hash code according to all attributes.
118
109
  # @return [Integer] Hash code
119
110
  def hash
120
- [type, name, input, authentication_id, transformation_ids].hash
111
+ [name, input, authentication_id, transformation_ids].hash
121
112
  end
122
113
 
123
114
  # Builds the object from hash
@@ -0,0 +1,228 @@
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
+ class DestinationUpdateInput
11
+ # Algolia index name (case-sensitive).
12
+ attr_accessor :index_name
13
+
14
+ attr_accessor :record_type
15
+
16
+ # Attributes from your source to exclude from Algolia records. Not all your data attributes will be useful for searching. Keeping your Algolia records small increases indexing and search performance. - Exclude nested attributes with `.` notation. For example, `foo.bar` indexes the `foo` attribute and all its children **except** the `bar` attribute. - Exclude attributes from arrays with `[i]`, where `i` is the index of the array element. For example, `foo.[0].bar` only excludes the `bar` attribute from the first element of the `foo` array, but indexes the complete `foo` attribute for all other elements. Use `*` as wildcard: `foo.[*].bar` excludes `bar` from all elements of the `foo` array.
17
+ attr_accessor :attributes_to_exclude
18
+
19
+ # Attribute mapping from ruby-style variable name to JSON key.
20
+ def self.attribute_map
21
+ {
22
+ :index_name => :indexName,
23
+ :record_type => :recordType,
24
+ :attributes_to_exclude => :attributesToExclude
25
+ }
26
+ end
27
+
28
+ # Attribute type mapping.
29
+ def self.types_mapping
30
+ {
31
+ :index_name => :"String",
32
+ :record_type => :"RecordType",
33
+ :attributes_to_exclude => :"Array<String>"
34
+ }
35
+ end
36
+
37
+ # List of attributes with nullable: true
38
+ def self.openapi_nullable
39
+ Set.new(
40
+ []
41
+ )
42
+ end
43
+
44
+ # Initializes the object
45
+ # @param [Hash] attributes Model attributes in the form of hash
46
+ def initialize(attributes = {})
47
+ if (!attributes.is_a?(Hash))
48
+ raise(
49
+ ArgumentError,
50
+ "The input argument (attributes) must be a hash in `Algolia::DestinationUpdateInput` initialize method"
51
+ )
52
+ end
53
+
54
+ # check to see if the attribute exists and convert string to symbol for hash key
55
+ attributes = attributes.each_with_object({}) { |(k, v), h|
56
+ if (!self.class.attribute_map.key?(k.to_sym))
57
+ raise(
58
+ ArgumentError,
59
+ "`#{k}` is not a valid attribute in `Algolia::DestinationUpdateInput`. Please check the name to make sure it's valid. List of attributes: " +
60
+ self.class.attribute_map.keys.inspect
61
+ )
62
+ end
63
+
64
+ h[k.to_sym] = v
65
+ }
66
+
67
+ if attributes.key?(:index_name)
68
+ self.index_name = attributes[:index_name]
69
+ end
70
+
71
+ if attributes.key?(:record_type)
72
+ self.record_type = attributes[:record_type]
73
+ end
74
+
75
+ if attributes.key?(:attributes_to_exclude)
76
+ if (value = attributes[:attributes_to_exclude]).is_a?(Array)
77
+ self.attributes_to_exclude = value
78
+ end
79
+ end
80
+ end
81
+
82
+ # Checks equality by comparing each attribute.
83
+ # @param [Object] Object to be compared
84
+ def ==(other)
85
+ return true if self.equal?(other)
86
+ self.class == other.class &&
87
+ index_name == other.index_name &&
88
+ record_type == other.record_type &&
89
+ attributes_to_exclude == other.attributes_to_exclude
90
+ end
91
+
92
+ # @see the `==` method
93
+ # @param [Object] Object to be compared
94
+ def eql?(other)
95
+ self == other
96
+ end
97
+
98
+ # Calculates hash code according to all attributes.
99
+ # @return [Integer] Hash code
100
+ def hash
101
+ [index_name, record_type, attributes_to_exclude].hash
102
+ end
103
+
104
+ # Builds the object from hash
105
+ # @param [Hash] attributes Model attributes in the form of hash
106
+ # @return [Object] Returns the model itself
107
+ def self.build_from_hash(attributes)
108
+ return nil unless attributes.is_a?(Hash)
109
+ attributes = attributes.transform_keys(&:to_sym)
110
+ transformed_hash = {}
111
+ types_mapping.each_pair do |key, type|
112
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
113
+ transformed_hash[key.to_sym] = nil
114
+ elsif type =~ /\AArray<(.*)>/i
115
+ # check to ensure the input is an array given that the attribute
116
+ # is documented as an array but the input is not
117
+ if attributes[attribute_map[key]].is_a?(Array)
118
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
119
+ _deserialize(::Regexp.last_match(1), v)
120
+ }
121
+ end
122
+ elsif !attributes[attribute_map[key]].nil?
123
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
124
+ end
125
+ end
126
+
127
+ new(transformed_hash)
128
+ end
129
+
130
+ # Deserializes the data based on type
131
+ # @param string type Data type
132
+ # @param string value Value to be deserialized
133
+ # @return [Object] Deserialized data
134
+ def self._deserialize(type, value)
135
+ case type.to_sym
136
+ when :Time
137
+ Time.parse(value)
138
+ when :Date
139
+ Date.parse(value)
140
+ when :String
141
+ value.to_s
142
+ when :Integer
143
+ value.to_i
144
+ when :Float
145
+ value.to_f
146
+ when :Boolean
147
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
148
+ true
149
+ else
150
+ false
151
+ end
152
+
153
+ when :Object
154
+ # generic object (usually a Hash), return directly
155
+ value
156
+ when /\AArray<(?<inner_type>.+)>\z/
157
+ inner_type = Regexp.last_match[:inner_type]
158
+ value.map { |v| _deserialize(inner_type, v) }
159
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
160
+ k_type = Regexp.last_match[:k_type]
161
+ v_type = Regexp.last_match[:v_type]
162
+ {}.tap do |hash|
163
+ value.each do |k, v|
164
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
165
+ end
166
+ end
167
+ # model
168
+ else
169
+ # models (e.g. Pet) or oneOf
170
+ klass = Algolia::Ingestion.const_get(type)
171
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
172
+ .build_from_hash(value)
173
+ end
174
+ end
175
+
176
+ # Returns the string representation of the object
177
+ # @return [String] String presentation of the object
178
+ def to_s
179
+ to_hash.to_s
180
+ end
181
+
182
+ # to_body is an alias to to_hash (backward compatibility)
183
+ # @return [Hash] Returns the object in the form of hash
184
+ def to_body
185
+ to_hash
186
+ end
187
+
188
+ def to_json(*_args)
189
+ to_hash.to_json
190
+ end
191
+
192
+ # Returns the object in the form of hash
193
+ # @return [Hash] Returns the object in the form of hash
194
+ def to_hash
195
+ hash = {}
196
+ self.class.attribute_map.each_pair do |attr, param|
197
+ value = send(attr)
198
+ if value.nil?
199
+ is_nullable = self.class.openapi_nullable.include?(attr)
200
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
201
+ end
202
+
203
+ hash[param] = _to_hash(value)
204
+ end
205
+
206
+ hash
207
+ end
208
+
209
+ # Outputs non-array value in the form of hash
210
+ # For object, use to_hash. Otherwise, just return the value
211
+ # @param [Object] value Any valid value
212
+ # @return [Hash] Returns the value in the form of hash
213
+ def _to_hash(value)
214
+ if value.is_a?(Array)
215
+ value.compact.map { |v| _to_hash(v) }
216
+ elsif value.is_a?(Hash)
217
+ {}.tap do |hash|
218
+ value.each { |k, v| hash[k] = _to_hash(v) }
219
+ end
220
+ elsif value.respond_to?(:to_hash)
221
+ value.to_hash
222
+ else
223
+ value
224
+ end
225
+ end
226
+ end
227
+ end
228
+ end
@@ -0,0 +1,227 @@
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
+ # Specific configuration attributes of an `algoliaIndex` source.
11
+ class SourceAlgoliaIndex
12
+ # Name of the Algolia index to read records from.
13
+ attr_accessor :index_name
14
+
15
+ # SQL-like filter expression applied while browsing the source index. See [filters](https://www.algolia.com/doc/api-reference/api-parameters/filters/).
16
+ attr_accessor :filters
17
+
18
+ # Attribute mapping from ruby-style variable name to JSON key.
19
+ def self.attribute_map
20
+ {
21
+ :index_name => :indexName,
22
+ :filters => :filters
23
+ }
24
+ end
25
+
26
+ # Returns the keys that uniquely identify this oneOf variant when present
27
+ def self.discriminator_attributes
28
+ [
29
+ :indexName
30
+ ]
31
+ end
32
+
33
+ # Attribute type mapping.
34
+ def self.types_mapping
35
+ {
36
+ :index_name => :"String",
37
+ :filters => :"String"
38
+ }
39
+ end
40
+
41
+ # List of attributes with nullable: true
42
+ def self.openapi_nullable
43
+ Set.new(
44
+ []
45
+ )
46
+ end
47
+
48
+ # Initializes the object
49
+ # @param [Hash] attributes Model attributes in the form of hash
50
+ def initialize(attributes = {})
51
+ if (!attributes.is_a?(Hash))
52
+ raise(
53
+ ArgumentError,
54
+ "The input argument (attributes) must be a hash in `Algolia::SourceAlgoliaIndex` initialize method"
55
+ )
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::SourceAlgoliaIndex`. 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?(:index_name)
72
+ self.index_name = attributes[:index_name]
73
+ else
74
+ self.index_name = nil
75
+ end
76
+
77
+ if attributes.key?(:filters)
78
+ self.filters = attributes[:filters]
79
+ end
80
+ end
81
+
82
+ # Checks equality by comparing each attribute.
83
+ # @param [Object] Object to be compared
84
+ def ==(other)
85
+ return true if self.equal?(other)
86
+ self.class == other.class &&
87
+ index_name == other.index_name &&
88
+ filters == other.filters
89
+ end
90
+
91
+ # @see the `==` method
92
+ # @param [Object] Object to be compared
93
+ def eql?(other)
94
+ self == other
95
+ end
96
+
97
+ # Calculates hash code according to all attributes.
98
+ # @return [Integer] Hash code
99
+ def hash
100
+ [index_name, filters].hash
101
+ end
102
+
103
+ # Builds the object from hash
104
+ # @param [Hash] attributes Model attributes in the form of hash
105
+ # @return [Object] Returns the model itself
106
+ def self.build_from_hash(attributes)
107
+ return nil unless attributes.is_a?(Hash)
108
+ attributes = attributes.transform_keys(&:to_sym)
109
+ transformed_hash = {}
110
+ types_mapping.each_pair do |key, type|
111
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
112
+ transformed_hash[key.to_sym] = nil
113
+ elsif type =~ /\AArray<(.*)>/i
114
+ # check to ensure the input is an array given that the attribute
115
+ # is documented as an array but the input is not
116
+ if attributes[attribute_map[key]].is_a?(Array)
117
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
118
+ _deserialize(::Regexp.last_match(1), v)
119
+ }
120
+ end
121
+ elsif !attributes[attribute_map[key]].nil?
122
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
123
+ end
124
+ end
125
+
126
+ new(transformed_hash)
127
+ end
128
+
129
+ # Deserializes the data based on type
130
+ # @param string type Data type
131
+ # @param string value Value to be deserialized
132
+ # @return [Object] Deserialized data
133
+ def self._deserialize(type, value)
134
+ case type.to_sym
135
+ when :Time
136
+ Time.parse(value)
137
+ when :Date
138
+ Date.parse(value)
139
+ when :String
140
+ value.to_s
141
+ when :Integer
142
+ value.to_i
143
+ when :Float
144
+ value.to_f
145
+ when :Boolean
146
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
147
+ true
148
+ else
149
+ false
150
+ end
151
+
152
+ when :Object
153
+ # generic object (usually a Hash), return directly
154
+ value
155
+ when /\AArray<(?<inner_type>.+)>\z/
156
+ inner_type = Regexp.last_match[:inner_type]
157
+ value.map { |v| _deserialize(inner_type, v) }
158
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
159
+ k_type = Regexp.last_match[:k_type]
160
+ v_type = Regexp.last_match[:v_type]
161
+ {}.tap do |hash|
162
+ value.each do |k, v|
163
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
164
+ end
165
+ end
166
+ # model
167
+ else
168
+ # models (e.g. Pet) or oneOf
169
+ klass = Algolia::Ingestion.const_get(type)
170
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
171
+ .build_from_hash(value)
172
+ end
173
+ end
174
+
175
+ # Returns the string representation of the object
176
+ # @return [String] String presentation of the object
177
+ def to_s
178
+ to_hash.to_s
179
+ end
180
+
181
+ # to_body is an alias to to_hash (backward compatibility)
182
+ # @return [Hash] Returns the object in the form of hash
183
+ def to_body
184
+ to_hash
185
+ end
186
+
187
+ def to_json(*_args)
188
+ to_hash.to_json
189
+ end
190
+
191
+ # Returns the object in the form of hash
192
+ # @return [Hash] Returns the object in the form of hash
193
+ def to_hash
194
+ hash = {}
195
+ self.class.attribute_map.each_pair do |attr, param|
196
+ value = send(attr)
197
+ if value.nil?
198
+ is_nullable = self.class.openapi_nullable.include?(attr)
199
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
200
+ end
201
+
202
+ hash[param] = _to_hash(value)
203
+ end
204
+
205
+ hash
206
+ end
207
+
208
+ # Outputs non-array value in the form of hash
209
+ # For object, use to_hash. Otherwise, just return the value
210
+ # @param [Object] value Any valid value
211
+ # @return [Hash] Returns the value in the form of hash
212
+ def _to_hash(value)
213
+ if value.is_a?(Array)
214
+ value.compact.map { |v| _to_hash(v) }
215
+ elsif value.is_a?(Hash)
216
+ {}.tap do |hash|
217
+ value.each { |k, v| hash[k] = _to_hash(v) }
218
+ end
219
+ elsif value.respond_to?(:to_hash)
220
+ value.to_hash
221
+ else
222
+ value
223
+ end
224
+ end
225
+ end
226
+ end
227
+ end
@@ -12,6 +12,7 @@ module Algolia
12
12
  # List of class defined in oneOf (OpenAPI v3)
13
13
  def openapi_one_of
14
14
  [
15
+ :"SourceAlgoliaIndex",
15
16
  :"SourceBigCommerce",
16
17
  :"SourceBigQuery",
17
18
  :"SourceCSV",
@@ -8,6 +8,7 @@ require "time"
8
8
  module Algolia
9
9
  module Ingestion
10
10
  class SourceType
11
+ ALGOLIA_INDEX = "algoliaIndex".freeze
11
12
  BIGCOMMERCE = "bigcommerce".freeze
12
13
  BIGQUERY = "bigquery".freeze
13
14
  COMMERCETOOLS = "commercetools".freeze
@@ -19,7 +20,18 @@ module Algolia
19
20
  PUSH = "push".freeze
20
21
 
21
22
  def self.all_vars
22
- @all_vars ||= [BIGCOMMERCE, BIGQUERY, COMMERCETOOLS, CSV, DOCKER, GA4_BIGQUERY_EXPORT, JSON, SHOPIFY, PUSH].freeze
23
+ @all_vars ||= [
24
+ ALGOLIA_INDEX,
25
+ BIGCOMMERCE,
26
+ BIGQUERY,
27
+ COMMERCETOOLS,
28
+ CSV,
29
+ DOCKER,
30
+ GA4_BIGQUERY_EXPORT,
31
+ JSON,
32
+ SHOPIFY,
33
+ PUSH
34
+ ].freeze
23
35
  end
24
36
 
25
37
  # Builds the enum from string