From 958decbdc3d7df74c8d4514ba066fe7f0527cae3 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Thu, 3 Jul 2025 09:45:37 +0100 Subject: [PATCH 1/3] [API] Updates source code docs to 58fbe0ad87bb94a0870b7df4db76587fbfcaa5b7 --- .../lib/elasticsearch/api/actions/cat/recovery.rb | 7 ++++--- .../lib/elasticsearch/api/actions/cat/segments.rb | 5 +++-- .../lib/elasticsearch/api/actions/cat/snapshots.rb | 3 ++- .../lib/elasticsearch/api/actions/inference/put.rb | 1 + .../lib/elasticsearch/api/actions/snapshot/status.rb | 5 +++++ elasticsearch-api/lib/elasticsearch/api/version.rb | 2 +- 6 files changed, 16 insertions(+), 7 deletions(-) diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cat/recovery.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cat/recovery.rb index 1d2dfafce8..fff0d8e372 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cat/recovery.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cat/recovery.rb @@ -33,11 +33,12 @@ module Actions # @option arguments [Boolean] :active_only If `true`, the response only includes ongoing shard recoveries. # @option arguments [String] :bytes The unit used to display byte values. # @option arguments [Boolean] :detailed If `true`, the response includes detailed information about shard recoveries. - # @option arguments [String, Array] :h List of columns to appear in the response. Supports simple wildcards. - # @option arguments [String, Array] :s List of columns that determine how the table should be sorted. + # @option arguments [String, Array] :h A comma-separated list of columns names to display. + # It supports simple wildcards. Server default: ip,hp,rp,r,m,n,cpu,l. + # @option arguments [String, Array] :s A comma-separated list of column names or aliases that determines the sort order. # Sorting defaults to ascending and can be changed by setting `:asc` # or `:desc` as a suffix to the column name. - # @option arguments [String] :time Unit used to display time values. + # @option arguments [String] :time The unit used to display time values. # @option arguments [String] :format Specifies the format to return the columnar data in, can be set to # `text`, `json`, `cbor`, `yaml`, or `smile`. Server default: text. # @option arguments [Boolean] :help When set to `true` will output available columns. This option diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cat/segments.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cat/segments.rb index d4aac7e32d..73210c272b 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cat/segments.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cat/segments.rb @@ -31,8 +31,9 @@ module Actions # Supports wildcards (`*`). # To target all data streams and indices, omit this parameter or use `*` or `_all`. # @option arguments [String] :bytes The unit used to display byte values. - # @option arguments [String, Array] :h List of columns to appear in the response. Supports simple wildcards. - # @option arguments [String, Array] :s List of columns that determine how the table should be sorted. + # @option arguments [String, Array] :h A comma-separated list of columns names to display. + # It supports simple wildcards. Server default: ip,hp,rp,r,m,n,cpu,l. + # @option arguments [String, Array] :s A comma-separated list of column names or aliases that determines the sort order. # Sorting defaults to ascending and can be changed by setting `:asc` # or `:desc` as a suffix to the column name. # @option arguments [Boolean] :local If `true`, the request computes the list of selected nodes from the diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/cat/snapshots.rb b/elasticsearch-api/lib/elasticsearch/api/actions/cat/snapshots.rb index 51296ffab3..819d85ea77 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/cat/snapshots.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/cat/snapshots.rb @@ -32,7 +32,8 @@ module Actions # `_all` returns all repositories. # If any repository fails during the request, Elasticsearch returns an error. # @option arguments [Boolean] :ignore_unavailable If `true`, the response does not include information from unavailable snapshots. - # @option arguments [String, Array] :h List of columns to appear in the response. Supports simple wildcards. + # @option arguments [String, Array] :h A comma-separated list of columns names to display. + # It supports simple wildcards. Server default: ip,hp,rp,r,m,n,cpu,l. # @option arguments [String, Array] :s List of columns that determine how the table should be sorted. # Sorting defaults to ascending and can be changed by setting `:asc` # or `:desc` as a suffix to the column name. diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put.rb index 15809dde8a..bb543c9ff2 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put.rb @@ -33,6 +33,7 @@ module Actions # * Azure AI Studio (`completion`, `text_embedding`) # * Azure OpenAI (`completion`, `text_embedding`) # * Cohere (`completion`, `rerank`, `text_embedding`) + # * DeepSeek (`completion`, `chat_completion`) # * Elasticsearch (`rerank`, `sparse_embedding`, `text_embedding` - this service is for built-in models and models uploaded through Eland) # * ELSER (`sparse_embedding`) # * Google AI Studio (`completion`, `text_embedding`) diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/status.rb b/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/status.rb index 5011d182d2..94fe2018ec 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/status.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/snapshot/status.rb @@ -29,6 +29,11 @@ module Actions # If you omit the `` request path parameter, the request retrieves information only for currently running snapshots. # This usage is preferred. # If needed, you can specify `` and `` to retrieve information for specific snapshots, even if they're not currently running. + # Note that the stats will not be available for any shard snapshots in an ongoing snapshot completed by a node that (even momentarily) left the cluster. + # Loading the stats from the repository is an expensive operation (see the WARNING below). + # Therefore the stats values for such shards will be -1 even though the "stage" value will be "DONE", in order to minimize latency. + # A "description" field will be present for a shard snapshot completed by a departed node explaining why the shard snapshot's stats results are invalid. + # Consequently, the total stats for the index will be less than expected due to the missing values from these shards. # WARNING: Using the API to return the status of any snapshots other than currently running snapshots can be expensive. # The API requires a read from the repository for each shard in each snapshot. # For example, if you have 100 snapshots with 1,000 shards each, an API request that includes all snapshots will require 100,000 reads (100 snapshots x 1,000 shards). diff --git a/elasticsearch-api/lib/elasticsearch/api/version.rb b/elasticsearch-api/lib/elasticsearch/api/version.rb index aa75ce46e5..15a5c3826b 100644 --- a/elasticsearch-api/lib/elasticsearch/api/version.rb +++ b/elasticsearch-api/lib/elasticsearch/api/version.rb @@ -18,6 +18,6 @@ module Elasticsearch module API VERSION = '9.1.0'.freeze - ES_SPECIFICATION_COMMIT = 'cd2d1fba07d3224129ca5a8d6018d86f67004fdf'.freeze + ES_SPECIFICATION_COMMIT = '58fbe0ad87bb94a0870b7df4db76587fbfcaa5b7'.freeze end end From b631150a5836c6b93b2092fe1839f15b77f2af79 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Thu, 3 Jul 2025 09:47:36 +0100 Subject: [PATCH 2/3] [API] Adds inference.put_deepseek --- .../api/actions/inference/put_deepseek.rb | 81 +++++++++++++++++++ .../actions/inference/put_deepseek_spec.rb | 36 +++++++++ 2 files changed, 117 insertions(+) create mode 100644 elasticsearch-api/lib/elasticsearch/api/actions/inference/put_deepseek.rb create mode 100644 elasticsearch-api/spec/unit/actions/inference/put_deepseek_spec.rb diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_deepseek.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_deepseek.rb new file mode 100644 index 0000000000..45ba0bb95f --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_deepseek.rb @@ -0,0 +1,81 @@ +# 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. +# +# This code was automatically generated from the Elasticsearch Specification +# See https://github.com/elastic/elasticsearch-specification +# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. +module Elasticsearch + module API + module Inference + module Actions + # Create a DeepSeek inference endpoint. + # Create an inference endpoint to perform an inference task with the `deepseek` service. + # + # @option arguments [String] :task_type The type of the inference task that the model will perform. (*Required*) + # @option arguments [String] :deepseek_inference_id The unique identifier of the inference endpoint. (*Required*) + # @option arguments [Boolean] :error_trace When set to `true` Elasticsearch will include the full stack trace of errors + # when they occur. + # @option arguments [String, Array] :filter_path Comma-separated list of filters in dot notation which reduce the response + # returned by Elasticsearch. + # @option arguments [Boolean] :human When set to `true` will return statistics in a format suitable for humans. + # For example `"exists_time": "1h"` for humans and + # `"exists_time_in_millis": 3600000` for computers. When disabled the human + # readable values will be omitted. This makes sense for responses being consumed + # only by machines. + # @option arguments [Boolean] :pretty If set to `true` the returned JSON will be "pretty-formatted". Only use + # this option for debugging only. + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-put-deepseek + # + def put_deepseek(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'inference.put_deepseek' } + + defined_params = [:task_type, :deepseek_inference_id].each_with_object({}) do |variable, set_variables| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'task_type' missing" unless arguments[:task_type] + + unless arguments[:deepseek_inference_id] + raise ArgumentError, + "Required argument 'deepseek_inference_id' missing" + end + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _task_type = arguments.delete(:task_type) + + _deepseek_inference_id = arguments.delete(:deepseek_inference_id) + + method = Elasticsearch::API::HTTP_PUT + path = "_inference/#{Utils.listify(_task_type)}/#{Utils.listify(_deepseek_inference_id)}" + params = Utils.process_params(arguments) + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/spec/unit/actions/inference/put_deepseek_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_deepseek_spec.rb new file mode 100644 index 0000000000..25cbe4e72e --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/inference/put_deepseek_spec.rb @@ -0,0 +1,36 @@ +# 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. + +require 'spec_helper' + +describe 'client#inference.put_deepseek' do + let(:expected_args) do + [ + 'PUT', + '_inference/foo/bar', + {}, + nil, + {}, + { defined_params: { deepseek_inference_id: 'bar', task_type: 'foo' }, + endpoint: 'inference.put_deepseek' } + ] + end + + it 'performs the request' do + expect(client_double.inference.put_deepseek(task_type: 'foo', deepseek_inference_id: 'bar')).to be_a Elasticsearch::API::Response + end +end From fca7a6f7fbf543b4d954ee897ef64753521863d0 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Thu, 3 Jul 2025 11:14:45 +0100 Subject: [PATCH 3/3] [Test Runner] Updates perform_request_spec Don't fail, log when methods are not implemented yet --- .../spec/unit/perform_request_spec.rb | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/elasticsearch-api/spec/unit/perform_request_spec.rb b/elasticsearch-api/spec/unit/perform_request_spec.rb index a94e74ff14..59324aebc2 100644 --- a/elasticsearch-api/spec/unit/perform_request_spec.rb +++ b/elasticsearch-api/spec/unit/perform_request_spec.rb @@ -15,8 +15,9 @@ # specific language governing permissions and limitations # under the License. -require 'spec_helper' require 'elastic-transport' +require 'spec_helper' + require_relative File.expand_path('../../utils/thor/endpoint_spec', __dir__) require_relative File.expand_path('../../utils/thor/generator/files_helper', __dir__) @@ -28,10 +29,23 @@ # TODO: Once the test suite is migrated to elasticsearch-specification, these should be removed spec.module_namespace.flatten.first == 'rollup' || [ - 'scroll', 'clear_scroll', 'connector.last_sync', 'knn_search', - 'indices.remove_block' + 'scroll', 'clear_scroll', 'connector.last_sync', 'knn_search' ].include?(spec.endpoint_name) + # Skip testing if the method hasn't been added to the client yet: + client = Elasticsearch::Client.new + implemented = if spec.module_namespace.empty? + client.public_methods.include?(spec.method_name.to_sym) + else + client.public_methods.include?(spec.module_namespace[0].to_sym) && + client.send(spec.module_namespace[0]).methods.include?(spec.method_name.to_sym) + end + unless implemented + name = spec.module_namespace.empty? ? spec.method_name : "#{spec.module_namespace[0]}.#{spec.method_name}" + Logger.new($stdout).info("Method #{name} not implemented yet") + next + end + # These are the path parts defined by the user in the method argument defined_path_parts = spec.path_params.inject({}) do |params, part| params.merge(part => 'testing') @@ -68,7 +82,7 @@ end if spec.path_parts.empty? - it "passes the endpoint id to the request" do + it 'passes the endpoint id to the request' do if spec.module_namespace.empty? client_double.send(spec.method_name, required_params) else @@ -81,7 +95,9 @@ client_double.send(spec.method_name, required_params.merge(defined_path_parts)) else client_double.send( - spec.module_namespace[0]).send(spec.method_name, required_params.merge(defined_path_parts) + spec.module_namespace[0] + ).send( + spec.method_name, required_params.merge(defined_path_parts) ) end end