Class: SFRest::Centralized_role_management

Inherits:
Object
  • Object
show all
Defined in:
lib/sfrest/centralized_role_management.rb

Overview

We need to keep this naming due to the way connection.rb autoloads things. rubocop: disable Naming/ClassAndModuleCamelCase Manage the centralized role management feature.

Instance Method Summary collapse

Constructor Details

#initialize(conn) ⇒ Centralized_role_management

Returns a new instance of Centralized_role_management.

Parameters:



11
12
13
# File 'lib/sfrest/centralized_role_management.rb', line 11

def initialize(conn)
  @conn = conn
end

Instance Method Details

#centralized_role_mappingArray

Get current centralized role management settings

Returns:

  • (Array)

    an array of roles with their associated settings.



18
19
20
# File 'lib/sfrest/centralized_role_management.rb', line 18

def centralized_role_mapping
  @conn.get('/api/v1/centralized-role-management')
end

#disable_role_mapping(factory_role) ⇒ Array

Disable the centralized role management settings for a given role.

Parameters:

  • factory_role (String)

    the site factory role.

Returns:

  • (Array)

    an array of roles with their associated settings.



38
39
40
# File 'lib/sfrest/centralized_role_management.rb', line 38

def disable_role_mapping(factory_role)
  @conn.delete("/api/v1/centralized-role-management/#{factory_role}")
end

#enable_role_mapping(factory_role, site_role = '') ⇒ Array

Enable the centralized role management settings for a given role.

Parameters:

  • factory_role (String)

    the site factory role.

  • site_role (String) (defaults to: '')

    the corresponding role on the site.

Returns:

  • (Array)

    an array of roles with their associated settings.



27
28
29
30
31
32
# File 'lib/sfrest/centralized_role_management.rb', line 27

def enable_role_mapping(factory_role, site_role = '')
  payload = {
    'site_role' => site_role
  }.to_json
  @conn.put("/api/v1/centralized-role-management/#{factory_role}", payload)
end