Browse Source
Merge pull request #258 from modularTaco/add-client-session-stats
add client session stats
pull/266/head
Marcos Pereira
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
18 additions and
2 deletions
-
keycloak/keycloak_admin.py
-
keycloak/urls_patterns.py
|
|
@ -2295,7 +2295,6 @@ class KeycloakAdmin: |
|
|
|
data_raw = self.connection.raw_get(URL_ADMIN_CLIENT_ALL_SESSIONS.format(**params_path)) |
|
|
|
return raise_error_from_response(data_raw, KeycloakGetError) |
|
|
|
|
|
|
|
|
|
|
|
def delete_user_realm_role(self, user_id, payload): |
|
|
|
""" |
|
|
|
Delete realm-level role mappings |
|
|
@ -2306,3 +2305,18 @@ class KeycloakAdmin: |
|
|
|
data_raw = self.connection.raw_delete(URL_ADMIN_DELETE_USER_ROLE.format(**params_path), |
|
|
|
data=json.dumps(payload)) |
|
|
|
return raise_error_from_response(data_raw, KeycloakGetError, expected_codes=[204]) |
|
|
|
|
|
|
|
def get_client_sessions_stats(self): |
|
|
|
""" |
|
|
|
Get current session count for all clients with active sessions |
|
|
|
|
|
|
|
https://www.keycloak.org/docs-api/16.1/rest-api/index.html#_getclientsessionstats |
|
|
|
|
|
|
|
:return: Dict of clients and session count |
|
|
|
""" |
|
|
|
params_path = {"realm-name": self.realm_name} |
|
|
|
data_raw = self.raw_get( |
|
|
|
self.URL_ADMIN_CLIENT_SESSION_STATS.format(**params_path) |
|
|
|
) |
|
|
|
return raise_error_from_response(data_raw, KeycloakGetError) |
|
|
|
|
|
|
@ -124,3 +124,5 @@ URL_ADMIN_USER_FEDERATED_IDENTITY = "admin/realms/{realm-name}/users/{id}/federa |
|
|
|
URL_ADMIN_EVENTS = 'admin/realms/{realm-name}/events' |
|
|
|
|
|
|
|
URL_ADMIN_DELETE_USER_ROLE = "admin/realms/{realm-name}/users/{id}/role-mappings/realm" |
|
|
|
|
|
|
|
URL_ADMIN_CLIENT_SESSION_STATS = "admin/realms/{realm-name}/client-session-stats" |