Browse Source

Merged in mattboret/python-keycloak (pull request #34)

Add support to create a new Realm

Approved-by: Marcos Pereira <marcospereira.mpj@gmail.com>
pull/12/head
Matthieu BORET 6 years ago
committed by Marcos Pereira
parent
commit
a5a6263253
  1. 3
      README.md
  2. 16
      keycloak/keycloak_admin.py

3
README.md

@ -236,4 +236,7 @@ keycloak_admin.assign_client_role(client_id=client_id, user_id=user_id, role_id=
# Get all ID Providers
idps = keycloak_admin.get_idps()
# Create a new Realm
keycloak_admin.create_realm(payload={"realm": "demo", skip_exists=False)
```

16
keycloak/keycloak_admin.py

@ -145,6 +145,22 @@ class KeycloakAdmin:
data_raw = self.connection.raw_get(URL_ADMIN_REALMS)
return raise_error_from_response(data_raw, KeycloakGetError)
def create_realm(self, payload, skip_exists=False):
"""
Create a client
ClientRepresentation: http://www.keycloak.org/docs-api/3.3/rest-api/index.html#_realmrepresentation
:param skip_exists: Skip if Realm already exist.
:param payload: RealmRepresentation
:return: Keycloak server response (UserRepresentation)
"""
data_raw = self.connection.raw_post(URL_ADMIN_REALMS,
data=json.dumps(payload))
return raise_error_from_response(data_raw, KeycloakGetError, expected_code=201, skip_exists=skip_exists)
def get_users(self, query=None):
"""
Get users Returns a list of users, filtered according to query parameters

Loading…
Cancel
Save