Skip to content

Auto-generated code for 8.18 #2634

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,37 +22,40 @@ module Elasticsearch
module API
module Inference
module Actions
# Configure an inference endpoint that uses the Elastic Inference Service (EIS)
# Perform inference
#
# @option arguments [String] :inference_id The inference Id
# @option arguments [String] :task_type The task type
# @option arguments [String] :eis_inference_id The inference ID
# @option arguments [Hash] :headers Custom HTTP headers
# @option arguments [Hash] :body The inference endpoint's task and service settings
# @option arguments [Hash] :body The inference payload
#
# @see https://www.elastic.co/guide/en/elasticsearch/reference/8.17/infer-service-elastic.html
# @see https://www.elastic.co/guide/en/elasticsearch/reference/8.17/post-inference-api.html
#
def put_eis(arguments = {})
request_opts = { endpoint: arguments[:endpoint] || 'inference.put_eis' }
def inference(arguments = {})
request_opts = { endpoint: arguments[:endpoint] || 'inference.inference' }

defined_params = %i[task_type eis_inference_id].each_with_object({}) do |variable, set_variables|
defined_params = %i[inference_id task_type].each_with_object({}) do |variable, set_variables|
set_variables[variable] = arguments[variable] if arguments.key?(variable)
end
request_opts[:defined_params] = defined_params unless defined_params.empty?

raise ArgumentError, "Required argument 'task_type' missing" unless arguments[:task_type]
raise ArgumentError, "Required argument 'eis_inference_id' missing" unless arguments[:eis_inference_id]
raise ArgumentError, "Required argument 'inference_id' missing" unless arguments[:inference_id]

arguments = arguments.clone
headers = arguments.delete(:headers) || {}

body = arguments.delete(:body)

_task_type = arguments.delete(:task_type)
_inference_id = arguments.delete(:inference_id)

_eis_inference_id = arguments.delete(:eis_inference_id)
_task_type = arguments.delete(:task_type)

method = Elasticsearch::API::HTTP_PUT
path = "_inference/#{Utils.__listify(_task_type)}/#{Utils.__listify(_eis_inference_id)}"
method = Elasticsearch::API::HTTP_POST
path = if _task_type && _inference_id
"_inference/#{Utils.__listify(_task_type)}/#{Utils.__listify(_inference_id)}"
else
"_inference/#{Utils.__listify(_inference_id)}"
end
params = {}

Elasticsearch::API::Response.new(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@

require 'spec_helper'

describe 'client#inference.put_eis' do
describe 'client#inference.inference' do
let(:expected_args) do
[
'PUT',
'POST',
'_inference/foo/bar',
{},
nil,
{},
{ defined_params: { eis_inference_id: 'bar', task_type: 'foo' },
endpoint: 'inference.put_eis' }
{ defined_params: { inference_id: 'bar', task_type: 'foo' },
endpoint: 'inference.inference' }
]
end

it 'performs the request' do
expect(client_double.inference.put_eis(task_type: 'foo', eis_inference_id: 'bar')).to be_a Elasticsearch::API::Response
expect(client_double.inference.inference(task_type: 'foo', inference_id: 'bar')).to be_a Elasticsearch::API::Response
end
end