Class: RubyAem::Resources::Group

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_aem/resources/group.rb

Overview

Group class contains API calls related to managing an AEM group.

Instance Method Summary collapse

Constructor Details

#initialize(client, path, name) ⇒ Object

Initialise a group.

Parameters:

  • client

    RubyAem::Client

  • path

    the path to group node, e.g. /home/groups/s/

  • name

    the name of the AEM group, e.g. somegroup



25
26
27
28
29
30
31
# File 'lib/ruby_aem/resources/group.rb', line 25

def initialize(client, path, name)
  @client = client
  @call_params = {
    path: path,
    name: name
  }
end

Instance Method Details

#add_member(member) ⇒ Object

Add another group as a member of this group.

Parameters:

  • member

    the name of the member group to be added

Returns:

  • RubyAem::Result



78
79
80
81
82
83
84
# File 'lib/ruby_aem/resources/group.rb', line 78

def add_member(member)
  result = find_authorizable_id
  @call_params[:authorizable_id] = result.data
  @call_params[:member] = member
  @call_params[:path] = RubyAem::Swagger.path(@call_params[:path])
  @client.call(self.class, __callee__.to_s, @call_params)
end

#createObject

Create a new group.

Returns:

  • RubyAem::Result



36
37
38
39
# File 'lib/ruby_aem/resources/group.rb', line 36

def create
  @call_params[:path] = "/#{@call_params[:path]}" unless @call_params[:path].start_with? '/'
  @client.call(self.class, __callee__.to_s, @call_params)
end

#deleteObject

Delete the group.

Returns:

  • RubyAem::Result



44
45
46
47
48
49
# File 'lib/ruby_aem/resources/group.rb', line 44

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

#existsObject

Check whether the group exists or not. If the group exists, this method returns a true result data, false otherwise.

Returns:

  • RubyAem::Result



56
57
58
59
60
61
# File 'lib/ruby_aem/resources/group.rb', line 56

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

#find_authorizable_idObject

Find the group’s authorizable ID. Return authorizable ID as result data, or nil if authorizable ID cannot be found.

Returns:

  • RubyAem::Result



91
92
93
94
# File 'lib/ruby_aem/resources/group.rb', line 91

def find_authorizable_id
  @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 group’s permission.

Parameters:

  • permission_path

    the path that the group’s permission is to be set against, e.g. /etc/replication

  • permission_csv

    comma-separated-values of the group’s permission, e.g. read:true,modify:true

Returns:

  • RubyAem::Result



68
69
70
71
72
# File 'lib/ruby_aem/resources/group.rb', line 68

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