Skip to content

Commit

Permalink
support creation of projects for users
Browse files Browse the repository at this point in the history
  • Loading branch information
Gauvain Pocentek committed Dec 26, 2013
1 parent 0ee6ca5 commit dc2bf5e
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion gitlab.py
Expand Up @@ -348,6 +348,13 @@ def Project(self, id=None, **kwargs):
"""
return self._getListOrObject(Project, id, **kwargs)

def UserProject(self, id=None, **kwargs):
"""Creates a project for a user.
id must be a dict.
"""
return self._getListOrObject(UserProject, id, **kwargs)

def _list_projects(self, url):
r = self.rawGet(url)
if r.status_code != 200:
Expand Down Expand Up @@ -892,6 +899,20 @@ def Note(self, id=None, **kwargs):
**kwargs)


class UserProject(GitlabObject):
_url = '/projects/user/%(user_id)s'
_constructorTypes = {'owner': 'User', 'namespace': 'Group'}
canUpdate = False
canDelete = False
canList = False
canGet = False
requiredCreateAttrs = ['name', 'user_id']
optionalCreateAttrs = ['default_branch', 'issues_enabled', 'wall_enabled',
'merge_requests_enabled', 'wiki_enabled',
'snippets_enabled', 'public', 'visibility_level',
'description']


class Project(GitlabObject):
_url = '/projects'
_constructorTypes = {'owner': 'User', 'namespace': 'Group'}
Expand All @@ -900,7 +921,8 @@ class Project(GitlabObject):
requiredCreateAttrs = ['name']
optionalCreateAttrs = ['default_branch', 'issues_enabled', 'wall_enabled',
'merge_requests_enabled', 'wiki_enabled',
'namespace_id']
'snippets_enabled', 'public', 'visibility_level',
'namespace_id', 'description']
shortPrintAttr = 'path'

def Branch(self, id=None, **kwargs):
Expand Down

0 comments on commit dc2bf5e

Please sign in to comment.