Skip to content

Commit aa89fab

Browse files
committed
[API] Adds ES|QL view crud endpoints
1 parent c0cb481 commit aa89fab

6 files changed

Lines changed: 333 additions & 0 deletions

File tree

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Licensed to Elasticsearch B.V. under one or more contributor
2+
# license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright
4+
# ownership. Elasticsearch B.V. licenses this file to you under
5+
# the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
#
18+
# This code was automatically generated from the Elasticsearch Specification
19+
# See https://github.com/elastic/elasticsearch-specification
20+
# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash.
21+
module Elasticsearch
22+
module API
23+
module Esql
24+
module Actions
25+
# Delete an ES|QL view.
26+
# Deletes a stored ES|QL view.
27+
# This functionality is in technical preview and may be changed or removed in a future
28+
# release. Elastic will apply best effort to fix any issues, but features in technical
29+
# preview are not subject to the support SLA of official GA features.
30+
#
31+
# @option arguments [String] :name The view name to remove. (*Required*)
32+
# @option arguments [Boolean] :error_trace When set to `true` Elasticsearch will include the full stack trace of errors
33+
# when they occur.
34+
# @option arguments [String, Array<String>] :filter_path Comma-separated list of filters in dot notation which reduce the response
35+
# returned by Elasticsearch.
36+
# @option arguments [Boolean] :human When set to `true` will return statistics in a format suitable for humans.
37+
# For example `"exists_time": "1h"` for humans and
38+
# `"exists_time_in_millis": 3600000` for computers. When disabled the human
39+
# readable values will be omitted. This makes sense for responses being consumed
40+
# only by machines.
41+
# @option arguments [Boolean] :pretty If set to `true` the returned JSON will be "pretty-formatted". Only use
42+
# this option for debugging only.
43+
# @option arguments [Hash] :headers Custom HTTP headers
44+
#
45+
# @see https://www.elastic.co/docs/api/doc/elasticsearch#TODO
46+
#
47+
def delete_view(arguments = {})
48+
request_opts = { endpoint: arguments[:endpoint] || 'esql.delete_view' }
49+
50+
defined_params = [:name].each_with_object({}) do |variable, set_variables|
51+
set_variables[variable] = arguments[variable] if arguments.key?(variable)
52+
end
53+
request_opts[:defined_params] = defined_params unless defined_params.empty?
54+
55+
raise ArgumentError, "Required argument 'name' missing" unless arguments[:name]
56+
57+
arguments = arguments.clone
58+
headers = arguments.delete(:headers) || {}
59+
60+
body = nil
61+
62+
_name = arguments.delete(:name)
63+
64+
method = Elasticsearch::API::HTTP_DELETE
65+
path = "_query/view/#{Utils.listify(_name)}"
66+
params = Utils.process_params(arguments)
67+
68+
Elasticsearch::API::Response.new(
69+
perform_request(method, path, params, body, headers, request_opts)
70+
)
71+
end
72+
end
73+
end
74+
end
75+
end
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Licensed to Elasticsearch B.V. under one or more contributor
2+
# license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright
4+
# ownership. Elasticsearch B.V. licenses this file to you under
5+
# the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
#
18+
# This code was automatically generated from the Elasticsearch Specification
19+
# See https://github.com/elastic/elasticsearch-specification
20+
# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash.
21+
module Elasticsearch
22+
module API
23+
module Esql
24+
module Actions
25+
# Get an ES|QL view.
26+
# Returns a stored ES|QL view.
27+
# This functionality is in technical preview and may be changed or removed in a future
28+
# release. Elastic will apply best effort to fix any issues, but features in technical
29+
# preview are not subject to the support SLA of official GA features.
30+
#
31+
# @option arguments [String] :name The comma-separated view names to retrieve.
32+
# @option arguments [Boolean] :error_trace When set to `true` Elasticsearch will include the full stack trace of errors
33+
# when they occur.
34+
# @option arguments [String, Array<String>] :filter_path Comma-separated list of filters in dot notation which reduce the response
35+
# returned by Elasticsearch.
36+
# @option arguments [Boolean] :human When set to `true` will return statistics in a format suitable for humans.
37+
# For example `"exists_time": "1h"` for humans and
38+
# `"exists_time_in_millis": 3600000` for computers. When disabled the human
39+
# readable values will be omitted. This makes sense for responses being consumed
40+
# only by machines.
41+
# @option arguments [Boolean] :pretty If set to `true` the returned JSON will be "pretty-formatted". Only use
42+
# this option for debugging only.
43+
# @option arguments [Hash] :headers Custom HTTP headers
44+
#
45+
# @see https://www.elastic.co/docs/api/doc/elasticsearch#TODO
46+
#
47+
def get_view(arguments = {})
48+
request_opts = { endpoint: arguments[:endpoint] || 'esql.get_view' }
49+
50+
defined_params = [:name].each_with_object({}) do |variable, set_variables|
51+
set_variables[variable] = arguments[variable] if arguments.key?(variable)
52+
end
53+
request_opts[:defined_params] = defined_params unless defined_params.empty?
54+
55+
arguments = arguments.clone
56+
headers = arguments.delete(:headers) || {}
57+
58+
body = nil
59+
60+
_name = arguments.delete(:name)
61+
62+
method = Elasticsearch::API::HTTP_GET
63+
path = if _name
64+
"_query/view/#{Utils.listify(_name)}"
65+
else
66+
'_query/view'
67+
end
68+
params = Utils.process_params(arguments)
69+
70+
Elasticsearch::API::Response.new(
71+
perform_request(method, path, params, body, headers, request_opts)
72+
)
73+
end
74+
end
75+
end
76+
end
77+
end
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Licensed to Elasticsearch B.V. under one or more contributor
2+
# license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright
4+
# ownership. Elasticsearch B.V. licenses this file to you under
5+
# the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
#
18+
# This code was automatically generated from the Elasticsearch Specification
19+
# See https://github.com/elastic/elasticsearch-specification
20+
# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash.
21+
module Elasticsearch
22+
module API
23+
module Esql
24+
module Actions
25+
# Create or update an ES|QL view.
26+
# This functionality is in technical preview and may be changed or removed in a future
27+
# release. Elastic will apply best effort to fix any issues, but features in technical
28+
# preview are not subject to the support SLA of official GA features.
29+
#
30+
# @option arguments [String] :name The view name to create or update. (*Required*)
31+
# @option arguments [Boolean] :error_trace When set to `true` Elasticsearch will include the full stack trace of errors
32+
# when they occur.
33+
# @option arguments [String, Array<String>] :filter_path Comma-separated list of filters in dot notation which reduce the response
34+
# returned by Elasticsearch.
35+
# @option arguments [Boolean] :human When set to `true` will return statistics in a format suitable for humans.
36+
# For example `"exists_time": "1h"` for humans and
37+
# `"exists_time_in_millis": 3600000` for computers. When disabled the human
38+
# readable values will be omitted. This makes sense for responses being consumed
39+
# only by machines.
40+
# @option arguments [Boolean] :pretty If set to `true` the returned JSON will be "pretty-formatted". Only use
41+
# this option for debugging only.
42+
# @option arguments [Hash] :headers Custom HTTP headers
43+
# @option arguments [Hash] :body request body
44+
#
45+
# @see https://www.elastic.co/docs/api/doc/elasticsearch#TODO
46+
#
47+
def put_view(arguments = {})
48+
request_opts = { endpoint: arguments[:endpoint] || 'esql.put_view' }
49+
50+
defined_params = [:name].each_with_object({}) do |variable, set_variables|
51+
set_variables[variable] = arguments[variable] if arguments.key?(variable)
52+
end
53+
request_opts[:defined_params] = defined_params unless defined_params.empty?
54+
55+
raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
56+
raise ArgumentError, "Required argument 'name' missing" unless arguments[:name]
57+
58+
arguments = arguments.clone
59+
headers = arguments.delete(:headers) || {}
60+
61+
body = arguments.delete(:body)
62+
63+
_name = arguments.delete(:name)
64+
65+
method = Elasticsearch::API::HTTP_PUT
66+
path = "_query/view/#{Utils.listify(_name)}"
67+
params = Utils.process_params(arguments)
68+
69+
Elasticsearch::API::Response.new(
70+
perform_request(method, path, params, body, headers, request_opts)
71+
)
72+
end
73+
end
74+
end
75+
end
76+
end
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Licensed to Elasticsearch B.V. under one or more contributor
2+
# license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright
4+
# ownership. Elasticsearch B.V. licenses this file to you under
5+
# the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
require 'spec_helper'
19+
20+
describe 'client.esql#delete_view' do
21+
let(:expected_args) do
22+
[
23+
'DELETE',
24+
'_query/view/foo',
25+
{},
26+
nil,
27+
{},
28+
{ endpoint: 'esql.delete_view', defined_params: { name: 'foo' } }
29+
]
30+
end
31+
32+
it 'performs the request' do
33+
expect(client_double.esql.delete_view(name: 'foo')).to be_a Elasticsearch::API::Response
34+
end
35+
end
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Licensed to Elasticsearch B.V. under one or more contributor
2+
# license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright
4+
# ownership. Elasticsearch B.V. licenses this file to you under
5+
# the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
require 'spec_helper'
19+
20+
describe 'client.esql#get_view' do
21+
let(:expected_args) do
22+
[
23+
'GET',
24+
'_query/view/foo',
25+
{},
26+
nil,
27+
{},
28+
{ endpoint: 'esql.get_view', defined_params: { name: 'foo' } }
29+
]
30+
end
31+
32+
it 'performs the request' do
33+
expect(client_double.esql.get_view(name: 'foo')).to be_a Elasticsearch::API::Response
34+
end
35+
end
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Licensed to Elasticsearch B.V. under one or more contributor
2+
# license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright
4+
# ownership. Elasticsearch B.V. licenses this file to you under
5+
# the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
require 'spec_helper'
19+
20+
describe 'client.esql#put_view' do
21+
let(:expected_args) do
22+
[
23+
'PUT',
24+
'_query/view/foo',
25+
{},
26+
{},
27+
{},
28+
{ endpoint: 'esql.put_view', defined_params: { name: 'foo' } }
29+
]
30+
end
31+
32+
it 'performs the request' do
33+
expect(client_double.esql.put_view(name: 'foo', body: {})).to be_a Elasticsearch::API::Response
34+
end
35+
end

0 commit comments

Comments
 (0)