Skip to content

Commit dec668e

Browse files
committed
[API] Adds inference.put_amazonsagemaker
1 parent 9431c9a commit dec668e

File tree

3 files changed

+119
-0
lines changed

3 files changed

+119
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ module Actions
2929
# The following integrations are available through the inference API. You can find the available task types next to the integration name:
3030
# * AlibabaCloud AI Search (`completion`, `rerank`, `sparse_embedding`, `text_embedding`)
3131
# * Amazon Bedrock (`completion`, `text_embedding`)
32+
# * Amazon SageMaker (`chat_completion`, `completion`, `rerank`, `sparse_embedding`, `text_embedding`)
3233
# * Anthropic (`completion`)
3334
# * Azure AI Studio (`completion`, `text_embedding`)
3435
# * Azure OpenAI (`completion`, `text_embedding`)
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
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+
# This code was automatically generated from the Elasticsearch Specification
19+
# See https://github.com/elastic/elasticsearch-specification
20+
# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash.
21+
module Elasticsearch
22+
module API
23+
module Inference
24+
module Actions
25+
# Create an Amazon SageMaker inference endpoint.
26+
# Create an inference endpoint to perform an inference task with the `amazon_sagemaker` service.
27+
#
28+
# @option arguments [String] :task_type The type of the inference task that the model will perform. (*Required*)
29+
# @option arguments [String] :amazonsagemaker_inference_id The unique identifier of the inference endpoint. (*Required*)
30+
# @option arguments [Time] :timeout Specifies the amount of time to wait for the inference endpoint to be created. Server default: 30s.
31+
# @option arguments [Boolean] :error_trace When set to `true` Elasticsearch will include the full stack trace of errors
32+
# when they occur.
33+
# @option arguments [String, Array<String>] :filter_path Comma-separated list of filters in dot notation which reduce the response
34+
# returned by Elasticsearch.
35+
# @option arguments [Boolean] :human When set to `true` will return statistics in a format suitable for humans.
36+
# For example `"exists_time": "1h"` for humans and
37+
# `"exists_time_in_millis": 3600000` for computers. When disabled the human
38+
# readable values will be omitted. This makes sense for responses being consumed
39+
# only by machines.
40+
# @option arguments [Boolean] :pretty If set to `true` the returned JSON will be "pretty-formatted". Only use
41+
# this option for debugging only.
42+
# @option arguments [Hash] :headers Custom HTTP headers
43+
# @option arguments [Hash] :body request body
44+
#
45+
# @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-put-amazonsagemaker
46+
#
47+
def put_amazonsagemaker(arguments = {})
48+
request_opts = { endpoint: arguments[:endpoint] || 'inference.put_amazonsagemaker' }
49+
50+
defined_params = [:task_type, :amazonsagemaker_inference_id].each_with_object({}) do |variable, set_variables|
51+
set_variables[variable] = arguments[variable] if arguments.key?(variable)
52+
end
53+
request_opts[:defined_params] = defined_params unless defined_params.empty?
54+
55+
raise ArgumentError, "Required argument 'task_type' missing" unless arguments[:task_type]
56+
57+
unless arguments[:amazonsagemaker_inference_id]
58+
raise ArgumentError,
59+
"Required argument 'amazonsagemaker_inference_id' missing"
60+
end
61+
62+
arguments = arguments.clone
63+
headers = arguments.delete(:headers) || {}
64+
65+
body = arguments.delete(:body)
66+
67+
_task_type = arguments.delete(:task_type)
68+
69+
_amazonsagemaker_inference_id = arguments.delete(:amazonsagemaker_inference_id)
70+
71+
method = Elasticsearch::API::HTTP_PUT
72+
path = "_inference/#{Utils.listify(_task_type)}/#{Utils.listify(_amazonsagemaker_inference_id)}"
73+
params = Utils.process_params(arguments)
74+
75+
Elasticsearch::API::Response.new(
76+
perform_request(method, path, params, body, headers, request_opts)
77+
)
78+
end
79+
end
80+
end
81+
end
82+
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_amazonsagemaker' do
21+
let(:expected_args) do
22+
[
23+
'PUT',
24+
'_inference/foo/bar',
25+
{},
26+
nil,
27+
{},
28+
{ defined_params: { amazonsagemaker_inference_id: 'bar', task_type: 'foo' },
29+
endpoint: 'inference.put_amazonsagemaker' }
30+
]
31+
end
32+
33+
it 'performs the request' do
34+
expect(client_double.inference.put_amazonsagemaker(task_type: 'foo', amazonsagemaker_inference_id: 'bar')).to be_a Elasticsearch::API::Response
35+
end
36+
end

0 commit comments

Comments
 (0)