diff options
author | Gauvain Pocentek <gauvain@pocentek.net> | 2013-07-07 05:27:49 -0700 |
---|---|---|
committer | Gauvain Pocentek <gauvain@pocentek.net> | 2013-07-07 05:27:49 -0700 |
commit | 8f65cf8837944ec2640f983ef61a0e73877bd3bf (patch) | |
tree | 67d15a336b10d819ff32fc10553439e823b57852 /gitlab.py | |
parent | 05ab4732ceaee7d6d6c1f162b5925602b7c9ad44 (diff) | |
parent | cb5b7542edde926f73be6e7a2ab55f944ccbca00 (diff) | |
download | gitlab-8f65cf8837944ec2640f983ef61a0e73877bd3bf.tar.gz |
Merge pull request #1 from dekimsey/team-api
Addded API for team access.
Diffstat (limited to 'gitlab.py')
-rw-r--r-- | gitlab.py | 52 |
1 files changed, 52 insertions, 0 deletions
@@ -385,6 +385,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 @@ -852,3 +866,41 @@ class Project(GitlabObject): return self._getListOrObject(ProjectTag, id, project_id=self.id, **kwargs) + + +class TeamMember(GitlabObject): + _url = '/user_teams/%(team_id)s/members' + canUpdate = False + requiredCreateAttrs = ['team_id', 'user_id', 'access_level'] + requiredDeleteAttrs = ['team_id'] + requiredGetAttrs = ['team_id'] + requiredListAttrs = ['team_id'] + shortPrintAttr = 'username' + + +class TeamProject(GitlabObject): + _url = '/user_teams/%(team_id)s/projects' + _constructorTypes = {'owner': 'User', 'namespace': 'Group'} + canUpdate = False + requiredCreateAttrs = ['team_id', 'project_id', 'greatest_access_level'] + requiredDeleteAttrs = ['team_id', 'project_id'] + requiredGetAttrs = ['team_id'] + requiredListAttrs = ['team_id'] + shortPrintAttr = 'name' + + +class Team(GitlabObject): + _url = '/user_teams' + shortPrintAttr = 'name' + requiredCreateAttrs = ['name', 'path'] + canUpdate = False + + 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) |