Commit fe60f99f authored by redmitry@list.ru's avatar redmitry@list.ru

get all groups data at once (briefRepresentation=false)

parent 504deb3c
......@@ -101,7 +101,7 @@ def deleteGroup(group, headers):
# Get the 'Community' group with all its subgroups (openebench communities)
def getKeycloakCommunities(headers):
KC_OEB_GROUPS = KEYCLOAK_OPENEBENCH_REALM + 'groups'
KC_OEB_GROUPS = KEYCLOAK_OPENEBENCH_REALM + 'groups?briefRepresentation=false'
groups_req = urllib.request.Request(KC_OEB_GROUPS, headers=headers)
groups_res = urllib.request.urlopen(groups_req);
......@@ -113,7 +113,7 @@ def getKeycloakCommunities(headers):
for group in groups:
if (group['name'] == 'Community'):
return enhanceGroups(group, headers)
return group
## add Community group
KC_OEB_GROUPS = KEYCLOAK_OPENEBENCH_REALM + 'groups'
......@@ -128,28 +128,6 @@ def getKeycloakCommunities(headers):
if(group_res.getcode() >= 400):
print("error adding Keycloak 'Community' group ", group_req)
# getting GroupRepresentation[] via /groups doesn't return 'attributes'
# update it calling /groups/{id} one by one
def enhanceGroups(root, headers):
for group in root['subGroups']:
group_id = group['id']
KC_OEB_GROUP = KEYCLOAK_OPENEBENCH_REALM + 'groups/' + group_id
group_req = urllib.request.Request(KC_OEB_GROUP, headers=headers)
group_res = urllib.request.urlopen(group_req);
if(group_res.getcode() >= 400):
print("error obtaining openebench user groups", group_req)
data = group_res.read()
subgroup = json.loads(data)
group['attributes'] = subgroup['attributes']
return root
# Get OpenEBench communities via the REST API
def getOpenebenchCommunities():
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment