diff --git a/src/keycloak/keycloak_admin.py b/src/keycloak/keycloak_admin.py index 3af3319..1d5bec2 100644 --- a/src/keycloak/keycloak_admin.py +++ b/src/keycloak/keycloak_admin.py @@ -3993,6 +3993,25 @@ class KeycloakAdmin: ) 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. @@ -9278,6 +9297,25 @@ class KeycloakAdmin: ) 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, diff --git a/src/keycloak/urls_patterns.py b/src/keycloak/urls_patterns.py index aa36810..05b2d39 100644 --- a/src/keycloak/urls_patterns.py +++ b/src/keycloak/urls_patterns.py @@ -62,6 +62,9 @@ URL_ADMIN_USER_REALM_ROLES_AVAILABLE = ( 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}"