@@ -63,16 +63,28 @@ def each(self, after=None, role=None, q=None, sort=None):
6363
6464
6565class WorkspaceRepositories (RepositoriesBase ):
66+ ALLOW_FORKS = "allow_forks"
67+ NO_PUBLIC_FORKS = "no_public_forks"
68+ NO_FORKS = "no_forks"
69+ FORK_POLICIES = [
70+ ALLOW_FORKS ,
71+ NO_PUBLIC_FORKS ,
72+ NO_FORKS ,
73+ ]
74+
6675 def __init__ (self , url , * args , ** kwargs ):
6776 super (WorkspaceRepositories , self ).__init__ (url , * args , ** kwargs )
6877
69- def create (self , repo_slug , project_key = None ):
78+ def create (self , repo_slug , project_key = None , is_private = None , fork_policy = None ):
7079 """
7180 Creates a new repository with the given repo_slug.
7281
7382 :param repo_slug: string: The repo_slug of the project.
7483 :param project_key: string: The key of the project. If the project is not provided, the repository
7584 is automatically assigned to the oldest project in the workspace.
85+ :param is_private: boolean: Set to false if the repository shall be public.
86+ :param fork_policy: string: The fork policy (one of WorkspaceRepositories.ALLOW_FORKS,
87+ WorkspaceRepositories.NO_PUBLIC_FORKS, WorkspaceRepositories.NO_FORKS).
7688
7789 :return: The created project object
7890
@@ -82,6 +94,12 @@ def create(self, repo_slug, project_key=None):
8294 data = {"scm" : "git" }
8395 if project_key is not None :
8496 data ["project" ] = {"key" : project_key }
97+ if is_private is not None :
98+ data ["is_private" ] = is_private
99+ if fork_policy is not None :
100+ if fork_policy not in self .FORK_POLICIES :
101+ raise ValueError ("fork_policy must be one of {}" .format (self .FORK_POLICIES ))
102+ data ["fork_policy" ] = fork_policy
85103 return self ._get_object (self .post (repo_slug , data = data ))
86104
87105 def each (self , role = None , q = None , sort = None ):
@@ -277,6 +295,11 @@ def is_private(self, is_private):
277295 """Setter for the repository private flag"""
278296 return self .update (is_private = is_private )
279297
298+ @property
299+ def fork_policy (self ):
300+ """Getter for the repository fork policy"""
301+ return self .get_data ("fork_policy" )
302+
280303 @property
281304 def uuid (self ):
282305 """The repository uuid"""
0 commit comments