Skip to content

Commit c2c9968

Browse files
committed
[API] Adds inference APIs
1 parent 1090aa7 commit c2c9968

File tree

5 files changed

+263
-0
lines changed

5 files changed

+263
-0
lines changed

lib/elasticsearch-serverless/api.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ def perform_request(method, path, params = {}, body = nil, headers = nil)
6464
:esql,
6565
:graph,
6666
:indices,
67+
:inference,
6768
:ingest,
6869
:license,
6970
:logstash,
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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 commit f284cc16f4d4b4289bc679aa1529bb504190fe80
19+
# @see https://github.com/elastic/elasticsearch-specification
20+
#
21+
module ElasticsearchServerless
22+
module API
23+
module Inference
24+
module Actions
25+
# Delete an inference endpoint
26+
# This functionality is Experimental and may be changed or removed
27+
# completely in a future release. Elastic will take a best effort approach
28+
# to fix any issues, but experimental features are not subject to the
29+
# support SLA of official GA features.
30+
#
31+
# @option arguments [String] :task_type The task type
32+
# @option arguments [String] :inference_id The inference Id (*Required*)
33+
# @option arguments [Boolean] :dry_run When true, the endpoint is not deleted, and a list of ingest processors which reference this endpoint is returned
34+
# @option arguments [Boolean] :force When true, the inference endpoint is forcefully deleted even if it is still being used by ingest processors or semantic text fields
35+
# @option arguments [Hash] :headers Custom HTTP headers
36+
#
37+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-inference-api.html
38+
#
39+
def delete(arguments = {})
40+
raise ArgumentError, "Required argument 'inference_id' missing" unless arguments[:inference_id]
41+
42+
arguments = arguments.clone
43+
headers = arguments.delete(:headers) || {}
44+
45+
body = nil
46+
47+
_task_type = arguments.delete(:task_type)
48+
49+
_inference_id = arguments.delete(:inference_id)
50+
51+
method = ElasticsearchServerless::API::HTTP_DELETE
52+
path = if _task_type && _inference_id
53+
"_inference/#{Utils.listify(_task_type)}/#{Utils.listify(_inference_id)}"
54+
else
55+
"_inference/#{Utils.listify(_inference_id)}"
56+
end
57+
params = Utils.process_params(arguments)
58+
59+
ElasticsearchServerless::API::Response.new(
60+
perform_request(method, path, params, body, headers)
61+
)
62+
end
63+
end
64+
end
65+
end
66+
end
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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 commit f284cc16f4d4b4289bc679aa1529bb504190fe80
19+
# @see https://github.com/elastic/elasticsearch-specification
20+
#
21+
module ElasticsearchServerless
22+
module API
23+
module Inference
24+
module Actions
25+
# Get an inference endpoint
26+
# This functionality is Experimental and may be changed or removed
27+
# completely in a future release. Elastic will take a best effort approach
28+
# to fix any issues, but experimental features are not subject to the
29+
# support SLA of official GA features.
30+
#
31+
# @option arguments [String] :task_type The task type
32+
# @option arguments [String] :inference_id The inference Id
33+
# @option arguments [Hash] :headers Custom HTTP headers
34+
#
35+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/master/get-inference-api.html
36+
#
37+
def get(arguments = {})
38+
arguments = arguments.clone
39+
headers = arguments.delete(:headers) || {}
40+
41+
body = nil
42+
43+
_task_type = arguments.delete(:task_type)
44+
45+
_inference_id = arguments.delete(:inference_id)
46+
47+
method = ElasticsearchServerless::API::HTTP_GET
48+
path = if _task_type && _inference_id
49+
"_inference/#{Utils.listify(_task_type)}/#{Utils.listify(_inference_id)}"
50+
elsif _inference_id
51+
"_inference/#{Utils.listify(_inference_id)}"
52+
else
53+
"_inference"
54+
end
55+
params = {}
56+
57+
ElasticsearchServerless::API::Response.new(
58+
perform_request(method, path, params, body, headers)
59+
)
60+
end
61+
end
62+
end
63+
end
64+
end
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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 commit f284cc16f4d4b4289bc679aa1529bb504190fe80
19+
# @see https://github.com/elastic/elasticsearch-specification
20+
#
21+
module ElasticsearchServerless
22+
module API
23+
module Inference
24+
module Actions
25+
# Perform inference on the service
26+
# This functionality is Experimental and may be changed or removed
27+
# completely in a future release. Elastic will take a best effort approach
28+
# to fix any issues, but experimental features are not subject to the
29+
# support SLA of official GA features.
30+
#
31+
# @option arguments [String] :task_type The task type
32+
# @option arguments [String] :inference_id The inference Id (*Required*)
33+
# @option arguments [Time] :timeout Specifies the amount of time to wait for the inference request to complete. Server default: 30s.
34+
# @option arguments [Hash] :headers Custom HTTP headers
35+
# @option arguments [Hash] :body request body
36+
#
37+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/master/post-inference-api.html
38+
#
39+
def inference(arguments = {})
40+
raise ArgumentError, "Required argument 'inference_id' missing" unless arguments[:inference_id]
41+
42+
arguments = arguments.clone
43+
headers = arguments.delete(:headers) || {}
44+
45+
body = arguments.delete(:body)
46+
47+
_task_type = arguments.delete(:task_type)
48+
49+
_inference_id = arguments.delete(:inference_id)
50+
51+
method = ElasticsearchServerless::API::HTTP_POST
52+
path = if _task_type && _inference_id
53+
"_inference/#{Utils.listify(_task_type)}/#{Utils.listify(_inference_id)}"
54+
else
55+
"_inference/#{Utils.listify(_inference_id)}"
56+
end
57+
params = Utils.process_params(arguments)
58+
59+
ElasticsearchServerless::API::Response.new(
60+
perform_request(method, path, params, body, headers)
61+
)
62+
end
63+
end
64+
end
65+
end
66+
end
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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 commit f284cc16f4d4b4289bc679aa1529bb504190fe80
19+
# @see https://github.com/elastic/elasticsearch-specification
20+
#
21+
module ElasticsearchServerless
22+
module API
23+
module Inference
24+
module Actions
25+
# Create an inference endpoint
26+
# This functionality is Experimental and may be changed or removed
27+
# completely in a future release. Elastic will take a best effort approach
28+
# to fix any issues, but experimental features are not subject to the
29+
# support SLA of official GA features.
30+
#
31+
# @option arguments [String] :task_type The task type
32+
# @option arguments [String] :inference_id The inference Id (*Required*)
33+
# @option arguments [Hash] :headers Custom HTTP headers
34+
# @option arguments [Hash] :body inference_config
35+
#
36+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/master/put-inference-api.html
37+
#
38+
def put(arguments = {})
39+
raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
40+
raise ArgumentError, "Required argument 'inference_id' missing" unless arguments[:inference_id]
41+
42+
arguments = arguments.clone
43+
headers = arguments.delete(:headers) || {}
44+
45+
body = arguments.delete(:body)
46+
47+
_task_type = arguments.delete(:task_type)
48+
49+
_inference_id = arguments.delete(:inference_id)
50+
51+
method = ElasticsearchServerless::API::HTTP_PUT
52+
path = if _task_type && _inference_id
53+
"_inference/#{Utils.listify(_task_type)}/#{Utils.listify(_inference_id)}"
54+
else
55+
"_inference/#{Utils.listify(_inference_id)}"
56+
end
57+
params = {}
58+
59+
ElasticsearchServerless::API::Response.new(
60+
perform_request(method, path, params, body, headers)
61+
)
62+
end
63+
end
64+
end
65+
end
66+
end

0 commit comments

Comments
 (0)