summaryrefslogtreecommitdiff
path: root/gitlab
diff options
context:
space:
mode:
Diffstat (limited to 'gitlab')
-rw-r--r--gitlab/__init__.py7
-rw-r--r--gitlab/objects.py28
2 files changed, 35 insertions, 0 deletions
diff --git a/gitlab/__init__.py b/gitlab/__init__.py
index b2d8cb6..badab53 100644
--- a/gitlab/__init__.py
+++ b/gitlab/__init__.py
@@ -444,6 +444,13 @@ class Gitlab(object):
"""
return UserProject._get_list_or_object(self, id, **kwargs)
+ def ProjectFork(self, id=None, **kwargs):
+ """Fork a project for a user.
+
+ id must be a dict.
+ """
+ return ProjectFork._get_list_or_object(self, id, **kwargs)
+
def _list_projects(self, url, **kwargs):
r = self._raw_get(url, **kwargs)
raise_error_from_response(r, GitlabListError)
diff --git a/gitlab/objects.py b/gitlab/objects.py
index 26896f2..db21eaf 100644
--- a/gitlab/objects.py
+++ b/gitlab/objects.py
@@ -545,6 +545,15 @@ class ProjectEventManager(BaseManager):
obj_cls = ProjectEvent
+class ProjectFork(GitlabObject):
+ _url = '/projects/fork/%(project_id)s'
+ canUpdate = False
+ canDelete = False
+ canList = False
+ canGet = False
+ requiredUrlAttrs = ['project_id']
+
+
class ProjectHook(GitlabObject):
_url = '/projects/%(project_id)s/hooks'
requiredUrlAttrs = ['project_id']
@@ -956,6 +965,25 @@ class Project(GitlabObject):
r = self.gitlab._raw_delete(url, **kwargs)
raise_error_from_response(r, GitlabDeleteError)
+ def create_fork_relation(self, forked_from_id):
+ """Create a forked from/to relation between existing projects.
+
+ Args:
+ forked_from_id (int): The ID of the project that was forked from
+
+ Raises:
+ GitlabCreateError: Operation failed
+ GitlabConnectionError: Connection to GitLab-server failed
+ """
+ url = "/projects/%s/fork/%s" % (self.id, forked_from_id)
+ r = self.gitlab._raw_post(url)
+ raise_error_from_response(r, GitlabCreateError, 201)
+
+ def delete_fork_relation(self):
+ url = "/projects/%s/fork" % self.id
+ r = self.gitlab._raw_delete(url)
+ raise_error_from_response(r, GitlabDeleteError)
+
class TeamMember(GitlabObject):
_url = '/user_teams/%(team_id)s/members'