Module: Simpleokta::Client::Groups

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

Instance Method Summary collapse

Instance Method Details

#add_user_to_group(group_id, user_id) ⇒ Object

Add a user to a group

Parameters:

  • group_id (String)

    the unique identifier of the group

  • user_id (String)

    the unique identifier of the user

Returns:

  • 204 No Content

See Also:



99
100
101
# File 'lib/simpleokta/groups.rb', line 99

def add_user_to_group(group_id, user_id)
  call_with_token('put', "#{Constants::GROUP_API_BASE_PATH}/#{group_id}/users/#{user_id}")
end

#apps_assigned_to_group(group_id) ⇒ Array<Group Object>

Return all applications members of a group have automatically assigned to them.

Parameters:

  • group_id (String)

    the unique identifier of the group

Returns:

  • (Array<Group Object>)

See Also:



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

def apps_assigned_to_group(group_id)
  response = call_with_token('get', "#{Constants::GROUP_API_BASE_PATH}/#{group_id}/apps")
  JSON.parse(response.body)
end

#assign_group_to_application(app_id, group_id) ⇒ Hash<Application Group Object>

Set an application to be automatically assigned to members of a group

Parameters:

  • app_id (String)

    the unique id of the application

  • group_id (String)

    the unique identifier of the group

Returns:

  • (Hash<Application Group Object>)

See Also:



40
41
42
43
# File 'lib/simpleokta/groups.rb', line 40

def assign_group_to_application(app_id, group_id)
  response = call_with_token('put', "#{Constants::APP_API_BASE_PATH}/#{app_id}/groups/#{group_id}")
  JSON.parse(response.body)
end

#get_assigned_group_for_application(app_id, group_id) ⇒ Group Assignment

Returns an application group assignment

Parameters:

  • app_id (String)

    the unique id of the application

  • group_id (String)

    the unique identifier of the group

Returns:

  • (Group Assignment)

See Also:



60
61
62
63
# File 'lib/simpleokta/groups.rb', line 60

def get_assigned_group_for_application(app_id, group_id)
  response = call_with_token('get', "#{Constants::APP_API_BASE_PATH}/#{app_id}/groups/#{group_id}")
  JSON.parse(response.body)
end

#group(group_id) ⇒ Hash<Group Object>

Return a specific Group in the okta instance.

Parameters:

  • group_id (String)

    the unique identifier of the group

Returns:

  • (Hash<Group Object>)

See Also:



12
13
14
15
# File 'lib/simpleokta/groups.rb', line 12

def group(group_id)
  response = call_with_token('get', "#{Constants::GROUP_API_BASE_PATH}/#{group_id}")
  JSON.parse(response.body)
end

#group_members(group_id) ⇒ Object

Get all members assigned to a group

Parameters:

  • group_id (String)

    the unique identifier of the group

Returns:

  • 204 No Content

See Also:



89
90
91
92
# File 'lib/simpleokta/groups.rb', line 89

def group_members(group_id)
  response = call_with_token('get', "#{Constants::GROUP_API_BASE_PATH}/#{group_id}/users")
  JSON.parse(response.body)
end

#groupsArray<Group Object>

Return all Groups in the okta instance.

Returns:

  • (Array<Group Object>)

See Also:



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

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

#remove_group(group_id) ⇒ Object

Remove a group from your org.

Parameters:

  • group_id (String)

    the unique identifier of the group

Returns:

  • 204 No Content

See Also:



81
82
83
# File 'lib/simpleokta/groups.rb', line 81

def remove_group(group_id)
  call_with_token('delete', "#{Constants::GROUP_API_BASE_PATH}/#{group_id}")
end

#remove_group_from_application(app_id, group_id) ⇒ Group Assignment

Set an application to no longer be automatically assigned to members of a group

Parameters:

  • app_id (String)

    the unique id of the application

  • group_id (String)

    the unique identifier of the group

Returns:

  • (Group Assignment)

See Also:



51
52
53
# File 'lib/simpleokta/groups.rb', line 51

def remove_group_from_application(app_id, group_id)
  call_with_token('delete', "#{Constants::APP_API_BASE_PATH}/#{app_id}/groups/#{group_id}")
end

#remove_user_from_group(group_id, user_id) ⇒ Object

Remove a user from a group

Parameters:

  • group_id (String)

    the unique identifier of the group

  • user_id (String)

    the unique identifier of the user

Returns:

  • 204 No Content

See Also:



108
109
110
# File 'lib/simpleokta/groups.rb', line 108

def remove_user_from_group(group_id, user_id)
  call_with_token('delete', "#{Constants::GROUP_API_BASE_PATH}/#{group_id}/users/#{user_id}")
end

#update_group(group_id, group_data) ⇒ Hash<Group Object>

Update a group in the okta instance.

Parameters:

  • group_id (String)

    the unique identifier of the group

  • group_data (Hash)

    the data you want the group to contain

Returns:

  • (Hash<Group Object>)

See Also:



71
72
73
74
# File 'lib/simpleokta/groups.rb', line 71

def update_group(group_id, group_data)
  response = call_with_token('put', "#{Constants::GROUP_API_BASE_PATH}/#{group_id}", group_data)
  JSON.parse(response.body)
end