Groups

https://www.keycloak.org/docs-api/26.0.0/rest-api/index.html#_groups

class keycloak_admin_aio._resources.groups.Groups

Provides the Keycloak group resource

from keycloak_admin_aio import KeycloakAdmin, GroupRepresentation

kc: KeycloakAdmin  # must be instantiated
get_url()

Get the resource’s url.

Return type:

str

async get(brief_representation=None, first=None, max=None, search=None)

Get groups.

groups: list[GroupRepresentation] = await kc.groups.get()
Parameters:
  • brief_representation (bool | None)

  • first (int | None)

  • max (int | None)

  • search (str | None)

Return type:

list[GroupRepresentation]

async create(group_representation)

Create a group.

group_representation = GroupRepresentation(name="group-name")
group_id: str = await kc.groups.create(group_representation)
Parameters:

group_representation (GroupRepresentation)

Return type:

str

async count(search=None, top=None)

Get group count.

group_count: int = await kc.groups.count()
Parameters:
  • search (str | None)

  • top (bool | None)

Return type:

int

Groups by id

class keycloak_admin_aio._resources.groups.by_id.GroupsById

Groups by id.

from keycloak_admin_aio import KeycloakAdmin, GroupRepresentation

kc: KeycloakAdmin  # must be instantiated
group_id: str  # uuid
get_url()

Get the resource’s url.

Return type:

str

async get()

Get a group by id.

group: GroupRepresentation = await kc.groups.by_id(group_id).get()
Return type:

GroupRepresentation

async update(group_representation)

Update a group by id.

group_representation = GroupRepresentation(name="group-name")
await kc.groups.by_id(group_id).update(group_representation)
Parameters:

group_representation (GroupRepresentation)

async delete()

Delete a group by id.

await kc.groups.by_id(group_id).delete()

Children for a group by id

class keycloak_admin_aio._resources.groups.by_id.children.GroupsByIdChildren

Get children of a group by id.

from keycloak_admin_aio import KeycloakAdmin, GroupRepresentation

kc: KeycloakAdmin  # must be instantiated
group_id: str  # uuid
get_url()

Get the resource’s url.

Return type:

str

async create(group_representation)

Create a parent/child group relationship.

group_representation = GroupRepresentation(name="child-group-name")
await kc.goups.by_id(group_id).children.add(group_representation)
Parameters:

group_representation (GroupRepresentation)

Members for a group by id

class keycloak_admin_aio._resources.groups.by_id.members.GroupsByIdMembers

Members of groups by id.

from keycloak_admin_aio import KeycloakAdmin, UserRepresentation

kc: KeycloakAdmin  # must be instantiated
group_id: str  # uuid
get_url()

Get the resource’s url.

Return type:

str

async get(brief_representation=None, first=None, max=None)

Get members of a group by id.

members: list[UserRepresentation] = await kc.groups.by_id(group_id).members.get()
Parameters:
  • brief_representation (bool | None)

  • first (int | None)

  • max (int | None)

Return type:

list[UserRepresentation]