Skip to content

Commit 62756a8

Browse files
committed
[API] Adds new APIs and namespace:
New namespace: synonym_rule New APIs: - query_ruleset.delete - query_ruleset.get - synonym_rule.put
1 parent f6016a8 commit 62756a8

File tree

9 files changed

+320
-2
lines changed

9 files changed

+320
-2
lines changed

elasticsearch-api/lib/elasticsearch/api.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ def self.included(base)
8383
Elasticsearch::API::SearchApplication,
8484
Elasticsearch::API::Synonyms,
8585
Elasticsearch::API::SynonymsSets,
86-
Elasticsearch::API::QueryRuleset
86+
Elasticsearch::API::QueryRuleset,
87+
Elasticsearch::API::SynonymRule
8788
end
8889

8990
# The serializer class
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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+
# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80
19+
# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec
20+
#
21+
module Elasticsearch
22+
module API
23+
module QueryRuleset
24+
module Actions
25+
# Deletes a query ruleset.
26+
# This functionality is Experimental and may be changed or removed
27+
# completely in a future release. Elastic will take a best effort approach
28+
# to fix any issues, but experimental features are not subject to the
29+
# support SLA of official GA features.
30+
#
31+
# @option arguments [String] :ruleset_id The unique identifier of the query ruleset to delete
32+
# @option arguments [Hash] :headers Custom HTTP headers
33+
#
34+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-query-ruleset.html
35+
#
36+
def delete(arguments = {})
37+
raise ArgumentError, "Required argument 'ruleset_id' missing" unless arguments[:ruleset_id]
38+
39+
arguments = arguments.clone
40+
headers = arguments.delete(:headers) || {}
41+
42+
body = nil
43+
44+
_ruleset_id = arguments.delete(:ruleset_id)
45+
46+
method = Elasticsearch::API::HTTP_DELETE
47+
path = "_query_rules/#{Utils.__listify(_ruleset_id)}"
48+
params = {}
49+
50+
Elasticsearch::API::Response.new(
51+
perform_request(method, path, params, body, headers)
52+
)
53+
end
54+
end
55+
end
56+
end
57+
end
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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+
# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80
19+
# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec
20+
#
21+
module Elasticsearch
22+
module API
23+
module QueryRuleset
24+
module Actions
25+
# Returns the details about a query ruleset.
26+
# This functionality is Experimental and may be changed or removed
27+
# completely in a future release. Elastic will take a best effort approach
28+
# to fix any issues, but experimental features are not subject to the
29+
# support SLA of official GA features.
30+
#
31+
# @option arguments [String] :ruleset_id The unique identifier of the query ruleset
32+
# @option arguments [Hash] :headers Custom HTTP headers
33+
#
34+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/current/get-query-ruleset.html
35+
#
36+
def get(arguments = {})
37+
raise ArgumentError, "Required argument 'ruleset_id' missing" unless arguments[:ruleset_id]
38+
39+
arguments = arguments.clone
40+
headers = arguments.delete(:headers) || {}
41+
42+
body = nil
43+
44+
_ruleset_id = arguments.delete(:ruleset_id)
45+
46+
method = Elasticsearch::API::HTTP_GET
47+
path = "_query_rules/#{Utils.__listify(_ruleset_id)}"
48+
params = {}
49+
50+
Elasticsearch::API::Response.new(
51+
perform_request(method, path, params, body, headers)
52+
)
53+
end
54+
end
55+
end
56+
end
57+
end

elasticsearch-api/lib/elasticsearch/api/actions/search_application/delete.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ module Actions
3131
# @option arguments [String] :name The name of the search application
3232
# @option arguments [Hash] :headers Custom HTTP headers
3333
#
34-
# @see https://www.elastic.co/guide/en/elasticsearch/reference/current/put-search-application.html
34+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-search-application.html
3535
#
3636
def delete(arguments = {})
3737
raise ArgumentError, "Required argument 'name' missing" unless arguments[:name]
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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+
# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80
19+
# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec
20+
#
21+
module Elasticsearch
22+
module API
23+
module SynonymRule
24+
module Actions
25+
# Creates or updates a synonym rule in a synonym set
26+
# This functionality is Experimental and may be changed or removed
27+
# completely in a future release. Elastic will take a best effort approach
28+
# to fix any issues, but experimental features are not subject to the
29+
# support SLA of official GA features.
30+
#
31+
# @option arguments [String] :synonyms_set The id of the synonym set to be updated with the synonym rule
32+
# @option arguments [String] :synonym_rule The id of the synonym rule to be updated or created
33+
# @option arguments [Hash] :headers Custom HTTP headers
34+
# @option arguments [Hash] :body Synonym rule (*Required*)
35+
#
36+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/current/put-synonym-rule.html
37+
#
38+
def put(arguments = {})
39+
raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
40+
raise ArgumentError, "Required argument 'synonyms_set' missing" unless arguments[:synonyms_set]
41+
raise ArgumentError, "Required argument 'synonym_rule' missing" unless arguments[:synonym_rule]
42+
43+
arguments = arguments.clone
44+
headers = arguments.delete(:headers) || {}
45+
46+
body = arguments.delete(:body)
47+
48+
_synonyms_set = arguments.delete(:synonyms_set)
49+
50+
_synonym_rule = arguments.delete(:synonym_rule)
51+
52+
method = Elasticsearch::API::HTTP_PUT
53+
path = "_synonyms/#{Utils.__listify(_synonyms_set)}/#{Utils.__listify(_synonym_rule)}"
54+
params = {}
55+
56+
Elasticsearch::API::Response.new(
57+
perform_request(method, path, params, body, headers)
58+
)
59+
end
60+
end
61+
end
62+
end
63+
end
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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+
module Elasticsearch
19+
module API
20+
module SynonymRule
21+
module Actions; end
22+
23+
# Client for the "synonym_rule" namespace (includes the {SynonymRule::Actions} methods)
24+
#
25+
class SynonymRuleClient
26+
include Common::Client, Common::Client::Base, SynonymRule::Actions
27+
end
28+
29+
# Proxy method for {SynonymRuleClient}, available in the receiving object
30+
#
31+
def synonym_rule
32+
@synonym_rule ||= SynonymRuleClient.new(self)
33+
end
34+
end
35+
end
36+
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.query_ruleset#delete' do
21+
22+
let(:expected_args) do
23+
[
24+
'DELETE',
25+
'_query_rules/foo',
26+
{},
27+
nil,
28+
{}
29+
]
30+
end
31+
32+
it 'performs the request' do
33+
expect(client_double.query_ruleset.delete(ruleset_id: '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.query_ruleset#get' do
21+
22+
let(:expected_args) do
23+
[
24+
'GET',
25+
'_query_rules/foo',
26+
{},
27+
nil,
28+
{}
29+
]
30+
end
31+
32+
it 'performs the request' do
33+
expect(client_double.query_ruleset.get(ruleset_id: 'foo')).to be_a Elasticsearch::API::Response
34+
end
35+
end
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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.synonym_rule#put' do
21+
let(:expected_args) do
22+
[
23+
'PUT',
24+
'_synonyms/set/rule',
25+
{},
26+
{},
27+
{}
28+
]
29+
end
30+
31+
it 'performs the request' do
32+
expect(client_double.synonym_rule.put(body: {}, synonyms_set: 'set', synonym_rule: 'rule')).to be_a Elasticsearch::API::Response
33+
end
34+
end

0 commit comments

Comments
 (0)