Skip to content

[API] Adds inference APIs #85

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
Jun 27, 2024
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
1 change: 1 addition & 0 deletions lib/elasticsearch-serverless/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def perform_request(method, path, params = {}, body = nil, headers = nil)
:esql,
:graph,
:indices,
:inference,
:ingest,
:license,
:logstash,
Expand Down
66 changes: 66 additions & 0 deletions lib/elasticsearch-serverless/api/inference/delete.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Licensed to Elasticsearch B.V. under one or more contributor
# license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Elasticsearch B.V. licenses this file to you under
# the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
# Auto generated from commit f284cc16f4d4b4289bc679aa1529bb504190fe80
# @see https://github.com/elastic/elasticsearch-specification
#
module ElasticsearchServerless
module API
module Inference
module Actions
# Delete an inference endpoint
# This functionality is Experimental and may be changed or removed
# completely in a future release. Elastic will take a best effort approach
# to fix any issues, but experimental features are not subject to the
# support SLA of official GA features.
#
# @option arguments [String] :task_type The task type
# @option arguments [String] :inference_id The inference Id (*Required*)
# @option arguments [Boolean] :dry_run When true, the endpoint is not deleted, and a list of ingest processors which reference this endpoint is returned
# @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
# @option arguments [Hash] :headers Custom HTTP headers
#
# @see https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-inference-api.html
#
def delete(arguments = {})
raise ArgumentError, "Required argument 'inference_id' missing" unless arguments[:inference_id]

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

body = nil

_task_type = arguments.delete(:task_type)

_inference_id = arguments.delete(:inference_id)

method = ElasticsearchServerless::API::HTTP_DELETE
path = if _task_type && _inference_id
"_inference/#{Utils.listify(_task_type)}/#{Utils.listify(_inference_id)}"
else
"_inference/#{Utils.listify(_inference_id)}"
end
params = Utils.process_params(arguments)

ElasticsearchServerless::API::Response.new(
perform_request(method, path, params, body, headers)
)
end
end
end
end
end
64 changes: 64 additions & 0 deletions lib/elasticsearch-serverless/api/inference/get.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Licensed to Elasticsearch B.V. under one or more contributor
# license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Elasticsearch B.V. licenses this file to you under
# the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
# Auto generated from commit f284cc16f4d4b4289bc679aa1529bb504190fe80
# @see https://github.com/elastic/elasticsearch-specification
#
module ElasticsearchServerless
module API
module Inference
module Actions
# Get an inference endpoint
# This functionality is Experimental and may be changed or removed
# completely in a future release. Elastic will take a best effort approach
# to fix any issues, but experimental features are not subject to the
# support SLA of official GA features.
#
# @option arguments [String] :task_type The task type
# @option arguments [String] :inference_id The inference Id
# @option arguments [Hash] :headers Custom HTTP headers
#
# @see https://www.elastic.co/guide/en/elasticsearch/reference/master/get-inference-api.html
#
def get(arguments = {})
arguments = arguments.clone
headers = arguments.delete(:headers) || {}

body = nil

_task_type = arguments.delete(:task_type)

_inference_id = arguments.delete(:inference_id)

method = ElasticsearchServerless::API::HTTP_GET
path = if _task_type && _inference_id
"_inference/#{Utils.listify(_task_type)}/#{Utils.listify(_inference_id)}"
elsif _inference_id
"_inference/#{Utils.listify(_inference_id)}"
else
"_inference"
end
params = {}

ElasticsearchServerless::API::Response.new(
perform_request(method, path, params, body, headers)
)
end
end
end
end
end
66 changes: 66 additions & 0 deletions lib/elasticsearch-serverless/api/inference/inference.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Licensed to Elasticsearch B.V. under one or more contributor
# license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Elasticsearch B.V. licenses this file to you under
# the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
# Auto generated from commit f284cc16f4d4b4289bc679aa1529bb504190fe80
# @see https://github.com/elastic/elasticsearch-specification
#
module ElasticsearchServerless
module API
module Inference
module Actions
# Perform inference on the service
# This functionality is Experimental and may be changed or removed
# completely in a future release. Elastic will take a best effort approach
# to fix any issues, but experimental features are not subject to the
# support SLA of official GA features.
#
# @option arguments [String] :task_type The task type
# @option arguments [String] :inference_id The inference Id (*Required*)
# @option arguments [Time] :timeout Specifies the amount of time to wait for the inference request to complete. Server default: 30s.
# @option arguments [Hash] :headers Custom HTTP headers
# @option arguments [Hash] :body request body
#
# @see https://www.elastic.co/guide/en/elasticsearch/reference/master/post-inference-api.html
#
def inference(arguments = {})
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)

method = ElasticsearchServerless::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 = Utils.process_params(arguments)

ElasticsearchServerless::API::Response.new(
perform_request(method, path, params, body, headers)
)
end
end
end
end
end
66 changes: 66 additions & 0 deletions lib/elasticsearch-serverless/api/inference/put.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Licensed to Elasticsearch B.V. under one or more contributor
# license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Elasticsearch B.V. licenses this file to you under
# the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
# Auto generated from commit f284cc16f4d4b4289bc679aa1529bb504190fe80
# @see https://github.com/elastic/elasticsearch-specification
#
module ElasticsearchServerless
module API
module Inference
module Actions
# Create an inference endpoint
# This functionality is Experimental and may be changed or removed
# completely in a future release. Elastic will take a best effort approach
# to fix any issues, but experimental features are not subject to the
# support SLA of official GA features.
#
# @option arguments [String] :task_type The task type
# @option arguments [String] :inference_id The inference Id (*Required*)
# @option arguments [Hash] :headers Custom HTTP headers
# @option arguments [Hash] :body inference_config
#
# @see https://www.elastic.co/guide/en/elasticsearch/reference/master/put-inference-api.html
#
def put(arguments = {})
raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
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)

method = ElasticsearchServerless::API::HTTP_PUT
path = if _task_type && _inference_id
"_inference/#{Utils.listify(_task_type)}/#{Utils.listify(_inference_id)}"
else
"_inference/#{Utils.listify(_inference_id)}"
end
params = {}

ElasticsearchServerless::API::Response.new(
perform_request(method, path, params, body, headers)
)
end
end
end
end
end
Loading