Skip to content
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
65 changes: 65 additions & 0 deletions elasticsearch-api/lib/elasticsearch/api/actions/esql/get_query.rb
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
35 changes: 35 additions & 0 deletions elasticsearch-api/spec/unit/actions/esql/get_query_spec.rb
Original file line number Diff line number Diff line change
@@ -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
35 changes: 35 additions & 0 deletions elasticsearch-api/spec/unit/actions/esql/list_queries_spec.rb
Original file line number Diff line number Diff line change
@@ -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