# create group root and add user root
self._c.service.addUserGroupMember(self._sessionId, "root", "root")
# root should have access to all types
for icatType in ICatType.ALL_TYPES:
self._c.service.addRule(self._sessionId, "root", icatType,
"CRUD", None)
How do I accomplish this with the new API?
I think I have to create a ?group? or ?userGroup? first and then a new rule using the factory.
But I don't understand the relationship because rule references group and group references rules[].
I ran into Unexpected DB responses when I finally call the webservices create method.
Best,
Christian
# create group root
group = self._c.factory.create("group")
group.name = "root"
group.id = self._c.service.create(self._sessionId, group)
# root should have access to all types
for icatType in ICatType.ALL_TYPES:
rule = self._c.factory.create("rule")
rule.group = group
rule.crudFlags = "CRUD"
rule.what = icatType
self._c.service.create(self._sessionId, rule)
# create User and UserGroup to represent
# user -> group relationship
usr = self._c.factory.create("user")
usr.name = "root"
usr.fullName = "Superuser"
usr.id = self._c.service.create(self._sessionId, usr)
# relationship
usrGroup = self._c.factory.create("userGroup")
usrGroup.group = group
usrGroup.user = usr
self._c.service.create(self._sessionId, usrGroup)