Skip to content

Commit 3af92c0

Browse files
committed
[API] Inference API: Renames model_id to inference_id
1 parent 51e81d3 commit 3af92c0

File tree

8 files changed

+52
-40
lines changed

8 files changed

+52
-40
lines changed

elasticsearch-api/lib/elasticsearch/api/actions/inference/delete_model.rb

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,34 +28,37 @@ module Actions
2828
# to fix any issues, but experimental features are not subject to the
2929
# support SLA of official GA features.
3030
#
31-
# @option arguments [String] :task_type The model task type
32-
# @option arguments [String] :model_id The model Id
31+
# @option arguments [String] :inference_id The model Id
32+
# @option arguments [String] :task_type The task type
3333
# @option arguments [Hash] :headers Custom HTTP headers
3434
#
3535
# @see https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-inference-api.html
3636
#
3737
def delete_model(arguments = {})
3838
request_opts = { endpoint: arguments[:endpoint] || 'inference.delete_model' }
3939

40-
defined_params = %i[task_type model_id].each_with_object({}) do |variable, set_variables|
40+
defined_params = %i[inference_id task_type].each_with_object({}) do |variable, set_variables|
4141
set_variables[variable] = arguments[variable] if arguments.key?(variable)
4242
end
4343
request_opts[:defined_params] = defined_params unless defined_params.empty?
4444

45-
raise ArgumentError, "Required argument 'task_type' missing" unless arguments[:task_type]
46-
raise ArgumentError, "Required argument 'model_id' missing" unless arguments[:model_id]
45+
raise ArgumentError, "Required argument 'inference_id' missing" unless arguments[:inference_id]
4746

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

5150
body = nil
5251

53-
_task_type = arguments.delete(:task_type)
52+
_inference_id = arguments.delete(:inference_id)
5453

55-
_model_id = arguments.delete(:model_id)
54+
_task_type = arguments.delete(:task_type)
5655

5756
method = Elasticsearch::API::HTTP_DELETE
58-
path = "_inference/#{Utils.__listify(_task_type)}/#{Utils.__listify(_model_id)}"
57+
path = if _task_type && _inference_id
58+
"_inference/#{Utils.__listify(_task_type)}/#{Utils.__listify(_inference_id)}"
59+
else
60+
"_inference/#{Utils.__listify(_inference_id)}"
61+
end
5962
params = {}
6063

