I need to replace the permissions of a number of user groups because the groups are going to be renamed in Active Directory.
Due to the number of affected groups and repositories I need to do this automatically and I'm trying to use the REST API for this.
I can retrieve the groups and their permissions without problems, but I have trouble setting the new permissions because the documentation is incomplete:
https://docs.atlassian.com/fisheye-crucible/latest/wadl/fecru.html
If you expand the acceptable request representations part for PUT requests it's just empty. The examples from other PUT requests is not helping either.
The link to the REST API Examples from the documentation leads to a 404 and I can't find it anywhere else.
This is my python function to set the permissions for the new group name:
def repository_permissions_add(self, repository: str, group: str, permissions: object):
json_data = json.dumps({ 'permissions': permissions })
print(json_data)
response = self._put(self.fecru_url + "/rest-service-fecru/admin/repository-permissions/%s/groups/%s" % (repository, group),
data=json_data)
print(response.status_code)
print(response.text)
{"permissions": ["CAN_READ", "IS_ADMIN"]}
Can not deserialize instance of java.util.HashSet out of START_OBJECT token\n at [Source: HttpInputOverHTTP@4b333640[c=41,q=0,[0]=null,s=STREAM]; line: 1, column: 1]
I figured it out. The JSON Fisheye expected was wrong, it should only contain the permissions, with nothing around it.
['CAN_READ', 'IS_ADMIN']
Additionally, newer versions of the requests library have a json= parameter, which makes it even easier.
My function is now only:
def repository_permissions_add(self, repository: str, group: str, permissions: object):
response = self._put(self.fecru_url + "/rest-service-fecru/admin/repository-permissions/%s/groups/%s" % (repository, group),
json=permissions)
Note: The DELETE method expects the same JSON as the PUT method.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.