Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@ok_or_error
def remove_group(self, user, group):
"""
Remove the given group from the given user.
"""
return self._client.post(self.url("/remove-group"), dict(context=user, itemName=group))
@ok_or_error
def add_user(self, group, user):
"""
Add a user to a group.
"""
return self._client.post(self.url("/add-user"), dict(context=group, itemName=user))
@ok_or_error
def add_key(self, key_text, permission):
return self._client.post(self.url('/ssh', is_keys=True),
data=dict(key=dict(text=key_text),
permission=permission))
@ok_or_error
def create_branch(self, value, origin_branch='master'):
return self._client.post(self.url('/branches', is_branches=True),
data=dict(name=value, startPoint=origin_branch))
@ok_or_error
def _set_default_branch(self, value):
return self._client.put(self.url('/branches/default'), data=dict(id=value))
@ok_or_error
def delete_tag(self, name):
return self._client.delete(self.url('/tags/' + name, is_git=True))
@ok_or_error
def grant_to_group(self, group, permission):
"""
Grant a repository permission to a single group, i.e. set the default permission.
repository permissions:
* REPO_READ
* REPO_WRITE
* REPO_ADMIN
"""
return self._client.put(self._url_for_groups(), params=dict(name=group,
permission=permission))
@ok_or_error
def grant(self, user, permission):
"""
Promote or demote the permission level of a user.
Depending on context, you may use one of the following set of permissions:
global permissions:
* LICENSED_USER
* PROJECT_CREATE
* ADMIN
* SYS_ADMIN
project permissions:
* PROJECT_READ
@ok_or_error
def add_group(self, user, group):
"""
Add the given group to the given user.
"""
return self._client.post(self.url("/add-group"), dict(context=user, itemName=group))
@ok_or_error
def revoke_from_user(self, user):
"""
Revoke all repository permissions from a user.
"""
return self._client.delete(self._url_for_users(), params=dict(name=user))