Module: Keycloak::Admin::Groups
- Extended by:
- Resource, Resource::Pagination
- Defined in:
- lib/keycloak/admin/groups.rb
Overview
Groups resource.
The class is based on Keycloak::Admin::Resource and Keycloak::Admin::Resource::Pagination. It provides following additional methods:
-
::add
-
::remove
-
::members
Constant Summary
Constants included from Resource::Pagination
Resource::Pagination::MAX_ENTRIES
Instance Attribute Summary
Attributes included from Resource
Class Method Summary collapse
-
.add(id, user_id) ⇒ Object
Add user to group.
-
.members(id) ⇒ Object
Get group members.
-
.remove(id, user_id) ⇒ Object
Remove user from group.
-
.subgroup(id, attributes) ⇒ Object
Create subgroup.
Methods included from Resource::Pagination
Methods included from Resource
all, create, delete, find_by, find_by_id, update
Class Method Details
.add(id, user_id) ⇒ Object
Add user to group.
25 26 27 28 29 |
# File 'lib/keycloak/admin/groups.rb', line 25 def add(id, user_id) @agent.put("/admin/realms/#{@agent.realm}/users/#{user_id}/groups/#{id}") true end |
.members(id) ⇒ Object
Get group members.
41 42 43 44 45 46 47 48 49 |
# File 'lib/keycloak/admin/groups.rb', line 41 def members(id) objects = [] (1..pages).each do |page| first = (page * MAX_ENTRIES) - MAX_ENTRIES objects << @agent.get("#{resource}/#{id}/members?first=#{first}&max=#{MAX_ENTRIES}") end objects.flatten.map { |object| mash(object) } end |
.remove(id, user_id) ⇒ Object
Remove user from group.
33 34 35 36 37 |
# File 'lib/keycloak/admin/groups.rb', line 33 def remove(id, user_id) @agent.delete("/admin/realms/#{@agent.realm}/users/#{user_id}/groups/#{id}") true end |
.subgroup(id, attributes) ⇒ Object
Create subgroup.
53 54 55 56 57 |
# File 'lib/keycloak/admin/groups.rb', line 53 def subgroup(id, attributes) @agent.post("#{resource}/#{id}/children", params: { body: attributes.to_json }) true end |