Module: Simpleokta::Client::Users

Included in:
Simpleokta::Client
Defined in:
lib/simpleokta/users.rb

Instance Method Summary collapse

Instance Method Details

#activate_user(user_id, send_email) ⇒ Hash

Activate a user in the okta instance.

Users created are not immediately activated until they log on. This method bypasses that requirement

Parameters:

  • user_id (String)

    the unique id of a user in the okta instance

  • send_email (Boolean)

    whether or not to send an activation email to the user

Returns:

  • (Hash)

    contains information on activation. If send_email is set to True, returns an empty hash.

See Also:



106
107
108
109
110
# File 'lib/simpleokta/users.rb', line 106

def activate_user(user_id, send_email)
  response = call_with_token('post',
                             "#{Constants::USER_API_BASE_PATH}/#{user_id}/lifecycle/activate?sendEmail=#{send_email}")
  JSON.parse(response.body)
end

#apps_assigned_to_user(user_id) ⇒ Array<Application Object>

List all applications a user currently has assigned to them.

Parameters:

  • user_id (String)

    the unique id of a user in the okta instance

Returns:

  • (Array<Application Object>)

See Also:



167
168
169
170
# File 'lib/simpleokta/users.rb', line 167

def apps_assigned_to_user(user_id)
  response = call_with_token('get', "#{Constants::APP_API_BASE_PATH}/?filter=user.id+eq+\"#{user_id}\"")
  JSON.parse(response.body)
end

#create_and_activate_user(user_profile_data) ⇒ Hash<User>

Create an activated user in the okta instance without credentials

Parameters:

  • user_profile_data (Hash)

    the required fields to create a user in okta. At minimum, this should contain the Profile object.

Returns:

  • (Hash<User>)

See Also:



59
60
61
62
# File 'lib/simpleokta/users.rb', line 59

def create_and_activate_user()
  response = call_with_token('post', "#{Constants::USER_API_BASE_PATH}?activate=true", )
  JSON.parse(response.body)
end

#create_user(user_profile_data) ⇒ Hash<User>

Create a user in the okta instance without credentials

Examples:

Profile Object

"profile": {
  "firstName": "Isaac",
  "lastName": "Brock",
  "email": "[email protected]",
  "login": "[email protected]",
  "mobilePhone": "555-415-1337"
}

Parameters:

  • user_profile_data (Hash)

    the required fields to create a user in okta. At minimum, this should contain the Profile object.

Returns:

  • (Hash<User>)

See Also:



48
49
50
51
# File 'lib/simpleokta/users.rb', line 48

def create_user()
  response = call_with_token('post', "#{Constants::USER_API_BASE_PATH}?activate=false", )
  JSON.parse(response.body)
end

#create_user_in_group(user_profile_data, group_id_array) ⇒ Hash<User>

Create a user in the okta insance, and have the user added to groups

Parameters:

  • user_profile_data (Hash)

    the required fields to create a user in okta. At minimum, this should contain the Profile object.

  • group_id_array (Array<String>)

    the group ids the user should be added to

Returns:

  • (Hash<User>)

See Also:



71
72
73
74
75
76
# File 'lib/simpleokta/users.rb', line 71

def create_user_in_group(, group_id_array)
  body = 
  body[:groupIds] = group_id_array
  response = call_with_token('post', Constants::USER_API_BASE_PATH, body)
  JSON.parse(response.body)
end

#deactivate_user(user_id, send_email) ⇒ Hash

Deactivates a user in the okta instance.

Parameters:

  • user_id (String)

    the unique id of a user in the okta instance

  • send_email (Boolean)

    whether or not to send an activation email to the user

Returns:

  • (Hash)

    empty hash

See Also:



129
130
131
132
133
# File 'lib/simpleokta/users.rb', line 129

def deactivate_user(user_id, send_email)
  response = call_with_token('post',
                             "#{Constants::USER_API_BASE_PATH}/#{user_id}/lifecycle/deactivate?sendEmail=#{send_email}")
  JSON.parse(response.body)
end

#delete_user(user_id) ⇒ Hash<User>

Delete a user in the okta instance

Parameters:

  • user_id (String)

    the unique id of a user in the okta instance

Returns:

  • (Hash<User>)

See Also:



