diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/activate_user_profile.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/activate_user_profile.rb new file mode 100644 index 0000000000..113f36a786 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/activate_user_profile.rb @@ -0,0 +1,62 @@ +# 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. +# +# Auto generated from commit f284cc16f4d4b4289bc679aa1529bb504190fe80 +# @see https://github.com/elastic/elasticsearch-specification +# +module Elasticsearch + module API + module Security + module Actions + # Activate a user profile. + # Create or update a user profile on behalf of another user. + # NOTE: The user profile feature is designed only for use by Kibana and Elastic's Observability, Enterprise Search, and Elastic Security solutions. + # Individual users and external applications should not call this API directly. + # The calling application must have either an +access_token+ or a combination of +username+ and +password+ for the user that the profile document is intended for. + # Elastic reserves the right to change or remove this feature in future releases without prior notice. + # This API creates or updates a profile document for end users with information that is extracted from the user's authentication object including +username+, +full_name,+ +roles+, and the authentication realm. + # For example, in the JWT +access_token+ case, the profile user's +username+ is extracted from the JWT token claim pointed to by the +claims.principal+ setting of the JWT realm that authenticated the token. + # When updating a profile document, the API enables the document if it was disabled. + # Any updates do not change existing content for either the +labels+ or +data+ fields. + # + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-activate-user-profile + # + def activate_user_profile(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.activate_user_profile' } + + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + method = Elasticsearch::API::HTTP_POST + path = "_security/profile/_activate" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/disable_user_profile.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/disable_user_profile.rb new file mode 100644 index 0000000000..2ec39dbc7a --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/disable_user_profile.rb @@ -0,0 +1,70 @@ +# 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. +# +# Auto generated from commit f284cc16f4d4b4289bc679aa1529bb504190fe80 +# @see https://github.com/elastic/elasticsearch-specification +# +module Elasticsearch + module API + module Security + module Actions + # Disable a user profile. + # Disable user profiles so that they are not visible in user profile searches. + # NOTE: The user profile feature is designed only for use by Kibana and Elastic's Observability, Enterprise Search, and Elastic Security solutions. + # Individual users and external applications should not call this API directly. + # Elastic reserves the right to change or remove this feature in future releases without prior notice. + # When you activate a user profile, its automatically enabled and visible in user profile searches. You can use the disable user profile API to disable a user profile so it’s not visible in these searches. + # To re-enable a disabled user profile, use the enable user profile API . + # + # @option arguments [String] :uid Unique identifier for the user profile. (*Required*) + # @option arguments [String] :refresh If 'true', Elasticsearch refreshes the affected shards to make this operation visible to search. + # If 'wait_for', it waits for a refresh to make this operation visible to search. + # If 'false', it does nothing with refreshes. Server default: false. + # @option arguments [Hash] :headers Custom HTTP headers + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-disable-user-profile + # + def disable_user_profile(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.disable_user_profile' } + + defined_params = [:uid].inject({}) do |set_variables, variable| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + set_variables + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'uid' missing" unless arguments[:uid] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = nil + + _uid = arguments.delete(:uid) + + method = Elasticsearch::API::HTTP_PUT + path = "_security/profile/#{Utils.__listify(_uid)}/_disable" + params = Utils.process_params(arguments) + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/enable_user_profile.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/enable_user_profile.rb new file mode 100644 index 0000000000..7b2e01cb08 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/enable_user_profile.rb @@ -0,0 +1,71 @@ +# 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. +# +# Auto generated from commit f284cc16f4d4b4289bc679aa1529bb504190fe80 +# @see https://github.com/elastic/elasticsearch-specification +# +module Elasticsearch + module API + module Security + module Actions + # Enable a user profile. + # Enable user profiles to make them visible in user profile searches. + # NOTE: The user profile feature is designed only for use by Kibana and Elastic's Observability, Enterprise Search, and Elastic Security solutions. + # Individual users and external applications should not call this API directly. + # Elastic reserves the right to change or remove this feature in future releases without prior notice. + # When you activate a user profile, it's automatically enabled and visible in user profile searches. + # If you later disable the user profile, you can use the enable user profile API to make the profile visible in these searches again. + # + # @option arguments [String] :uid A unique identifier for the user profile. (*Required*) + # @option arguments [String] :refresh If 'true', Elasticsearch refreshes the affected shards to make this operation + # visible to search. + # If 'wait_for', it waits for a refresh to make this operation visible to search. + # If 'false', nothing is done with refreshes. Server default: false. + # @option arguments [Hash] :headers Custom HTTP headers + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-enable-user-profile + # + def enable_user_profile(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.enable_user_profile' } + + defined_params = [:uid].inject({}) do |set_variables, variable| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + set_variables + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'uid' missing" unless arguments[:uid] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = nil + + _uid = arguments.delete(:uid) + + method = Elasticsearch::API::HTTP_PUT + path = "_security/profile/#{Utils.__listify(_uid)}/_enable" + params = Utils.process_params(arguments) + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/get_user_profile.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/get_user_profile.rb new file mode 100644 index 0000000000..6f2a93df94 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/get_user_profile.rb @@ -0,0 +1,69 @@ +# 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. +# +# Auto generated from commit f284cc16f4d4b4289bc679aa1529bb504190fe80 +# @see https://github.com/elastic/elasticsearch-specification +# +module Elasticsearch + module API + module Security + module Actions + # Get a user profile. + # Get a user's profile using the unique profile ID. + # NOTE: The user profile feature is designed only for use by Kibana and Elastic's Observability, Enterprise Search, and Elastic Security solutions. + # Individual users and external applications should not call this API directly. + # Elastic reserves the right to change or remove this feature in future releases without prior notice. + # + # @option arguments [Userprofileid] :uid A unique identifier for the user profile. (*Required*) + # @option arguments [String] :data A comma-separated list of filters for the +data+ field of the profile document. + # To return all content use +data=*+. + # To return a subset of content use +data=+ to retrieve content nested under the specified ++. + # By default returns no +data+ content. + # @option arguments [Hash] :headers Custom HTTP headers + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-get-user-profile + # + def get_user_profile(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.get_user_profile' } + + defined_params = [:uid].inject({}) do |set_variables, variable| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + set_variables + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'uid' missing" unless arguments[:uid] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = nil + + _uid = arguments.delete(:uid) + + method = Elasticsearch::API::HTTP_GET + path = "_security/profile/#{Utils.__listify(_uid)}" + params = Utils.process_params(arguments) + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/has_privileges_user_profile.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/has_privileges_user_profile.rb new file mode 100644 index 0000000000..d7b2b4e7b2 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/has_privileges_user_profile.rb @@ -0,0 +1,56 @@ +# 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. +# +# Auto generated from commit f284cc16f4d4b4289bc679aa1529bb504190fe80 +# @see https://github.com/elastic/elasticsearch-specification +# +module Elasticsearch + module API + module Security + module Actions + # Check user profile privileges. + # Determine whether the users associated with the specified user profile IDs have all the requested privileges. + # NOTE: The user profile feature is designed only for use by Kibana and Elastic's Observability, Enterprise Search, and Elastic Security solutions. Individual users and external applications should not call this API directly. + # Elastic reserves the right to change or remove this feature in future releases without prior notice. + # + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-has-privileges-user-profile + # + def has_privileges_user_profile(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.has_privileges_user_profile' } + + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + method = Elasticsearch::API::HTTP_POST + path = "_security/profile/_has_privileges" + params = {} + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/suggest_user_profiles.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/suggest_user_profiles.rb new file mode 100644 index 0000000000..3586f601f0 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/suggest_user_profiles.rb @@ -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. +# +# Auto generated from commit f284cc16f4d4b4289bc679aa1529bb504190fe80 +# @see https://github.com/elastic/elasticsearch-specification +# +module Elasticsearch + module API + module Security + module Actions + # Suggest a user profile. + # Get suggestions for user profiles that match specified search criteria. + # NOTE: The user profile feature is designed only for use by Kibana and Elastic's Observability, Enterprise Search, and Elastic Security solutions. + # Individual users and external applications should not call this API directly. + # Elastic reserves the right to change or remove this feature in future releases without prior notice. + # + # @option arguments [String] :data A comma-separated list of filters for the +data+ field of the profile document. + # To return all content use +data=*+. + # To return a subset of content, use +data=+ to retrieve content nested under the specified ++. + # By default, the API returns no +data+ content. + # It is an error to specify +data+ as both the query parameter and the request body field. + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-suggest-user-profiles + # + def suggest_user_profiles(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.suggest_user_profiles' } + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + method = if body + Elasticsearch::API::HTTP_POST + else + Elasticsearch::API::HTTP_GET + end + + path = "_security/profile/_suggest" + params = Utils.process_params(arguments) + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/security/update_user_profile_data.rb b/elasticsearch-api/lib/elasticsearch/api/actions/security/update_user_profile_data.rb new file mode 100644 index 0000000000..a8e24acf6f --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/security/update_user_profile_data.rb @@ -0,0 +1,80 @@ +# 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. +# +# Auto generated from commit f284cc16f4d4b4289bc679aa1529bb504190fe80 +# @see https://github.com/elastic/elasticsearch-specification +# +module Elasticsearch + module API + module Security + module Actions + # Update user profile data. + # Update specific data for the user profile that is associated with a unique ID. + # NOTE: The user profile feature is designed only for use by Kibana and Elastic's Observability, Enterprise Search, and Elastic Security solutions. + # Individual users and external applications should not call this API directly. + # Elastic reserves the right to change or remove this feature in future releases without prior notice. + # To use this API, you must have one of the following privileges: + # * The +manage_user_profile+ cluster privilege. + # * The +update_profile_data+ global privilege for the namespaces that are referenced in the request. + # This API updates the +labels+ and +data+ fields of an existing user profile document with JSON objects. + # New keys and their values are added to the profile document and conflicting keys are replaced by data that's included in the request. + # For both labels and data, content is namespaced by the top-level fields. + # The +update_profile_data+ global privilege grants privileges for updating only the allowed namespaces. + # + # @option arguments [String] :uid A unique identifier for the user profile. (*Required*) + # @option arguments [Integer] :if_seq_no Only perform the operation if the document has this sequence number. + # @option arguments [Integer] :if_primary_term Only perform the operation if the document has this primary term. + # @option arguments [String] :refresh If 'true', Elasticsearch refreshes the affected shards to make this operation + # visible to search. + # If 'wait_for', it waits for a refresh to make this operation visible to search. + # If 'false', nothing is done with refreshes. Server default: false. + # @option arguments [Hash] :headers Custom HTTP headers + # @option arguments [Hash] :body request body + # + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-security-update-user-profile-data + # + def update_user_profile_data(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'security.update_user_profile_data' } + + defined_params = [:uid].inject({}) do |set_variables, variable| + set_variables[variable] = arguments[variable] if arguments.key?(variable) + set_variables + end + request_opts[:defined_params] = defined_params unless defined_params.empty? + + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + raise ArgumentError, "Required argument 'uid' missing" unless arguments[:uid] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _uid = arguments.delete(:uid) + + method = Elasticsearch::API::HTTP_PUT + path = "_security/profile/#{Utils.__listify(_uid)}/_data" + params = Utils.process_params(arguments) + + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers, request_opts) + ) + end + end + end + end +end diff --git a/elasticsearch-api/spec/unit/actions/security/activate_user_profile_spec.rb b/elasticsearch-api/spec/unit/actions/security/activate_user_profile_spec.rb new file mode 100644 index 0000000000..030bbeef79 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/security/activate_user_profile_spec.rb @@ -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#security#activate_user_profile' do + let(:expected_args) do + [ + 'POST', + '_security/profile/_activate', + {}, + {}, + {}, + { endpoint: 'security.activate_user_profile' } + ] + end + + it 'performs the request' do + expect(client_double.security.activate_user_profile(body: {})).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/security/disable_user_profile_spec.rb b/elasticsearch-api/spec/unit/actions/security/disable_user_profile_spec.rb new file mode 100644 index 0000000000..67aa731cbf --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/security/disable_user_profile_spec.rb @@ -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#security#disable_user_profile' do + let(:expected_args) do + [ + 'PUT', + '_security/profile/foo/_disable', + {}, + nil, + {}, + { endpoint: 'security.disable_user_profile', defined_params: { uid: 'foo' } } + ] + end + + it 'performs the request' do + expect(client_double.security.disable_user_profile(uid: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/security/enable_user_profile_spec.rb b/elasticsearch-api/spec/unit/actions/security/enable_user_profile_spec.rb new file mode 100644 index 0000000000..e5bf0dafab --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/security/enable_user_profile_spec.rb @@ -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#security#enable_user_profile' do + let(:expected_args) do + [ + 'PUT', + '_security/profile/foo/_enable', + {}, + nil, + {}, + { endpoint: 'security.enable_user_profile', defined_params: { uid: 'foo' } } + ] + end + + it 'performs the request' do + expect(client_double.security.enable_user_profile(uid: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/security/get_api_key_spec.rb b/elasticsearch-api/spec/unit/actions/security/get_api_key_spec.rb index 082d249109..508cd23dde 100644 --- a/elasticsearch-api/spec/unit/actions/security/get_api_key_spec.rb +++ b/elasticsearch-api/spec/unit/actions/security/get_api_key_spec.rb @@ -18,15 +18,14 @@ require 'spec_helper' describe 'client#security#get_api_key' do - let(:expected_args) do [ - 'GET', - '_security/api_key', - params, - nil, - {}, - { endpoint: 'security.get_api_key' } + 'GET', + '_security/api_key', + params, + nil, + {}, + { endpoint: 'security.get_api_key' } ] end @@ -39,7 +38,6 @@ end context 'when params are specified' do - let(:params) do { id: '1', username: 'user', @@ -49,9 +47,9 @@ it 'performs the request' do expect(client_double.security.get_api_key(id: '1', - username: 'user', - name: 'my-api-key', - realm_name: '_es_api_key')).to be_a Elasticsearch::API::Response + username: 'user', + name: 'my-api-key', + realm_name: '_es_api_key')).to be_a Elasticsearch::API::Response end end end diff --git a/elasticsearch-api/spec/unit/actions/security/get_user_profile_spec.rb b/elasticsearch-api/spec/unit/actions/security/get_user_profile_spec.rb new file mode 100644 index 0000000000..4d528ae1fa --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/security/get_user_profile_spec.rb @@ -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#security#get_user_profile' do + let(:expected_args) do + [ + 'GET', + '_security/profile/foo', + {}, + nil, + {}, + { endpoint: 'security.get_user_profile', defined_params: { uid: 'foo' } } + ] + end + + it 'performs the request' do + expect(client_double.security.get_user_profile(uid: 'foo')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/security/has_privilege_user_profile_spec.rb b/elasticsearch-api/spec/unit/actions/security/has_privilege_user_profile_spec.rb new file mode 100644 index 0000000000..a124ca0142 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/security/has_privilege_user_profile_spec.rb @@ -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#security#has_privileges_user_profile' do + let(:expected_args) do + [ + 'POST', + '_security/profile/_has_privileges', + {}, + {}, + {}, + { endpoint: 'security.has_privileges_user_profile' } + ] + end + + it 'performs the request' do + expect(client_double.security.has_privileges_user_profile(body: {})).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/security/suggest_user_profile_spec.rb b/elasticsearch-api/spec/unit/actions/security/suggest_user_profile_spec.rb new file mode 100644 index 0000000000..dcf0ba20b1 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/security/suggest_user_profile_spec.rb @@ -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#security#suggest_user_profiles' do + let(:expected_args) do + [ + 'POST', + '_security/profile/_suggest', + {}, + {}, + {}, + { endpoint: 'security.suggest_user_profiles' } + ] + end + + it 'performs the request' do + expect(client_double.security.suggest_user_profiles(body: {})).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/security/update_user_profile_spec.rb b/elasticsearch-api/spec/unit/actions/security/update_user_profile_spec.rb new file mode 100644 index 0000000000..1682a97fb5 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/security/update_user_profile_spec.rb @@ -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#security#update_user_profile_data' do + let(:expected_args) do + [ + 'PUT', + '_security/profile/foo/_data', + {}, + {}, + {}, + { endpoint: 'security.update_user_profile_data', defined_params: { uid: 'foo' } } + ] + end + + it 'performs the request' do + expect(client_double.security.update_user_profile_data(uid: 'foo', body: {})).to be_a Elasticsearch::API::Response + end +end