Class: RubyAem::Resources::User
- Inherits:
-
Object
- Object
- RubyAem::Resources::User
- Defined in:
- lib/ruby_aem/resources/user.rb
Overview
User class contains API calls related to managing an AEM user.
Instance Method Summary collapse
-
#add_to_group(group_path, group_name) ⇒ Object
Add user to a group.
-
#change_password(old_password, new_password) ⇒ Object
Change the user’s password.
-
#create(password) ⇒ Object
Create a new user.
-
#delete ⇒ Object
Delete the user.
-
#exists ⇒ Object
Check whether the user exists or not.
-
#find_authorizable_id ⇒ Object
Find the user’s authorizable ID.
-
#initialize(client, path, name) ⇒ Object
constructor
Initialise a user.
-
#set_permission(permission_path, permission_csv) ⇒ Object
Set the user’s permission.
Constructor Details
#initialize(client, path, name) ⇒ Object
Initialise a user.
25 26 27 28 29 30 31 |
# File 'lib/ruby_aem/resources/user.rb', line 25 def initialize(client, path, name) @client = client @call_params = { path: path, name: name } end |
Instance Method Details
#add_to_group(group_path, group_name) ⇒ Object
Add user to a group.
81 82 83 84 |
# 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_password(old_password, new_password) ⇒ Object
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.
93 94 95 96 97 |
# 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(password) ⇒ Object
Create a new user.
37 38 39 40 41 |
# 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 ⇒ Object
Delete the user.
46 47 48 49 50 51 |
# File 'lib/ruby_aem/resources/user.rb', line 46 def delete result = @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 |
#exists ⇒ Object
Check whether the user exists or not. If the user exists, this method returns a true result data, false otherwise.
58 59 60 61 62 63 |
# File 'lib/ruby_aem/resources/user.rb', line 58 def exists result = @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 |
#find_authorizable_id ⇒ Object
Find the user’s authorizable ID. Return authorizable ID as result data, or nil if authorizable ID cannot be found.
104 105 106 107 |
# File 'lib/ruby_aem/resources/user.rb', line 104 def @call_params[:path] = "/#{@call_params[:path]}" unless @call_params[:path].start_with? '/' @client.call(self.class, __callee__.to_s, @call_params) end |
#set_permission(permission_path, permission_csv) ⇒ Object
Set the user’s permission.
70 71 72 73 74 |
# File 'lib/ruby_aem/resources/user.rb', line 70 def (, ) @call_params[:permission_path] = @call_params[:permission_csv] = @client.call(self.class, __callee__.to_s, @call_params) end |