Skip to content

Commit dc2bf5e

Browse files
author
Gauvain Pocentek
committed
support creation of projects for users
1 parent 0ee6ca5 commit dc2bf5e

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

gitlab.py

+23-1
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,13 @@ def Project(self, id=None, **kwargs):
348348
"""
349349
return self._getListOrObject(Project, id, **kwargs)
350350

351+
def UserProject(self, id=None, **kwargs):
352+
"""Creates a project for a user.
353+
354+
id must be a dict.
355+
"""
356+
return self._getListOrObject(UserProject, id, **kwargs)
357+
351358
def _list_projects(self, url):
352359
r = self.rawGet(url)
353360
if r.status_code != 200:
@@ -892,6 +899,20 @@ def Note(self, id=None, **kwargs):
892899
**kwargs)
893900

894901

902+
class UserProject(GitlabObject):
903+
_url = '/projects/user/%(user_id)s'
904+
_constructorTypes = {'owner': 'User', 'namespace': 'Group'}
905+
canUpdate = False
906+
canDelete = False
907+
canList = False
908+
canGet = False
909+
requiredCreateAttrs = ['name', 'user_id']
910+
optionalCreateAttrs = ['default_branch', 'issues_enabled', 'wall_enabled',
911+
'merge_requests_enabled', 'wiki_enabled',
912+
'snippets_enabled', 'public', 'visibility_level',
913+
'description']
914+
915+
895916
class Project(GitlabObject):
896917
_url = '/projects'
897918
_constructorTypes = {'owner': 'User', 'namespace': 'Group'}
@@ -900,7 +921,8 @@ class Project(GitlabObject):
900921
requiredCreateAttrs = ['name']
901922
optionalCreateAttrs = ['default_branch', 'issues_enabled', 'wall_enabled',
902923
'merge_requests_enabled', 'wiki_enabled',
903-
'namespace_id']
924+
'snippets_enabled', 'public', 'visibility_level',
925+
'namespace_id', 'description']
904926
shortPrintAttr = 'path'
905927

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

0 commit comments

Comments
 (0)