Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
* REPO_ADMIN
"""
return self._client.put(self._url_for_groups(), params=dict(name=group,
permission=permission))
@ok_or_error
def revoke_from_group(self, group):
"""
Revoke all repository permissions from a group.
"""
return self._client.delete(self._url_for_groups(), params=dict(name=group))
update_doc(Groups.all, """
Returns groups that have been granted at least one permission.
filter: return only group names containing the supplied string will be returned
""")
update_doc(Users.all, """
Returns users that have been granted at least one permission.
"""
Create a repository with the given name
"""
return self._client.post(self.url(), data={"name": name,
"scmId": scmId,
"forkable": forkable,
})
def __getitem__(self, item):
"""
Return a :class:`Repository` object for operations on a specific repository
"""
return Repository(item, self.url(item), self._client, self)
update_doc(Repos.all, """Retrieve repositories from the project""")
params['filter'] = filter
return self.paginate("/more-members", params)
def more_non_members(self, user, filter=None):
"""
Retrieves a list of groups that the specified user is not a member of
filter: if specified only groups with names containing the supplied string will be returned
"""
params = dict(context=user)
if filter:
params['filter'] = filter
return self.paginate("/more-non-members", params)
update_doc(Users.all, """
Returns an iterator that will walk all the users, paginating as necessary.
def __getitem__(self, item):
return Project(item, self.url(item), self._client, self)
@response_or_error
def create(self, key, name, description='', avatar=None):
"""
Create a project. If supplied, avatar should be a base64 encoded image.
"""
data = dict(key=key, name=name, description=description)
if avatar:
data['avatar'] = "data:image/png;base64," + avatar
return self._client.post(self.url(), data)
update_doc(Projects.all, """Retrieve projects.""")
@ok_or_error
def revoke_from_group(self, group):
"""
Revoke all repository permissions from a group.
"""
return self._client.delete(self._url_for_groups(), params=dict(name=group))
update_doc(Groups.all, """
Returns groups that have been granted at least one permission.
filter: return only group names containing the supplied string will be returned
""")
update_doc(Users.all, """
Returns users that have been granted at least one permission.
params['filter'] = filter
return self.paginate("/more-members", params)
def more_non_members(self, group, filter=None):
"""
Retrieves a list of users that are not members of a specified group.
filter: return only users with usernames, display names or email addresses containing this string
"""
params = dict(context=group)
if filter:
params['filter'] = filter
return self.paginate("/more-non-members", params)
update_doc(Groups.all, """
Returns an iterator that will walk all the groups, paginating as necessary.
def create(self, match, users=None, groups=None, keys=None,
restriction_type=RestrictionType.READ_ONLY,
matcher_type=Matcher.PATTERN):
"""
Restrict a branch, or set of branches defined by a pattern,
to a set of users, groups, and access keys.
Note: access keys need to be specified by their numerical id. labels are
not accepted.
"""
data = Restriction.request_data(match, users, groups, keys,
restriction_type, matcher_type)
return self._client.post(self.url(""), data=data)
update_doc(Restrictions.all, """Retrieve list of restrictions for a repo""")
class BranchPermissions(ResourceBase):
"""Simple parent resource for this api, to distinguish restrictions from anything else"""
restrictions = Nested(Restrictions)