Skip to content

Commit 70f0e4e

Browse files
feat(specs): document runMetadata parameter (generated)
algolia/api-clients-automation#5087 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Devin Beeuwkes <[email protected]>
1 parent cea222a commit 70f0e4e

File tree

3 files changed

+239
-12
lines changed

3 files changed

+239
-12
lines changed

lib/algolia/api/ingestion_client.rb

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2322,9 +2322,10 @@ def run_source(source_id, run_source_payload = nil, request_options = {})
23222322
# - deleteIndex
23232323
# - editSettings
23242324
# @param task_id [String] Unique identifier of a task. (required)
2325+
# @param run_task_payload [RunTaskPayload]
23252326
# @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)
23262327
# @return [Http::Response] the response
2327-
def run_task_with_http_info(task_id, request_options = {})
2328+
def run_task_with_http_info(task_id, run_task_payload = nil, request_options = {})
23282329
# verify the required parameter 'task_id' is set
23292330
if @api_client.config.client_side_validation && task_id.nil?
23302331
raise ArgumentError, "Parameter `task_id` is required when calling `run_task`."
@@ -2336,7 +2337,7 @@ def run_task_with_http_info(task_id, request_options = {})
23362337
header_params = {}
23372338
header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?
23382339

2339-
post_body = request_options[:debug_body]
2340+
post_body = request_options[:debug_body] || @api_client.object_to_http_body(run_task_payload)
23402341

23412342
new_options = request_options.merge(
23422343
:operation => :"IngestionClient.run_task",
@@ -2356,10 +2357,11 @@ def run_task_with_http_info(task_id, request_options = {})
23562357
# - deleteIndex
23572358
# - editSettings
23582359
# @param task_id [String] Unique identifier of a task. (required)
2360+
# @param run_task_payload [RunTaskPayload]
23592361
# @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)
23602362
# @return [RunResponse]
2361-
def run_task(task_id, request_options = {})
2362-
response = run_task_with_http_info(task_id, request_options)
2363+
def run_task(task_id, run_task_payload = nil, request_options = {})
2364+
response = run_task_with_http_info(task_id, run_task_payload, request_options)
23632365
@api_client.deserialize(response.body, request_options[:debug_return_type] || "Ingestion::RunResponse")
23642366
end
23652367

@@ -2371,9 +2373,10 @@ def run_task(task_id, request_options = {})
23712373
# - editSettings
23722374
# THIS OPERATION IS DEPRECATED
23732375
# @param task_id [String] Unique identifier of a task. (required)
2376+
# @param run_task_payload [RunTaskPayload]
23742377
# @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)
23752378
# @return [Http::Response] the response
2376-
def run_task_v1_with_http_info(task_id, request_options = {})
2379+
def run_task_v1_with_http_info(task_id, run_task_payload = nil, request_options = {})
23772380
# verify the required parameter 'task_id' is set
23782381
if @api_client.config.client_side_validation && task_id.nil?
23792382
raise ArgumentError, "Parameter `task_id` is required when calling `run_task_v1`."
@@ -2385,7 +2388,7 @@ def run_task_v1_with_http_info(task_id, request_options = {})
23852388
header_params = {}
23862389
header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?
23872390

2388-
post_body = request_options[:debug_body]
2391+
post_body = request_options[:debug_body] || @api_client.object_to_http_body(run_task_payload)
23892392

23902393
new_options = request_options.merge(
23912394
:operation => :"IngestionClient.run_task_v1",
@@ -2405,10 +2408,11 @@ def run_task_v1_with_http_info(task_id, request_options = {})
24052408
# - deleteIndex
24062409
# - editSettings
24072410
# @param task_id [String] Unique identifier of a task. (required)
2411+
# @param run_task_payload [RunTaskPayload]
24082412
# @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)
24092413
# @return [RunResponse]
2410-
def run_task_v1(task_id, request_options = {})
2411-
response = run_task_v1_with_http_info(task_id, request_options)
2414+
def run_task_v1(task_id, run_task_payload = nil, request_options = {})
2415+
response = run_task_v1_with_http_info(task_id, run_task_payload, request_options)
24122416
@api_client.deserialize(response.body, request_options[:debug_return_type] || "Ingestion::RunResponse")
24132417
end
24142418

lib/algolia/models/ingestion/run_source_payload.rb

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,17 @@ class RunSourcePayload
1919

2020
attr_accessor :entity_type
2121

22+
# Additional information that will be passed to the created runs.
23+
attr_accessor :run_metadata
24+
2225
# Attribute mapping from ruby-style variable name to JSON key.
2326
def self.attribute_map
2427
{
2528
:index_to_include => :indexToInclude,
2629
:index_to_exclude => :indexToExclude,
2730
:entity_ids => :entityIDs,
28-
:entity_type => :entityType
31+
:entity_type => :entityType,
32+
:run_metadata => :runMetadata
2933
}
3034
end
3135

@@ -35,7 +39,8 @@ def self.types_mapping
3539
:index_to_include => :"Array<String>",
3640
:index_to_exclude => :"Array<String>",
3741
:entity_ids => :"Array<String>",
38-
:entity_type => :"EntityType"
42+
:entity_type => :"EntityType",
43+
:run_metadata => :"Hash<String, Object>"
3944
}
4045
end
4146

@@ -90,6 +95,12 @@ def initialize(attributes = {})
9095
if attributes.key?(:entity_type)
9196
self.entity_type = attributes[:entity_type]
9297
end
98+
99+
if attributes.key?(:run_metadata)
100+
if (value = attributes[:run_metadata]).is_a?(Hash)
101+
self.run_metadata = value
102+
end
103+
end
93104
end
94105

95106
# Checks equality by comparing each attribute.
@@ -100,7 +111,8 @@ def ==(other)
100111
index_to_include == other.index_to_include &&
101112
index_to_exclude == other.index_to_exclude &&
102113
entity_ids == other.entity_ids &&
103-
entity_type == other.entity_type
114+
entity_type == other.entity_type &&
115+
run_metadata == other.run_metadata
104116
end
105117

106118
# @see the `==` method
@@ -112,7 +124,7 @@ def eql?(other)
112124
# Calculates hash code according to all attributes.
113125
# @return [Integer] Hash code
114126
def hash
115-
[index_to_include, index_to_exclude, entity_ids, entity_type].hash
127+
[index_to_include, index_to_exclude, entity_ids, entity_type, run_metadata].hash
116128
end
117129

118130
# Builds the object from hash
Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
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 RunTaskPayload
11+
# Additional information that will be passed to the created run.
12+
attr_accessor :run_metadata
13+
14+
# Attribute mapping from ruby-style variable name to JSON key.
15+
def self.attribute_map
16+
{
17+
:run_metadata => :runMetadata
18+
}
19+
end
20+
21+
# Attribute type mapping.
22+
def self.types_mapping
23+
{
24+
:run_metadata => :"Hash<String, Object>"
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::RunTaskPayload` 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::RunTaskPayload`. 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?(:run_metadata)
59+
if (value = attributes[:run_metadata]).is_a?(Hash)
60+
self.run_metadata = value
61+
end
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+
run_metadata == other.run_metadata
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+
[run_metadata].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::Ingestion.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+
208+
end
209+
210+
end
211+
end

0 commit comments

Comments
 (0)