Module: Sailpoint

Defined in:
lib/sailpoint.rb,
lib/sailpoint/rest.rb,
lib/sailpoint/scim.rb,
lib/sailpoint/config.rb,
lib/sailpoint/version.rb

Overview

Used for setting you Sailpoint API configuration and credentials

Defined Under Namespace

Classes: Config, Error, Rest, Scim

Constant Summary collapse

RUBY_VERSION =

The minimum required RUBY_VERSION

'2.5'.freeze
VERSION =

The Sailpoints version

'0.0.2'.freeze

Class Method Summary collapse

Class Method Details

.get_user(username, interface: nil) ⇒ Hash

If a valid username and URL have been supplied a lookup requests will be send to determine if the user exists in the specified interface

Parameters:

  • username (String)
    • the username that we are going to valid exists in the IdentityIQ listing

Returns:

  • (Hash)
    • If a user is found, it will return all the that identities attributes

Raises:

  • (ArgumentError)


15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/sailpoint.rb', line 15

def self.get_user(username, interface: nil)
  raise ArgumentError, 'An invalid user lookup was specified.' if username.to_s.blank?
  raise ArgumentError, 'Please specify a valid HOST/Interface before attemping a lookup.' unless valid_url?
  raise ArgumentError, 'Valid credentials are required before attempting an API request.' unless valid_credentials?
  raise ArgumentError, 'Invalid method type' unless valid_interface_type?(interface) || valid_interface_type?(Sailpoint::Config.interface)

  if interface.nil?
    Object.const_get("Sailpoint::#{Sailpoint::Config.interface.capitalize}").get_user(username)
  elsif valid_interface_type?(interface)
    Object.const_get("Sailpoint::#{interface.capitalize}").get_user(username)
  end
end

.set_credentials(username, password) ⇒ Object

Assign the credentials for accessing the IdentityIQ API

Parameters:

  • username (String)
    • The Sailpoint username required for accessing the API

  • password (String)
    • The Sailpoint password required for accessing the API



31
32
33
# File 'lib/sailpoint.rb', line 31

def self.set_credentials(username, password)
  Sailpoint::Config.set_credentials(username, password) unless username.nil? && password.nil?
end

.set_host(host) ⇒ Object

Assign the IdentityIQ API base URL

Parameters:

  • host (String)
    • The base URL in which the API calls will be built upon



37
38
39
# File 'lib/sailpoint.rb', line 37

def self.set_host(host)
  Sailpoint::Config.host = host unless host.blank?
end

.valid_credentials?Boolean

Used to verify if any credentails were supplied for the API request

Returns:

  • (Boolean)

    if credentials were supplied or not



43
44
45
46
47
# File 'lib/sailpoint.rb', line 43

def self.valid_credentials?
  return false if Sailpoint::Config.username.blank? && Sailpoint::Config.password.blank?

  !Sailpoint::Config.hashed_credentials.blank?
end

.valid_interface_type?(interface) ⇒ Boolean

Used to verify if the specifed interface type is valid for the Sailpoint API

Parameters:

  • interface (String)
    • A specified API interface endpoint, that can either be Rest or Scim

Returns:

  • (Boolean)
    • Returns weither the specifed interface is a a valid type allowed by the API.



52
53
54
# File 'lib/sailpoint.rb', line 52

def self.valid_interface_type?(interface)
  %w[rest scim].include?(interface)
end

.valid_url?Boolean

Used to verify if the URL string is blank or a URL was supplied

Returns:

  • (Boolean)
    • if a url for the API endpoint was supplied or not



58
59
60
# File 'lib/sailpoint.rb', line 58

def self.valid_url?
  !Sailpoint::Config.url.blank?
end