diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 5d6e59e7fc..d0cf267dfa 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -25,7 +25,7 @@ steps: transport: main env: RUBY_VERSION: '{{ matrix.ruby }}' - STACK_VERSION: 9.0.3-SNAPSHOT + STACK_VERSION: 9.0.5-SNAPSHOT ES_YAML_TESTS_BRANCH: '9.0' TRANSPORT_VERSION: '{{ matrix.transport }}' RUBY_SOURCE: '{{ matrix.ruby_source }}' diff --git a/.github/workflows/9.0.yml b/.github/workflows/9.0.yml index 79370cd40f..23577f5188 100644 --- a/.github/workflows/9.0.yml +++ b/.github/workflows/9.0.yml @@ -26,7 +26,7 @@ jobs: sudo sysctl -w vm.max_map_count=262144 - uses: elastic/elastic-github-actions/elasticsearch@master with: - stack-version: 9.0.3-SNAPSHOT + stack-version: 9.0.5-SNAPSHOT - uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} @@ -39,4 +39,4 @@ jobs: - name: elasticsearch run: cd elasticsearch && bundle exec rake test:all - name: elasticsearch-api - run: rake es:download_artifacts[9.0.3-SNAPSHOT] && cd elasticsearch-api && bundle exec rake test:all + run: rake es:download_artifacts[9.0.5-SNAPSHOT] && cd elasticsearch-api && bundle exec rake test:all diff --git a/.github/workflows/otel.yml b/.github/workflows/otel.yml index a34ee1f4d6..6be79e1cd4 100644 --- a/.github/workflows/otel.yml +++ b/.github/workflows/otel.yml @@ -28,7 +28,7 @@ jobs: sudo sysctl -w vm.max_map_count=262144 - uses: elastic/elastic-github-actions/elasticsearch@master with: - stack-version: 9.0.3-SNAPSHOT + stack-version: 9.0.5-SNAPSHOT - uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} @@ -41,4 +41,4 @@ jobs: - name: elasticsearch run: cd elasticsearch && bundle exec rake test:all - name: elasticsearch-api - run: rake es:download_artifacts[9.0.3-SNAPSHOT] && cd elasticsearch-api && bundle exec rake test:all + run: rake es:download_artifacts[9.0.5-SNAPSHOT] && cd elasticsearch-api && bundle exec rake test:all diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_custom.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_custom.rb new file mode 100644 index 0000000000..a8937cbb55 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_custom.rb @@ -0,0 +1,112 @@ +# 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 custom inference endpoint. + # The custom service gives more control over how to interact with external inference services that aren't explicitly supported through dedicated integrations. + # The custom service gives you the ability to define the headers, url, query parameters, request body, and secrets. + # The custom service supports the template replacement functionality, which enables you to define a template that can be replaced with the value associated with that key. + # Templates are portions of a string that start with `${` and end with `}`. + # The parameters `secret_parameters` and `task_settings` are checked for keys for template replacement. Template replacement is supported in the `request`, `headers`, `url`, and `query_parameters`. + # If the definition (key) is not found for a template, an error message is returned. + # In case of an endpoint definition like the following: + # + # ``` + # PUT _inference/text_embedding/test-text-embedding + # { + # "service": "custom", + # "service_settings": { + # "secret_parameters": { + # "api_key": "" + # }, + # "url": "...endpoints.huggingface.cloud/v1/embeddings", + # "headers": { + # "Authorization": "Bearer ${api_key}", + # "Content-Type": "application/json" + # }, + # "request": "{\"input\": ${input}}", + # "response": { + # "json_parser": { + # "text_embeddings":"$.data[*].embedding[*]" + # } + # } + # } + # } + # ``` + # + # To replace `${api_key}` the `secret_parameters` and `task_settings` are checked for a key named `api_key`. + # + # @option arguments [String] :task_type The type of the inference task that the model will perform. (*Required*) + # @option arguments [String] :custom_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-custom + # + def put_custom(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'inference.put_custom' } + + defined_params = [:task_type, :custom_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[:custom_inference_id] + raise ArgumentError, + "Required argument 'custom_inference_id' missing" + end + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _task_type = arguments.delete(:task_type) + + _custom_inference_id = arguments.delete(:custom_inference_id) + + method = Elasticsearch::API::HTTP_PUT + path = "_inference/#{Utils.listify(_task_type)}/#{Utils.listify(_custom_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/lib/elasticsearch/api/actions/info.rb b/elasticsearch-api/lib/elasticsearch/api/actions/info.rb index f6c1ae836e..e166b68c8d 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/info.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/info.rb @@ -23,6 +23,7 @@ module API module Actions # Get cluster info. # Get basic build, version, and cluster information. + # ::: In Serverless, this API is retained for backward compatibility only. Some response fields, such as the version number, should be ignored. # # @option arguments [Boolean] :error_trace When set to `true` Elasticsearch will include the full stack trace of errors # when they occur. diff --git a/elasticsearch-api/lib/elasticsearch/api/version.rb b/elasticsearch-api/lib/elasticsearch/api/version.rb index c116efbc72..db97226258 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.0.3'.freeze - ES_SPECIFICATION_COMMIT = '896e37f76add4e8878e9f04205dd8628c7263219'.freeze + ES_SPECIFICATION_COMMIT = '6a749236ec86e65b50e31dc888c727c0aede67a3'.freeze end end diff --git a/elasticsearch-api/spec/unit/actions/inference/put_custom_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_custom_spec.rb new file mode 100644 index 0000000000..a409676f1b --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/inference/put_custom_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_custom' do + let(:expected_args) do + [ + 'PUT', + '_inference/foo/baz', + {}, + nil, + {}, + { defined_params: { custom_inference_id: 'baz', task_type: 'foo' }, + endpoint: 'inference.put_custom' } + ] + end + + it 'performs the request' do + expect(client_double.inference.put_custom(task_type: 'foo', custom_inference_id: 'baz')).to be_a Elasticsearch::API::Response + end +end