From 7f0ed66803808c58fe2a21e37a6f498e281c4cd4 Mon Sep 17 00:00:00 2001 From: ggallard Date: Wed, 19 Aug 2020 18:31:04 -0300 Subject: [PATCH] Added create_client_scope --- keycloak/keycloak_admin.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/keycloak/keycloak_admin.py b/keycloak/keycloak_admin.py index ae443b6..7603a88 100644 --- a/keycloak/keycloak_admin.py +++ b/keycloak/keycloak_admin.py @@ -1252,6 +1252,22 @@ class KeycloakAdmin: data_raw = self.raw_get(URL_ADMIN_CLIENT_SCOPE.format(**params_path)) return raise_error_from_response(data_raw, KeycloakGetError) + def create_client_scope(self, payload, skip_exists=False): + """ + Create a client scope + + ClientScopeRepresentation: https://www.keycloak.org/docs-api/8.0/rest-api/index.html#_getclientscopes + + :param payload: ClientScopeRepresentation + :param skip_exists: If true then do not raise an error if client scope already exists + :return: Keycloak server response (ClientScopeRepresentation) + """ + + params_path = {"realm-name": self.realm_name} + data_raw = self.raw_post(URL_ADMIN_CLIENT_SCOPES.format(**params_path), + data=json.dumps(payload)) + return raise_error_from_response(data_raw, KeycloakGetError, expected_code=201, skip_exists=skip_exists) + def add_mapper_to_client_scope(self, client_scope_id, payload): """ Add a mapper to a client scope