diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/esql/get_query.rb b/elasticsearch-api/lib/elasticsearch/api/actions/esql/get_query.rb new file mode 100644 index 0000000000..46b4e08792 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/esql/get_query.rb @@ -0,0 +1,65 @@ +# 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 Esql + module Actions + # Get a specific running ES|QL query information. + # Returns an object extended information about a running ES|QL query. + # 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] :id The query ID (*Required*) + # @option arguments [Hash] :headers Custom HTTP headers + # + # @see [TODO] + # + def get_query(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'esql.get_query' } + + defined_params = [: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 'id' missing" unless arguments[:id] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = nil + + _id = arguments.delete(:id) + + method = Elasticsearch::API::HTTP_GET + path = "_query/queries/#{Utils.listify(_id)}" + params = {} + + 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/esql/list_queries.rb b/elasticsearch-api/lib/elasticsearch/api/actions/esql/list_queries.rb new file mode 100644 index 0000000000..22b804c0ec --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/esql/list_queries.rb @@ -0,0 +1,55 @@ +# 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 Esql + module Actions + # Get running ES|QL queries information. + # Returns an object containing IDs and other information about the running ES|QL queries. + # 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 [Hash] :headers Custom HTTP headers + # + # @see [TODO] + # + def list_queries(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'esql.list_queries' } + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = nil + + method = Elasticsearch::API::HTTP_GET + path = '_query/queries' + params = {} + + 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/esql/get_query_spec.rb b/elasticsearch-api/spec/unit/actions/esql/get_query_spec.rb new file mode 100644 index 0000000000..15c9d48bbe --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/esql/get_query_spec.rb @@ -0,0 +1,35 @@ +# 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.esql#query' do + let(:expected_args) do + [ + 'GET', + '_query/queries/test', + {}, + nil, + {}, + { endpoint: 'esql.get_query', defined_params: { id: 'test' } } + ] + end + + it 'performs the request' do + expect(client_double.esql.get_query(id: 'test')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/esql/list_queries_spec.rb b/elasticsearch-api/spec/unit/actions/esql/list_queries_spec.rb new file mode 100644 index 0000000000..4bc4a99d73 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/esql/list_queries_spec.rb @@ -0,0 +1,35 @@ +# 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.esql#list_queries' do + let(:expected_args) do + [ + 'GET', + '_query/queries', + {}, + nil, + {}, + { endpoint: 'esql.list_queries' } + ] + end + + it 'performs the request' do + expect(client_double.esql.list_queries).to be_a Elasticsearch::API::Response + end +end