Add community.general.keycloak_realm_users_info into keycloak collection

This commit is contained in:
Harsha Cherukuri
2026-07-23 22:31:32 -04:00
parent f2792e32ba
commit ff51c4098a
5 changed files with 158 additions and 0 deletions

View File

@@ -1108,6 +1108,22 @@ class KeycloakAPI:
except Exception as e:
self.fail_request(e, msg=f"Could not obtain the user for realm {realm} and username {username}: {e}")
def get_realm_users(self, realm: str = "master") -> list[dict[str, t.Any]]:
"""Obtain list of users from the realm
:param realm: realm id
:return: list of user representations
"""
users_url = URL_USERS.format(url=self.baseurl, realm=realm)
try:
return self._request_and_deserialize(users_url, method="GET")
except ValueError as e:
self.module.fail_json(
msg=f"API returned incorrect JSON when trying to obtain the users for realm {realm}: {e}"
)
except Exception as e:
self.fail_request(e, msg=f"Could not obtain the users for realm {realm}: {e}")
def get_service_account_user_by_client_id(self, client_id, realm: str = "master"):
"""Fetch a keycloak service account user within a realm based on its client_id.