From a527dbecc6d606566f0b908b6277774af2e9b24b Mon Sep 17 00:00:00 2001 From: Cristiano Casella Date: Mon, 12 Feb 2024 09:25:00 +0100 Subject: [PATCH 1/3] feat: Added "in" parameter to project/group iteration search --- gitlab/v4/objects/iterations.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gitlab/v4/objects/iterations.py b/gitlab/v4/objects/iterations.py index 30895ff46..fbeef4ef0 100644 --- a/gitlab/v4/objects/iterations.py +++ b/gitlab/v4/objects/iterations.py @@ -16,11 +16,11 @@ class GroupIterationManager(ListMixin, RESTManager): _path = "/groups/{group_id}/iterations" _obj_cls = GroupIteration _from_parent_attrs = {"group_id": "id"} - _list_filters = ("state", "search", "include_ancestors") + _list_filters = ("state", "search", "in", "include_ancestors") class ProjectIterationManager(ListMixin, RESTManager): _path = "/projects/{project_id}/iterations" _obj_cls = GroupIteration _from_parent_attrs = {"project_id": "id"} - _list_filters = ("state", "search", "include_ancestors") + _list_filters = ("state", "search", "in", "include_ancestors") From 9a7f3e29f0825ff59102a30739af6f879662e8a9 Mon Sep 17 00:00:00 2001 From: Cristiano Casella Date: Mon, 12 Feb 2024 09:25:00 +0100 Subject: [PATCH 2/3] feat: Added additional parameter to project/group iteration search --- docs/gl_objects/iterations.rst | 10 ++++++++++ gitlab/v4/objects/iterations.py | 31 +++++++++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/docs/gl_objects/iterations.rst b/docs/gl_objects/iterations.rst index 8db0c2e85..8ff7f4149 100644 --- a/docs/gl_objects/iterations.rst +++ b/docs/gl_objects/iterations.rst @@ -31,3 +31,13 @@ List iterations for a project's ancestor groups:: List iterations for a group:: iterations = group.iterations.list() + +Unavailable filters or keyword conflicts:: + + In case you are trying to pass a parameter that collides with a python + keyword (i.e. `in`) or with python-gitlab's internal arguments, you'll have + to use the `query_parameters` argument: + + ``` + group.iterations.list(query_parameters={"in": "title"}) + ``` diff --git a/gitlab/v4/objects/iterations.py b/gitlab/v4/objects/iterations.py index fbeef4ef0..7de83d590 100644 --- a/gitlab/v4/objects/iterations.py +++ b/gitlab/v4/objects/iterations.py @@ -1,3 +1,4 @@ +from gitlab import types from gitlab.base import RESTManager, RESTObject from gitlab.mixins import ListMixin @@ -16,11 +17,37 @@ class GroupIterationManager(ListMixin, RESTManager): _path = "/groups/{group_id}/iterations" _obj_cls = GroupIteration _from_parent_attrs = {"group_id": "id"} - _list_filters = ("state", "search", "in", "include_ancestors") + # When using the API, the "in" keyword collides with python's "in" keyword + # raising a SyntaxError. + # For this reason, we have to use the query_parameters argument: + # group.iterations.list(query_parameters={"in": "title"}) + _list_filters = ( + "include_ancestors", + "include_descendants", + "in", + "search", + "state", + "updated_after", + "updated_before", + ) + _types = {"scopes": types.ArrayAttribute} class ProjectIterationManager(ListMixin, RESTManager): _path = "/projects/{project_id}/iterations" _obj_cls = GroupIteration _from_parent_attrs = {"project_id": "id"} - _list_filters = ("state", "search", "in", "include_ancestors") + # When using the API, the "in" keyword collides with python's "in" keyword + # raising a SyntaxError. + # For this reason, we have to use the query_parameters argument: + # project.iterations.list(query_parameters={"in": "title"}) + _list_filters = ( + "include_ancestors", + "include_descendants", + "in", + "search", + "state", + "updated_after", + "updated_before", + ) + _types = {"in": types.ArrayAttribute} From f4094d296b4531a49d98bdb69c55c7259fe9c97d Mon Sep 17 00:00:00 2001 From: Nejc Habjan Date: Wed, 22 May 2024 13:08:35 +0200 Subject: [PATCH 3/3] chore: apply review suggestion --- gitlab/v4/objects/iterations.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitlab/v4/objects/iterations.py b/gitlab/v4/objects/iterations.py index 7de83d590..eac3f1f4e 100644 --- a/gitlab/v4/objects/iterations.py +++ b/gitlab/v4/objects/iterations.py @@ -30,7 +30,7 @@ class GroupIterationManager(ListMixin, RESTManager): "updated_after", "updated_before", ) - _types = {"scopes": types.ArrayAttribute} + _types = {"in": types.ArrayAttribute} class ProjectIterationManager(ListMixin, RESTManager):