Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions src/keycloak/keycloak_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3993,6 +3993,24 @@ def get_group_client_roles(self, group_id: str, client_id: str) -> list:
)
return raise_error_from_response(data_raw, KeycloakGetError)

def get_all_roles_of_group(self, group_id: str, brief_representation: bool = True) -> dict:
"""
Get all roles of a group.

:param group_id: id of the group
:type group_id: str
:param brief_representation: whether to omit role attributes in the response
:type brief_representation: bool
:return: Keycloak server response
:rtype: list
"""
params_path = {"realm-name": self.connection.realm_name, "id": group_id}
params = {"briefRepresentation": brief_representation}
data_raw = self.connection.raw_get(
urls_patterns.URL_ADMIN_GROUP_ALL_ROLES.format(**params_path), **params
)
return raise_error_from_response(data_raw, KeycloakGetError)

def delete_group_client_roles(self, group_id: str, client_id: str, roles: str | list) -> bytes:
"""
Delete client roles of a group.
Expand Down Expand Up @@ -9278,6 +9296,26 @@ async def a_get_group_client_roles(self, group_id: str, client_id: str) -> list:
)
return raise_error_from_response(data_raw, KeycloakGetError)

async def a_get_all_roles_of_group(
self, group_id: str, brief_representation: bool = True
) -> dict:
"""
Get all roles of a group asynchronously.

:param group_id: id of the group
:type group_id: str
:param brief_representation: whether to omit role attributes in the response
:type brief_representation: bool
:return: Keycloak server response
:rtype: list
"""
params_path = {"realm-name": self.connection.realm_name, "id": group_id}
params = {"briefRepresentation": brief_representation}
data_raw = await self.connection.a_raw_get(
urls_patterns.URL_ADMIN_GROUP_ALL_ROLES.format(**params_path), **params
)
return raise_error_from_response(data_raw, KeycloakGetError)

async def a_delete_group_client_roles(
self,
group_id: str,
Expand Down
1 change: 1 addition & 0 deletions src/keycloak/urls_patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
URL_ADMIN_USER_REALM_ROLES_COMPOSITE = (
"admin/realms/{realm-name}/users/{id}/role-mappings/realm/composite"
)
URL_ADMIN_GROUP_ALL_ROLES = "admin/realms/{realm-name}/groups/{id}/role-mappings"
URL_ADMIN_GROUPS_REALM_ROLES = "admin/realms/{realm-name}/groups/{id}/role-mappings/realm"
URL_ADMIN_GROUPS_CLIENT_ROLES = (
"admin/realms/{realm-name}/groups/{id}/role-mappings/clients/{client-id}"
Expand Down
Loading