6164
Elasticsearch::API::Response.new(

elasticsearch-api/lib/elasticsearch/api/actions/inference/get_model.rb

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,34 +28,37 @@ module Actions
2828
# to fix any issues, but experimental features are not subject to the
2929
# support SLA of official GA features.
3030
#
31-
# @option arguments [String] :task_type The model task type
32-
# @option arguments [String] :model_id The model Id
31+
# @option arguments [String] :inference_id The inference Id
32+
# @option arguments [String] :task_type The task type
3333
# @option arguments [Hash] :headers Custom HTTP headers
3434
#
3535
# @see https://www.elastic.co/guide/en/elasticsearch/reference/current/get-inference-api.html
3636
#
3737
def get_model(arguments = {})
3838
request_opts = { endpoint: arguments[:endpoint] || 'inference.get_model' }
3939

40-
defined_params = %i[task_type model_id].each_with_object({}) do |variable, set_variables|
40+
defined_params = %i[inference_id task_type].each_with_object({}) do |variable, set_variables|
4141
set_variables[variable] = arguments[variable] if arguments.key?(variable)
4242
end
4343
request_opts[:defined_params] = defined_params unless defined_params.empty?
4444

45-
raise ArgumentError, "Required argument 'task_type' missing" unless arguments[:task_type]
46-
raise ArgumentError, "Required argument 'model_id' missing" unless arguments[:model_id]
45+
raise ArgumentError, "Required argument 'inference_id' missing" unless arguments[:inference_id]
4746

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

5150
body = nil
5251

53-
_task_type = arguments.delete(:task_type)
52+
_inference_id = arguments.delete(:inference_id)
5453

55-
_model_id = arguments.delete(:model_id)
54+
_task_type = arguments.delete(:task_type)
5655

5756
method = Elasticsearch::API::HTTP_GET
58-
path = "_inference/#{Utils.__listify(_task_type)}/#{Utils.__listify(_model_id)}"
57+
path = if _task_type && _inference_id
58+
"_inference/#{Utils.__listify(_task_type)}/#{Utils.__listify(_inference_id)}"
59+
else
60+
"_inference/#{Utils.__listify(_inference_id)}"
61+
end
5962
params = {}
6063

6164
Elasticsearch::API::Response.new(

elasticsearch-api/lib/elasticsearch/api/actions/inference/inference.rb

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ module Actions
2828
# to fix any issues, but experimental features are not subject to the
2929
# support SLA of official GA features.
3030
#
31-
# @option arguments [String] :task_type The model task type
32-
# @option arguments [String] :model_id The model Id
31+
# @option arguments [String] :inference_id The inference Id
32+
# @option arguments [String] :task_type The task type
3333
# @option arguments [Hash] :headers Custom HTTP headers
3434
# @option arguments [Hash] :body The inference payload
3535
#
@@ -38,25 +38,28 @@ module Actions
3838
def inference(arguments = {})
3939
request_opts = { endpoint: arguments[:endpoint] || 'inference.inference' }
4040

41-
defined_params = %i[task_type model_id].each_with_object({}) do |variable, set_variables|
41+
defined_params = %i[inference_id task_type].each_with_object({}) do |variable, set_variables|
4242
set_variables[variable] = arguments[variable] if arguments.key?(variable)
4343
end
4444
request_opts[:defined_params] = defined_params unless defined_params.empty?
4545

46-
raise ArgumentError, "Required argument 'task_type' missing" unless arguments[:task_type]
47-
raise ArgumentError, "Required argument 'model_id' missing" unless arguments[:model_id]
46+
raise ArgumentError, "Required argument 'inference_id' missing" unless arguments[:inference_id]
4847

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

5251
body = arguments.delete(:body)
5352

54-
_task_type = arguments.delete(:task_type)
53+
_inference_id = arguments.delete(:inference_id)
5554

56-
_model_id = arguments.delete(:model_id)
55+
_task_type = arguments.delete(:task_type)
5756

5857
method = Elasticsearch::API::HTTP_POST
59-
path = "_inference/#{Utils.__listify(_task_type)}/#{Utils.__listify(_model_id)}"
58+
path = if _task_type && _inference_id
59+
"_inference/#{Utils.__listify(_task_type)}/#{Utils.__listify(_inference_id)}"
60+
else
61+
"_inference/#{Utils.__listify(_inference_id)}"
62+
end
6063
params = {}
6164

6265
Elasticsearch::API::Response.new(

elasticsearch-api/lib/elasticsearch/api/actions/inference/put_model.rb

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ module Actions
2828
# to fix any issues, but experimental features are not subject to the
2929
# support SLA of official GA features.
3030
#
31-
# @option arguments [String] :task_type The model task type
32-
# @option arguments [String] :model_id The model Id
31+
# @option arguments [String] :inference_id The inference Id
32+
# @option arguments [String] :task_type The task type
3333
# @option arguments [Hash] :headers Custom HTTP headers
3434
# @option arguments [Hash] :body The model's task and service settings
3535
#
@@ -38,25 +38,28 @@ module Actions
3838
def put_model(arguments = {})
3939
request_opts = { endpoint: arguments[:endpoint] || 'inference.put_model' }
4040

41-
defined_params = %i[task_type model_id].each_with_object({}) do |variable, set_variables|
41+
defined_params = %i[inference_id task_type].each_with_object({}) do |variable, set_variables|
4242
set_variables[variable] = arguments[variable] if arguments.key?(variable)
4343
end
4444
request_opts[:defined_params] = defined_params unless defined_params.empty?
4545

46-
raise ArgumentError, "Required argument 'task_type' missing" unless arguments[:task_type]
47-
raise ArgumentError, "Required argument 'model_id' missing" unless arguments[:model_id]
46+
raise ArgumentError, "Required argument 'inference_id' missing" unless arguments[:inference_id]
4847

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

5251
body = arguments.delete(:body)
5352

54-
_task_type = arguments.delete(:task_type)
53+
_inference_id = arguments.delete(:inference_id)
5554

56-
_model_id = arguments.delete(:model_id)
55+
_task_type = arguments.delete(:task_type)
5756

5857
method = Elasticsearch::API::HTTP_PUT
59-
path = "_inference/#{Utils.__listify(_task_type)}/#{Utils.__listify(_model_id)}"
58+
path = if _task_type && _inference_id
59+
"_inference/#{Utils.__listify(_task_type)}/#{Utils.__listify(_inference_id)}"
60+
else
61+
"_inference/#{Utils.__listify(_inference_id)}"
62+
end
6063
params = {}
6164

6265
Elasticsearch::API::Response.new(

elasticsearch-api/spec/elasticsearch/api/actions/inference/delete_model_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
{},
2626
nil,
2727
{},
28-
{ defined_params: { model_id: 'bar', task_type: 'foo' },
28+
{ defined_params: { inference_id: 'bar', task_type: 'foo' },
2929
endpoint: 'inference.delete_model' }
3030
]
3131
end
3232

3333
it 'performs the request' do
34-
expect(client_double.inference.delete_model(task_type: 'foo', model_id: 'bar')).to be_a Elasticsearch::API::Response
34+
expect(client_double.inference.delete_model(task_type: 'foo', inference_id: 'bar')).to be_a Elasticsearch::API::Response
3535
end
3636
end

elasticsearch-api/spec/elasticsearch/api/actions/inference/get_model_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
{},
2626
nil,
2727
{},
28-
{ defined_params: { model_id: 'bar', task_type: 'foo' },
28+
{ defined_params: { inference_id: 'bar', task_type: 'foo' },
2929
endpoint: 'inference.get_model' }
3030
]
3131
end
3232

3333
it 'performs the request' do
34-
expect(client_double.inference.get_model(task_type: 'foo', model_id: 'bar')).to be_a Elasticsearch::API::Response
34+
expect(client_double.inference.get_model(task_type: 'foo', inference_id: 'bar')).to be_a Elasticsearch::API::Response
3535
end
3636
end

elasticsearch-api/spec/elasticsearch/api/actions/inference/inference_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
{},
2626
nil,
2727
{},
28-
{ defined_params: { model_id: 'bar', task_type: 'foo' },
28+
{ defined_params: { inference_id: 'bar', task_type: 'foo' },
2929
endpoint: 'inference.inference' }
3030
]
3131
end
3232

3333
it 'performs the request' do
34-
expect(client_double.inference.inference(task_type: 'foo', model_id: 'bar')).to be_a Elasticsearch::API::Response
34+
expect(client_double.inference.inference(task_type: 'foo', inference_id: 'bar')).to be_a Elasticsearch::API::Response
3535
end
3636
end

elasticsearch-api/spec/elasticsearch/api/actions/inference/put_model_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
{},
2626
nil,
2727
{},
28-
{ defined_params: { model_id: 'bar', task_type: 'foo' },
28+
{ defined_params: { inference_id: 'bar', task_type: 'foo' },
2929
endpoint: 'inference.put_model' }
3030
]
3131
end
3232

3333
it 'performs the request' do
34-
expect(client_double.inference.put_model(task_type: 'foo', model_id: 'bar')).to be_a Elasticsearch::API::Response
34+
expect(client_double.inference.put_model(task_type: 'foo', inference_id: 'bar')).to be_a Elasticsearch::API::Response
3535
end
3636
end

0 commit comments

Comments
 (0)