@@ -424,8 +424,8 @@ def getprojectevents(self, id_, page=1, per_page=20):
424
424
def createproject (self , name , namespace_id = None , description = "" ,
425
425
issues_enabled = 0 , wall_enabled = 0 ,
426
426
merge_requests_enabled = 0 , wiki_enabled = 0 ,
427
- snippets_enabled = 0 , public = 0 , sudo = "" ,
428
- import_url = "" ):
427
+ snippets_enabled = 0 , public = 0 , visibility_level = - 1 ,
428
+ sudo = "" , import_url = "" ):
429
429
"""
430
430
Create a project
431
431
:param name: Obligatory
@@ -443,12 +443,32 @@ def createproject(self, name, namespace_id=None, description="",
443
443
if sudo != "" :
444
444
data ['sudo' ] = sudo
445
445
446
- # if gitlab is the new 6th version, there is a public option for the
447
- # project creation
446
+ # to define repository visibilty to other users, in gitlab version 6
447
+ # there is a public option and in gitlab version 7 there is a
448
+ # visibility_level option for the project creation.
448
449
if type (public ) != int :
449
450
raise TypeError
451
+ if type (visibility_level ) != int :
452
+ if type (visibility_level ) == str :
453
+ if visibility_level .lower () == "private" :
454
+ visibility_level = 0
455
+ elif visibility_level .lower () == "internal" :
456
+ visibility_level = 10
457
+ elif visibility_level .lower () == "public" :
458
+ visibility_level = 20
459
+ else :
460
+ raise ValueError
461
+ else :
462
+ raise TypeError
463
+
464
+ if visibility_level > 0 :
465
+ if public != 0 :
466
+ raise ValueError ('Only one of public and visibility_level arguments may be provided' )
467
+ data ['visibility_level' ] = visibility_level
468
+
450
469
if public != 0 :
451
470
data ['public' ] = public
471
+
452
472
request = requests .post (self .projects_url , headers = self .headers ,
453
473
data = data , verify = self .verify_ssl )
454
474
if request .status_code == 201 :
0 commit comments