Module: Opendistro::Client::Users
- Included in:
- Opendistro::Client
- Defined in:
- lib/opendistro/client/users.rb
Overview
Defines methods related to users.
Instance Method Summary collapse
-
#create_user(username, password, options = {}) ⇒ Opendistro::ObjectifiedHash
Creates a new user.
-
#delete_user(username) ⇒ Opendistro::ObjectifiedHash
Deletes a user.
-
#edit_user(username, options = {}) ⇒ Opendistro::ObjectifiedHash
Updates a user.
-
#user(username = nil) ⇒ Opendistro::ObjectifiedHash
Gets information about a user.
-
#users ⇒ Opendistro::ObjectifiedHash
Gets a list of users.
Instance Method Details
#create_user(username, password, options = {}) ⇒ Opendistro::ObjectifiedHash
Creates a new user. Requires authentication from an admin account.
42 43 44 45 46 |
# File 'lib/opendistro/client/users.rb', line 42 def create_user(username, password, = {}) raise ArgumentError, 'Missing required parameters' unless username || password put("/_opendistro/_security/api/internalusers/#{username}", body: { password: password }.merge!()) end |
#delete_user(username) ⇒ Opendistro::ObjectifiedHash
Deletes a user.
67 68 69 |
# File 'lib/opendistro/client/users.rb', line 67 def delete_user(username) delete("/_opendistro/_security/api/internalusers/#{username}") end |
#edit_user(username, options = {}) ⇒ Opendistro::ObjectifiedHash
Updates a user.
56 57 58 |
# File 'lib/opendistro/client/users.rb', line 56 def edit_user(username, = {}) patch("/_opendistro/_security/api/internalusers/#{username}", body: .to_json) end |
#user(username = nil) ⇒ Opendistro::ObjectifiedHash
Gets information about a user. Will return information about an authorized user if no user passed.
26 27 28 |
# File 'lib/opendistro/client/users.rb', line 26 def user(username = nil) username.nil? ? get('/_opendistro/_security/api/account') : get("/_opendistro/_security/api/internalusers/#{username}") end |
#users ⇒ Opendistro::ObjectifiedHash
Gets a list of users.
13 14 15 |
# File 'lib/opendistro/client/users.rb', line 13 def users get('/_opendistro/_security/api/internalusers/') end |