From 71c87508a268fafbcb0043617ec3aa7ed0e733fd Mon Sep 17 00:00:00 2001 From: Gauvain Pocentek Date: Thu, 26 Sep 2013 20:38:58 +0200 Subject: Add support for Gitlab 6.1 group members --- gitlab.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'gitlab.py') diff --git a/gitlab.py b/gitlab.py index b804294..628bf18 100644 --- a/gitlab.py +++ b/gitlab.py @@ -187,7 +187,7 @@ class Gitlab(object): cls = obj_class if obj_class._returnClass: cls = obj_class._returnClass - l = [cls(self, item) for item in r.json()] + l = [cls(self, item) for item in r.json() if item is not None] if kwargs: for k, v in kwargs.items(): if k in ('page', 'per_page'): @@ -571,12 +571,26 @@ class CurrentUser(GitlabObject): return CurrentUserKey(self.gitlab, id) +class GroupMember(GitlabObject): + _url = '/groups/%(group_id)s/members' + canGet = False + canUpdate = False + requiredCreateAttrs = ['group_id', 'user_id', 'access_level'] + requiredDeleteAttrs = ['group_id', 'user_id'] + shortPrintAttr = 'username' + + class Group(GitlabObject): _url = '/groups' _constructorTypes = {'projects': 'Project'} requiredCreateAttrs = ['name', 'path'] shortPrintAttr = 'name' + def Member(self, id=None, **kwargs): + return self._getListOrObject(GroupMember, id, + group_id=self.id, + **kwargs) + def transfer_project(self, id): url = '/groups/%d/projects/%d' % (self.id, id) r = self.gitlab.rawPost(url, None) -- cgit v1.2.1