Jira, Soap and Python revisited
As things usual, everything does not go as espected. When adding projects to Jira, you usually must set default permission sets and assing users to grops and what not. One especially irritating command (from Python point of view) in Jira’s SOAP api is
addActorsToProjectRole
which is quite useful, a must, when setting group permissions to specific project. When using SOAPpy, the correct way to call the method is:
soap.addActorsToProjectRole(v4=proj, v1=helper.token,v3=projectrole, actorType="atlassian-group-role-actor",v2=[group])
This add’s group actor, refer to Atlassian documentation to add user-actors to project roles. Remember that you can get project and project roles through soap by using jpypye and casting Python longs to Java.
Don’t ask me why, but this seems to render acceptable xml that Jira’s serverside implementation can read. A bit odd, but Atlassian supports only Java on SOAP side, so probably you’re more safe with Axis.
Another unfortunate thing concerns project creation. (This is to remind myself): WHEN users or groups have been added to project roles, like for giving permissions to delete work logs etc (and this usually concerns the defaul perimission set), we must remove the entries for users by walking through the permiossion set like this:
for y in permissionset[3]: #print y if len(y["remoteEntities"]) > 1: try: y._placeItem("remoteEntities",None,1) except Exception, e: print e pass
permissionset variable holds the Permission-set object, and slot [3] holds the actual permissions. If additional users or groups are added to the permission set, then permission (remoteEntities) will hold those users in a list, which must be “deleted” by assigning None. Otherwise the soap will complain about ‘email’, or ‘name’ fields. So that does it in Python.