82
83
84
85
# File 'lib/simpleokta/users.rb', line 82

def delete_user(user_id)
  response = call_with_token('delete', "#{Constants::USER_API_BASE_PATH}/#{user_id}")
  response
end

#reactivate_user(user_id, send_email) ⇒ Hash

Reactivates a user in the okta instance that was deactivated.

Parameters:

  • user_id (String)

    the unique id of a user in the okta instance

  • send_email (Boolean)

    whether or not to send an activation email to the user

Returns:

  • (Hash)

    contains information on activation. If send_email is set to True, returns an empty hash.

See Also:



118
119
120
121
122
# File 'lib/simpleokta/users.rb', line 118

def reactivate_user(user_id, send_email)
  response = call_with_token('post',
                             "#{Constants::USER_API_BASE_PATH}/#{user_id}/lifecycle/reactivate?sendEmail=#{send_email}")
  JSON.parse(response.body)
end

#suspend_user(user_id) ⇒ Hash

Suspend a user in the okta instance.

Parameters:

  • user_id (String)

    the unique id of a user in the okta instance

Returns:

  • (Hash)

    empty hash

See Also:



139
140
141
# File 'lib/simpleokta/users.rb', line 139

def suspend_user(user_id)
  call_with_token('post', "#{Constants::USER_API_BASE_PATH}/#{user_id}/lifecycle/suspend")
end

#unlock_user(user_id) ⇒ Hash

Unlocks a user in the okta instance.

Only available when a user has LOCKED_OUT status.
Sets the user status to ACTIVE.

Parameters:

  • user_id (String)

    the unique id of a user in the okta instance

Returns:

  • (Hash)

    empty hash

See Also:



158
159
160
# File 'lib/simpleokta/users.rb', line 158

def unlock_user(user_id)
  call_with_token('post', "#{Constants::USER_API_BASE_PATH}/#{user_id}/lifecycle/unlock")
end

#unsuspend_user(user_id) ⇒ Hash

Unsuspend a user in the okta instance.

Sets the user status to ACTIVE.

Parameters:

  • user_id (String)

    the unique id of a user in the okta instance

Returns:

  • (Hash)

    empty hash

See Also:



148
149
150
# File 'lib/simpleokta/users.rb', line 148

def unsuspend_user(user_id)
  call_with_token('post', "#{Constants::USER_API_BASE_PATH}/#{user_id}/lifecycle/unsuspend")
end

#update_user(user_id, user_profile_data) ⇒ Hash<User>

Update a user in the okta instance

Parameters:

  • user_id (String)

    the unique id of a user in the okta instance

  • user_profile_data (Hash)

    the required fields to create a user in okta. At minimum, this should contain the Profile object. Any fields not passed in user_profile_data will be set to null in the user data

Returns:

  • (Hash<User>)

See Also:



94
95
96
97
# File 'lib/simpleokta/users.rb', line 94

def update_user(user_id, )
  response = call_with_token('put', "#{Constants::USER_API_BASE_PATH}/#{user_id}", )
  JSON.parse(response.body)
end

#user(user_id) ⇒ Hash<User>

Return a specific user in an okta instance

Parameters:

  • user_id (String)

    the unique id of a user in the okta instance

Returns:

  • (Hash<User>)

See Also:



20
21
22
23
# File 'lib/simpleokta/users.rb', line 20

def user(user_id)
  response = call_with_token('get', "#{Constants::USER_API_BASE_PATH}/#{user_id}")
  JSON.parse(response.body)
end

#user_from_login(login) ⇒ Hash<User>

Return a specific user in an okta instance

Parameters:

  • login (String)

    the login email of the user

Returns:

  • (Hash<User>)

See Also:



29
30
31
32
# File 'lib/simpleokta/users.rb', line 29

def ()
  response = call_with_token('get', "#{Constants::USER_API_BASE_PATH}/#{ERB::Util.url_encode(login)}")
  JSON.parse(response.body)
end

#usersArray<User>

Return all users in an okta instance

Returns:

  • (Array<User>)

See Also:



11
12
13
14
# File 'lib/simpleokta/users.rb', line 11

def users
  response = call_with_token('get', Constants::USER_API_BASE_PATH)
  JSON.parse(response.body)
end