|
36 | 36 | URL_ADMIN_USER_GROUPS, URL_ADMIN_CLIENTS, URL_ADMIN_FLOWS_EXECUTIONS, URL_ADMIN_GROUPS, URL_ADMIN_USER_CLIENT_ROLES, \ |
37 | 37 | URL_ADMIN_REALM_IMPORT, URL_ADMIN_USERS_COUNT, URL_ADMIN_FLOWS, URL_ADMIN_GROUP, URL_ADMIN_CLIENT_AUTHZ_SETTINGS, \ |
38 | 38 | URL_ADMIN_GROUP_MEMBERS, URL_ADMIN_USER_STORAGE, URL_ADMIN_GROUP_PERMISSIONS, URL_ADMIN_IDPS, \ |
39 | | - URL_ADMIN_USER_CLIENT_ROLES_AVAILABLE, URL_ADMIN_USERS |
| 39 | + URL_ADMIN_USER_CLIENT_ROLES_AVAILABLE, URL_ADMIN_USERS, URL_ADMIN_CLIENT_SCOPES, \ |
| 40 | + URL_ADMIN_CLIENT_SCOPES_ADD_MAPPER, URL_ADMIN_CLIENT_SCOPE |
40 | 41 |
|
41 | 42 |
|
42 | 43 | class KeycloakAdmin: |
@@ -869,3 +870,43 @@ def sync_users(self, storage_id, action): |
869 | 870 | data_raw = self.connection.raw_post(URL_ADMIN_USER_STORAGE.format(**params_path), |
870 | 871 | data=json.dumps(data), **params_query) |
871 | 872 | return raise_error_from_response(data_raw, KeycloakGetError) |
| 873 | + |
| 874 | + def get_client_scopes(self): |
| 875 | + """ |
| 876 | + Get representation of the client scopes for the realm where we are connected to |
| 877 | + https://www.keycloak.org/docs-api/4.5/rest-api/index.html#_getclientscopes |
| 878 | +
|
| 879 | + :return: Keycloak server response Array of (ClientScopeRepresentation) |
| 880 | + """ |
| 881 | + |
| 882 | + params_path = {"realm-name": self.realm_name} |
| 883 | + data_raw = self.connection.raw_get(URL_ADMIN_CLIENT_SCOPES.format(**params_path)) |
| 884 | + return raise_error_from_response(data_raw, KeycloakGetError) |
| 885 | + |
| 886 | + def get_client_scope(self, client_scope_id): |
| 887 | + """ |
| 888 | + Get representation of the client scopes for the realm where we are connected to |
| 889 | + https://www.keycloak.org/docs-api/4.5/rest-api/index.html#_getclientscopes |
| 890 | +
|
| 891 | + :return: Keycloak server response (ClientScopeRepresentation) |
| 892 | + """ |
| 893 | + |
| 894 | + params_path = {"realm-name": self.realm_name, "scope-id": client_scope_id} |
| 895 | + data_raw = self.connection.raw_get(URL_ADMIN_CLIENT_SCOPE.format(**params_path)) |
| 896 | + return raise_error_from_response(data_raw, KeycloakGetError) |
| 897 | + |
| 898 | + |
| 899 | + def add_mapper_to_client_scope(self, client_scope_id, payload): |
| 900 | + """ |
| 901 | + Add a mapper to a client scope |
| 902 | + https://www.keycloak.org/docs-api/4.5/rest-api/index.html#_create_mapper |
| 903 | +
|
| 904 | + :param payload: ProtocolMapperRepresentation |
| 905 | + :return: Keycloak server Response |
| 906 | + """ |
| 907 | + |
| 908 | + params_path = {"realm-name": self.realm_name, "scope-id": client_scope_id} |
| 909 | + |
| 910 | + data_raw = self.connection.raw_post(URL_ADMIN_CLIENT_SCOPES_ADD_MAPPER.format(**params_path), data=json.dumps(payload)) |
| 911 | + |
| 912 | + return raise_error_from_response(data_raw, KeycloakGetError, expected_code=201) |
0 commit comments