Skip to content

Commit caa89ec

Browse files
committed
[API] New API: security.has_privileges_user_profile
1 parent c3f18ac commit caa89ec

File tree

2 files changed

+86
-0
lines changed

2 files changed

+86
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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 Security
21+
module Actions
22+
# Determines whether the users associated with the specified profile IDs have all the requested privileges.
23+
# This functionality is Experimental and may be changed or removed
24+
# completely in a future release. Elastic will take a best effort approach
25+
# to fix any issues, but experimental features are not subject to the
26+
# support SLA of official GA features.
27+
#
28+
# @option arguments [Hash] :headers Custom HTTP headers
29+
# @option arguments [Hash] :body The privileges to check and the list of profile IDs (*Required*)
30+
#
31+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/8.3/security-api-has-privileges-user-profile.html
32+
#
33+
def has_privileges_user_profile(arguments = {})
34+
raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
35+
36+
arguments = arguments.clone
37+
headers = arguments.delete(:headers) || {}
38+
39+
body = arguments.delete(:body)
40+
41+
method = Elasticsearch::API::HTTP_POST
42+
path = "_security/profile/_has_privileges"
43+
params = {}
44+
45+
Elasticsearch::API::Response.new(
46+
perform_request(method, path, params, body, headers)
47+
)
48+
end
49+
end
50+
end
51+
end
52+
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#security#has_privileges_user_profile' do
21+
let(:expected_args) do
22+
[
23+
'POST',
24+
'_security/profile/_has_privileges',
25+
{},
26+
{},
27+
{}
28+
]
29+
end
30+
31+
it 'performs the request' do
32+
expect(client_double.security.has_privileges_user_profile(body: {})).to be_a Elasticsearch::API::Response
33+
end
34+
end

0 commit comments

Comments
 (0)