@@ -2910,7 +2910,9 @@ def get_realm_users_profile(self) -> dict:
29102910 )
29112911 return raise_error_from_response (data_raw , KeycloakGetError , expected_codes = [HTTP_OK ])
29122912
2913- def get_realm_roles (self , brief_representation : bool = True , search_text : str = "" ) -> list :
2913+ def get_realm_roles (
2914+ self , brief_representation : bool = True , search_text : str = "" , query : dict | None = None
2915+ ) -> list :
29142916 """
29152917 Get all roles for the realm or client.
29162918
@@ -2921,20 +2923,23 @@ def get_realm_roles(self, brief_representation: bool = True, search_text: str =
29212923 :type brief_representation: bool
29222924 :param search_text: optional search text to limit the returned result.
29232925 :type search_text: str
2926+ :param query: Query parameters (optional)
2927+ :type query: dict
29242928 :return: Keycloak server response (RoleRepresentation)
29252929 :rtype: list
29262930 """
2931+ query = query or {}
29272932 params_path = {"realm-name" : self .connection .realm_name }
29282933 params = {"briefRepresentation" : brief_representation }
2934+ url = urls_patterns .URL_ADMIN_REALM_ROLES .format (** params_path )
29292935
29302936 if search_text is not None and search_text .strip () != "" :
29312937 params ["search" ] = search_text
29322938
2933- data_raw = self .connection .raw_get (
2934- urls_patterns .URL_ADMIN_REALM_ROLES .format (** params_path ),
2935- ** params ,
2936- )
2937- return raise_error_from_response (data_raw , KeycloakGetError )
2939+ if "first" in query and "max" in query :
2940+ return self .__fetch_paginated (url , query )
2941+
2942+ return self .__fetch_all (url , params )
29382943
29392944 def get_realm_role_groups (
29402945 self ,
@@ -8176,9 +8181,7 @@ async def a_get_realm_users_profile(self) -> dict:
81768181 return raise_error_from_response (data_raw , KeycloakGetError , expected_codes = [HTTP_OK ])
81778182
81788183 async def a_get_realm_roles (
8179- self ,
8180- brief_representation : bool = True ,
8181- search_text : str = "" ,
8184+ self , brief_representation : bool = True , search_text : str = "" , query : dict | None = None
81828185 ) -> list :
81838186 """
81848187 Get all roles for the realm or client asynchronously.
@@ -8190,20 +8193,23 @@ async def a_get_realm_roles(
81908193 :type brief_representation: bool
81918194 :param search_text: optional search text to limit the returned result.
81928195 :type search_text: str
8196+ :param query: Query parameters (optional)
8197+ :type query: dict
81938198 :return: Keycloak server response (RoleRepresentation)
81948199 :rtype: list
81958200 """
8201+ query = query or {}
81968202 params_path = {"realm-name" : self .connection .realm_name }
81978203 params = {"briefRepresentation" : brief_representation }
8204+ url = urls_patterns .URL_ADMIN_REALM_ROLES .format (** params_path )
81988205
81998206 if search_text is not None and search_text .strip () != "" :
82008207 params ["search" ] = search_text
82018208
8202- data_raw = await self .connection .a_raw_get (
8203- urls_patterns .URL_ADMIN_REALM_ROLES .format (** params_path ),
8204- ** params ,
8205- )
8206- return raise_error_from_response (data_raw , KeycloakGetError )
8209+ if "first" in query and "max" in query :
8210+ return await self .a___fetch_paginated (url , query )
8211+
8212+ return await self .a___fetch_all (url , params )
82078213
82088214 async def a_get_realm_role_groups (
82098215 self ,
0 commit comments