Skip to content

Commit 438cee7

Browse files
committed
[API] Adds inference.put_custom
1 parent 9403077 commit 438cee7

File tree

2 files changed

+101
-0
lines changed

2 files changed

+101
-0
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Licensed to Elasticsearch B.V. under one or more contributor
2+
# license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright
4+
# ownership. Elasticsearch B.V. licenses this file to you under
5+
# the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
#
18+
# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80
19+
# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec
20+
#
21+
module Elasticsearch
22+
module API
23+
module Inference
24+
module Actions
25+
# Configure a custom inference endpoint
26+
#
27+
# @option arguments [String] :task_type The task type
28+
# @option arguments [String] :custom_inference_id The inference Id
29+
# @option arguments [Hash] :headers Custom HTTP headers
30+
# @option arguments [Hash] :body The inference endpoint's task and service settings
31+
#
32+
# @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-put-custom
33+
#
34+
def put_custom(arguments = {})
35+
request_opts = { endpoint: arguments[:endpoint] || 'inference.put_custom' }
36+
37+
defined_params = %i[task_type custom_inference_id].each_with_object({}) do |variable, set_variables|
38+
set_variables[variable] = arguments[variable] if arguments.key?(variable)
39+
end
40+
request_opts[:defined_params] = defined_params unless defined_params.empty?
41+
42+
raise ArgumentError, "Required argument 'task_type' missing" unless arguments[:task_type]
43+
raise ArgumentError, "Required argument 'custom_inference_id' missing" unless arguments[:custom_inference_id]
44+
45+
arguments = arguments.clone
46+
headers = arguments.delete(:headers) || {}
47+
48+
body = arguments.delete(:body)
49+
50+
_task_type = arguments.delete(:task_type)
51+
52+
_custom_inference_id = arguments.delete(:custom_inference_id)
53+
54+
method = Elasticsearch::API::HTTP_PUT
55+
path = "_inference/#{Utils.__listify(_task_type)}/#{Utils.__listify(_custom_inference_id)}"
56+
params = {}
57+
58+
Elasticsearch::API::Response.new(
59+
perform_request(method, path, params, body, headers, request_opts)
60+
)
61+
end
62+
end
63+
end
64+
end
65+
end
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Licensed to Elasticsearch B.V. under one or more contributor
2+
# license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright
4+
# ownership. Elasticsearch B.V. licenses this file to you under
5+
# the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
require 'spec_helper'
19+
20+
describe 'client#inference.put_custom' do
21+
let(:expected_args) do
22+
[
23+
'PUT',
24+
'_inference/foo/baz',
25+
{},
26+
nil,
27+
{},
28+
{ defined_params: { custom_inference_id: 'baz', task_type: 'foo' },
29+
endpoint: 'inference.put_custom' }
30+
]
31+
end
32+
33+
it 'performs the request' do
34+
expect(client_double.inference.put_custom(task_type: 'foo', custom_inference_id: 'baz')).to be_a Elasticsearch::API::Response
35+
end
36+
end

0 commit comments

Comments
 (0)