class RubyAem::Resources::User
User
class contains API calls related to managing an AEM user.
Public Class Methods
Initialise a user.
@param client RubyAem::Client
@param path the path to user node, e.g. /home/users/s/ @param name the username of the AEM user, e.g. someuser, admin, johncitizen @return new RubyAem::Resources::User
instance
# File lib/ruby_aem/resources/user.rb, line 25 def initialize(client, path, name) @client = client @call_params = { path: path, name: name } end
Public Instance Methods
Add user to a group.
@param group_path the path to group node, e.g. /home/groups/s/ @param group_name the name of the AEM group, e.g. somegroup @return RubyAem::Result
# File lib/ruby_aem/resources/user.rb, line 81 def add_to_group(group_path, group_name) group = RubyAem::Resources::Group.new(@client, group_path, group_name) group.add_member(@call_params[:name]) end
Change the user's password. This only works if the user whose password is to be changed, is also the same user that authenticates to AEM via SwaggerAemClient.
@param old_password the user's old password to be changed from @param new_password the user's new password to be changed to @return RubyAem::Result
# File lib/ruby_aem/resources/user.rb, line 93 def change_password(old_password, new_password) @call_params[:old_password] = old_password @call_params[:new_password] = new_password @client.call(self.class, __callee__.to_s, @call_params) end
Create a new user.
@param password the password of the AEM user @return RubyAem::Result
# File lib/ruby_aem/resources/user.rb, line 37 def create(password) @call_params[:password] = password @call_params[:path] = "/#{@call_params[:path]}" unless @call_params[:path].start_with? '/' @client.call(self.class, __callee__.to_s, @call_params) end
Delete the user.
@return RubyAem::Result
# File lib/ruby_aem/resources/user.rb, line 46 def delete result = find_authorizable_id @call_params[:authorizable_id] = result.data @call_params[:path] = RubyAem::Swagger.path(@call_params[:path]) @client.call(self.class, __callee__.to_s, @call_params) end
Check whether the user exists or not. If the user exists, this method returns a true result data, false otherwise.
@return RubyAem::Result
# File lib/ruby_aem/resources/user.rb, line 58 def exists result = find_authorizable_id @call_params[:authorizable_id] = result.data @call_params[:path] = RubyAem::Swagger.path(@call_params[:path]) @client.call(self.class, __callee__.to_s, @call_params) end
Set the user's permission.
@param permission_path the path that the user's permission is to be set against, e.g. /etc/replication @param permission_csv comma-separated-values of the user's permission, e.g. read:true,modify:true @return RubyAem::Result
# File lib/ruby_aem/resources/user.rb, line 70 def set_permission(permission_path, permission_csv) @call_params[:permission_path] = permission_path @call_params[:permission_csv] = permission_csv @client.call(self.class, __callee__.to_s, @call_params) end