module Simpleokta::Client::Users
Public Instance Methods
Activate a user in the okta instance.
Users created are not immediately activated until they log on. This method bypasses that requirement
@param user_id [String] the unique id of a user in the okta instance @param send_email [Boolean] whether or not to send an activation email to the user @return [Hash] contains information on activation.
If send_email is set to True, returns an empty hash.
@see developer.okta.com/docs/reference/api/users/#activate-user Activate User
# 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
List all applications a user currently has assigned to them. @param user_id [String] the unique id of a user in the okta instance @return [Array<Application Object>] @see developer.okta.com/docs/reference/api/apps/#application-object Application Object @see developer.okta.com/docs/reference/api/apps/#list-applications-assigned-to-a-user List Applications Assigned to User
# 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 an activated user in the okta instance without credentials @param user_profile_data [Hash] the required fields to create a user in okta.
At minimum, this should contain the Profile object.
@return [Hash<User>] @see developer.okta.com/docs/reference/api/users/#create-user Create User @see developer.okta.com/docs/reference/api/users/#profile-object Profile Object
# File lib/simpleokta/users.rb, line 59 def create_and_activate_user(user_profile_data) response = call_with_token('post', "#{Constants::USER_API_BASE_PATH}?activate=true", user_profile_data) JSON.parse(response.body) end
Create a user in the okta instance without credentials @param user_profile_data [Hash] the required fields to create a user in okta.
At minimum, this should contain the Profile object.
@example Profile Object
"profile": { "firstName": "Isaac", "lastName": "Brock", "email": "isaac.brock@example.com", "login": "isaac.brock@example.com", "mobilePhone": "555-415-1337" }
@return [Hash<User>] @see developer.okta.com/docs/reference/api/users/#create-user Create User @see developer.okta.com/docs/reference/api/users/#profile-object Profile Object
# File lib/simpleokta/users.rb, line 48 def create_user(user_profile_data) response = call_with_token('post', "#{Constants::USER_API_BASE_PATH}?activate=false", user_profile_data) JSON.parse(response.body) end
Create a user in the okta insance, and have the user added to groups @param user_profile_data [Hash] the required fields to create a user in okta.
At minimum, this should contain the Profile object.
@param group_id_array [Array<String>] the group ids the user should be added to @return [Hash<User>] @see developer.okta.com/docs/reference/api/users/#user-object User Object @see developer.okta.com/docs/reference/api/users/#create-user-in-group Create User in Group
# File lib/simpleokta/users.rb, line 71 def create_user_in_group(user_profile_data, group_id_array) body = user_profile_data body[:groupIds] = group_id_array response = call_with_token('post', Constants::USER_API_BASE_PATH, body) JSON.parse(response.body) end
Deactivates a user in the okta instance. @param user_id [String] the unique id of a user in the okta instance @param send_email [Boolean] whether or not to send an activation email to the user @return [Hash] empty hash @see developer.okta.com/docs/reference/api/users/#deactivate-user Deactivate User
# 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 a user in the okta instance @param user_id [String] the unique id of a user in the okta instance @return [Hash<User>] @see developer.okta.com/docs/reference/api/users/#user-object User Object
# 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
Reactivates a user in the okta instance that was deactivated. @param user_id [String] the unique id of a user in the okta instance @param send_email [Boolean] whether or not to send an activation email to the user @return [Hash] contains information on activation.
If send_email is set to True, returns an empty hash.
@see developer.okta.com/docs/reference/api/users/#reactivate-user Reactivate User
# 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 a user in the okta instance. @param user_id [String] the unique id of a user in the okta instance @return [Hash] empty hash @see developer.okta.com/docs/reference/api/users/#suspend-user Suspend User
# 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
Unlocks a user in the okta instance.
Only available when a user has LOCKED_OUT status. Sets the user status to ACTIVE.
@param user_id [String] the unique id of a user in the okta instance @return [Hash] empty hash @see developer.okta.com/docs/reference/api/users/#unlock-user Unlock User
# 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 a user in the okta instance.
Sets the user status to ACTIVE.
@param user_id [String] the unique id of a user in the okta instance @return [Hash] empty hash @see developer.okta.com/docs/reference/api/users/#unsuspend-user Unsuspend User
# 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 a user in the okta instance @param user_id [String] the unique id of a user in the okta instance @param 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
@return [Hash<User>] @see developer.okta.com/docs/reference/api/users/#user-object User Object
# File lib/simpleokta/users.rb, line 94 def update_user(user_id, user_profile_data) response = call_with_token('put', "#{Constants::USER_API_BASE_PATH}/#{user_id}", user_profile_data) JSON.parse(response.body) end
Return a specific user in an okta instance @param user_id [String] the unique id of a user in the okta instance @return [Hash<User>] @see developer.okta.com/docs/reference/api/users/#user-object User Object
# 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
Return a specific user in an okta instance @param login [String] the login email of the user @return [Hash<User>] @see developer.okta.com/docs/reference/api/users/#user-object User Object
# File lib/simpleokta/users.rb, line 29 def user_from_login(login) response = call_with_token('get', "#{Constants::USER_API_BASE_PATH}/#{ERB::Util.url_encode(login)}") JSON.parse(response.body) end
Return all users in an okta instance @return [Array<User>] @see developer.okta.com/docs/reference/api/users/#user-object User Object
# File lib/simpleokta/users.rb, line 11 def users response = call_with_token('get', Constants::USER_API_BASE_PATH) JSON.parse(response.body) end