diff options
author | samcday <sam.c.day@gmail.com> | 2013-05-09 16:09:56 +1000 |
---|---|---|
committer | samcday <sam.c.day@gmail.com> | 2013-05-09 16:09:56 +1000 |
commit | 5388d19f8885d3ca2f93c5e07ed58a1b84a87475 (patch) | |
tree | 25670b8c58b0e58e58020373223abedd7e1d5558 /gitlab.py | |
parent | 123a01e3cfda762202d58acc46c45ab58da57708 (diff) | |
download | gitlab-5388d19f8885d3ca2f93c5e07ed58a1b84a87475.tar.gz |
Basic team support.
Diffstat (limited to 'gitlab.py')
-rw-r--r-- | gitlab.py | 42 |
1 files changed, 42 insertions, 0 deletions
@@ -345,6 +345,20 @@ class Gitlab(object): """ return self._getListOrObject(User, id, **kwargs) + def Team(self, id=None, **kwargs): + """Creates/gets/lists team(s) known by the GitLab server. + + If id is None, returns a list of teams. + + If id is an integer, returns the matching project (or raise a + GitlabGetError if not found) + + If id is a dict, create a new object using attributes provided. The + object is NOT saved on the server. Use the save() method on the object + to write it on the server. + """ + return self._getListOrObject(Team, id, **kwargs) + class GitlabObject(object): _url = None @@ -705,3 +719,31 @@ class Project(GitlabObject): return self._getListOrObject(ProjectTag, id, project_id=self.id, **kwargs) + + +class TeamMember(GitlabObject): + _url = '/user_teams/%(team_id)d/members' + requiredCreateAttrs = ['user_id', 'access_level'] + canUpdate = False + + +class TeamProject(GitlabObject): + _url = '/user_teams/%(team_id)d/projects' + _constructorTypes = {'owner': 'User', 'namespace': 'Group'} + requiredCreateAttrs = ['project_id', 'greatest_access_level'] + canUpdate = False + + +class Team(GitlabObject): + _url = '/user_teams' + requiredCreateAttrs = ['name', 'path'] + + def Member(self, id=None, **kwargs): + return self._getListOrObject(TeamMember, id, + team_id=self.id, + **kwargs) + + def Project(self, id=None, **kwargs): + return self._getListOrObject(TeamProject, id, + team_id=self.id, + **kwargs) |