From 44a7c2788dd19c1fe73d7449bd7e1370816fd36d Mon Sep 17 00:00:00 2001 From: Choy Rim Date: Wed, 20 Nov 2019 00:03:18 -0500 Subject: [PATCH 1/2] fix(project-fork): correct path computation for project-fork list --- gitlab/v4/objects.py | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/gitlab/v4/objects.py b/gitlab/v4/objects.py index 3ac7a4a9f..370bb4c17 100644 --- a/gitlab/v4/objects.py +++ b/gitlab/v4/objects.py @@ -2049,7 +2049,7 @@ class ProjectFork(RESTObject): class ProjectForkManager(CreateMixin, ListMixin, RESTManager): - _path = "/projects/%(project_id)s/fork" + _path = "/projects/%(project_id)s/forks" _obj_cls = ProjectFork _from_parent_attrs = {"project_id": "id"} _list_filters = ( @@ -2069,28 +2069,6 @@ class ProjectForkManager(CreateMixin, ListMixin, RESTManager): ) _create_attrs = (tuple(), ("namespace",)) - def list(self, **kwargs): - """Retrieve a list of objects. - - Args: - all (bool): If True, return all the items, without pagination - per_page (int): Number of items to retrieve per request - page (int): ID of the page to return (starts with page 1) - as_list (bool): If set to False and no pagination option is - defined, return a generator instead of a list - **kwargs: Extra options to send to the server (e.g. sudo) - - Returns: - list: The list of objects, or a generator if `as_list` is False - - Raises: - GitlabAuthenticationError: If authentication is not correct - GitlabListError: If the server cannot perform the request - """ - - path = self._compute_path("/projects/%(project_id)s/forks") - return ListMixin.list(self, path=path, **kwargs) - class ProjectHook(SaveMixin, ObjectDeleteMixin, RESTObject): _short_print_attr = "url" From 516307f1cc9e140c7d85d0ed0c419679b314f80b Mon Sep 17 00:00:00 2001 From: Choy Rim Date: Wed, 20 Nov 2019 02:38:42 -0500 Subject: [PATCH 2/2] fix(project-fork): copy create fix from ProjectPipelineManager --- gitlab/v4/objects.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/gitlab/v4/objects.py b/gitlab/v4/objects.py index 370bb4c17..2b1f9555a 100644 --- a/gitlab/v4/objects.py +++ b/gitlab/v4/objects.py @@ -2069,6 +2069,25 @@ class ProjectForkManager(CreateMixin, ListMixin, RESTManager): ) _create_attrs = (tuple(), ("namespace",)) + def create(self, data, **kwargs): + """Creates a new object. + + Args: + data (dict): Parameters to send to the server to create the + resource + **kwargs: Extra options to send to the server (e.g. sudo) + + Raises: + GitlabAuthenticationError: If authentication is not correct + GitlabCreateError: If the server cannot perform the request + + Returns: + RESTObject: A new instance of the managed object class build with + the data sent by the server + """ + path = self.path[:-1] # drop the 's' + return CreateMixin.create(self, data, path=path, **kwargs) + class ProjectHook(SaveMixin, ObjectDeleteMixin, RESTObject): _short_print_attr = "url"