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.
28 29 30 31 32 33 34 |
# File 'lib/ruby_aem/resources/user.rb', line 28 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.
86 87 88 89 |
# File 'lib/ruby_aem/resources/user.rb', line 86 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.
96 97 98 99 100 |
# File 'lib/ruby_aem/resources/user.rb', line 96 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.
40 41 42 43 44 45 46 |
# File 'lib/ruby_aem/resources/user.rb', line 40 def create(password) @call_params[:password] = password if !@call_params[:path].match(/^\//) @call_params[:path] = "/#{@call_params[:path]}" end @client.call(self.class, __callee__.to_s, @call_params) end |
#delete ⇒ Object
Delete the user.
51 52 53 54 55 56 |
# File 'lib/ruby_aem/resources/user.rb', line 51 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.
63 64 65 66 67 68 |
# File 'lib/ruby_aem/resources/user.rb', line 63 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.
107 108 109 |
# File 'lib/ruby_aem/resources/user.rb', line 107 def () @client.call(self.class, __callee__.to_s, @call_params) end |
#set_permission(permission_path, permission_csv) ⇒ Object
Set the user’s permission.
75 76 77 78 79 |
# File 'lib/ruby_aem/resources/user.rb', line 75 def (, ) @call_params[:permission_path] = @call_params[:permission_csv] = @client.call(self.class, __callee__.to_s, @call_params) end |