From 02d82f70bce4cb3ca0a4ea53b4cf142a03b459fb Mon Sep 17 00:00:00 2001 From: Clive Jevons Date: Fri, 12 Feb 2021 20:47:38 +0100 Subject: [PATCH] update mapper in client scope --- keycloak/keycloak_admin.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/keycloak/keycloak_admin.py b/keycloak/keycloak_admin.py index 8fd19f6..39fbdf4 100644 --- a/keycloak/keycloak_admin.py +++ b/keycloak/keycloak_admin.py @@ -1588,6 +1588,26 @@ class KeycloakAdmin: return raise_error_from_response(data_raw, KeycloakGetError, expected_codes=[204]) + def update_mapper_in_client_scope(self, client_scope_id, protocol_mapper_id, payload): + """ + Update an existing protocol mapper in a client scope + https://www.keycloak.org/docs-api/8.0/rest-api/index.html#_protocol_mappers_resource + + :param client_scope_id: The id of the client scope + :param protocol_mapper_id: The id of the protocol mapper which exists in the client scope + and should to be updated + :param payload: ProtocolMapperRepresentation + :return: Keycloak server Response + """ + + params_path = {"realm-name": self.realm_name, "scope-id": client_scope_id, + "protocol-mapper-id": protocol_mapper_id} + + data_raw = self.raw_put( + URL_ADMIN_CLIENT_SCOPES_MAPPERS.format(**params_path), data=json.dumps(payload)) + + return raise_error_from_response(data_raw, KeycloakGetError, expected_codes=[204]) + def add_mapper_to_client(self, client_id, payload): """ Add a mapper to a client