Skip to content

Commit d3b6b92

Browse files
committed
[API] Adds security.query_api_keys
1 parent a42ff88 commit d3b6b92

File tree

3 files changed

+100
-1
lines changed

3 files changed

+100
-1
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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 XPack
20+
module API
21+
module Security
22+
module Actions
23+
# Retrieves information for API keys using a subset of query DSL
24+
#
25+
# @option arguments [Hash] :headers Custom HTTP headers
26+
# @option arguments [Hash] :body From, size, query, sort and search_after
27+
#
28+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/7.x/security-api-query-api-key.html
29+
#
30+
def query_api_keys(arguments = {})
31+
headers = arguments.delete(:headers) || {}
32+
33+
arguments = arguments.clone
34+
35+
method = if arguments[:body]
36+
Elasticsearch::API::HTTP_POST
37+
else
38+
Elasticsearch::API::HTTP_GET
39+
end
40+
41+
path = "_security/_query/api_key"
42+
params = {}
43+
44+
body = arguments[:body]
45+
perform_request(method, path, params, body, headers).body
46+
end
47+
end
48+
end
49+
end
50+
end
51+
end

elasticsearch-xpack/lib/elasticsearch/xpack/api/actions/sql/clear_cursor.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ module Actions
2525
# @option arguments [Hash] :headers Custom HTTP headers
2626
# @option arguments [Hash] :body Specify the cursor value in the `cursor` element to clean the cursor. (*Required*)
2727
#
28-
# @see https://www.elastic.co/guide/en/elasticsearch/reference/7.x/sql-pagination.html
28+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/7.x/clear-sql-cursor-api.html
2929
#
3030
def clear_cursor(arguments = {})
3131
raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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#security#query_api_keys' do
21+
let(:expected_args) do
22+
[
23+
method,
24+
'_security/_query/api_key',
25+
{},
26+
body,
27+
{}
28+
]
29+
end
30+
31+
let(:body) { nil }
32+
let(:method) { 'GET' }
33+
34+
it 'performs the request' do
35+
expect(client_double.security.query_api_keys).to eq({})
36+
end
37+
38+
context 'when body is specified' do
39+
let(:body) do
40+
{ size: 1, query: 'test' }
41+
end
42+
let(:method) { 'POST' }
43+
44+
it 'performs the request' do
45+
expect(client_double.security.query_api_keys(body: body)).to eq({})
46+
end
47+
end
48+
end

0 commit comments

Comments
 (0)