| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 66461ba commit 194ee01
7 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -28,6 +28,7 @@ API examples | |||
| 28 | 28 | gl_objects/group_access_tokens | |
| 29 | 29 | gl_objects/invitations | |
| 30 | 30 | gl_objects/issues | |
| 31 | + gl_objects/iterations | ||
| 31 | 32 | gl_objects/keys | |
| 32 | 33 | gl_objects/boards | |
| 33 | 34 | gl_objects/labels | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,33 @@ | |||
| 1 | + ########## | ||
| 2 | + Iterations | ||
| 3 | + ########## | ||
| 4 | + | ||
| 5 | + | ||
| 6 | + Reference | ||
| 7 | + --------- | ||
| 8 | + | ||
| 9 | + * v4 API: | ||
| 10 | + | ||
| 11 | + + :class:`gitlab.v4.objects.GroupIteration` | ||
| 12 | + + :class:`gitlab.v4.objects.GroupIterationManager` | ||
| 13 | + + :attr:`gitlab.v4.objects.Group.iterations` | ||
| 14 | + + :class:`gitlab.v4.objects.ProjectIterationManager` | ||
| 15 | + + :attr:`gitlab.v4.objects.Project.iterations` | ||
| 16 | + | ||
| 17 | + * GitLab API: https://docs.gitlab.com/ee/api/iterations.html | ||
| 18 | + | ||
| 19 | + Examples | ||
| 20 | + -------- | ||
| 21 | + | ||
| 22 | + .. note:: | ||
| 23 | + | ||
| 24 | + GitLab no longer has project iterations. Using a project endpoint returns | ||
| 25 | + the ancestor groups' iterations. | ||
| 26 | + | ||
| 27 | + List iterations for a project's ancestor groups:: | ||
| 28 | + | ||
| 29 | + iterations = project.iterations.list() | ||
| 30 | + | ||
| 31 | + List iterations for a group:: | ||
| 32 | + | ||
| 33 | + iterations = group.iterations.list() | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -47,6 +47,7 @@ | |||
| 47 | 47 | from .integrations import * | |
| 48 | 48 | from .invitations import * | |
| 49 | 49 | from .issues import * | |
| 50 | + from .iterations import * | ||
| 50 | 51 | from .jobs import * | |
| 51 | 52 | from .keys import * | |
| 52 | 53 | from .labels import * | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -24,6 +24,7 @@ | |||
| 24 | 24 | from .hooks import GroupHookManager # noqa: F401 | |
| 25 | 25 | from .invitations import GroupInvitationManager # noqa: F401 | |
| 26 | 26 | from .issues import GroupIssueManager # noqa: F401 | |
| 27 | + from .iterations import GroupIterationManager # noqa: F401 | ||
| 27 | 28 | from .labels import GroupLabelManager # noqa: F401 | |
| 28 | 29 | from .members import ( # noqa: F401 | |
| 29 | 30 | GroupBillableMemberManager, | |
@@ -71,6 +72,7 @@ class Group(SaveMixin, ObjectDeleteMixin, RESTObject): | |||
| 71 | 72 | invitations: GroupInvitationManager | |
| 72 | 73 | issues: GroupIssueManager | |
| 73 | 74 | issues_statistics: GroupIssuesStatisticsManager | |
| 75 | + iterations: GroupIterationManager | ||
| 74 | 76 | labels: GroupLabelManager | |
| 75 | 77 | members: GroupMemberManager | |
| 76 | 78 | members_all: GroupMemberAllManager | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,26 @@ | |||
| 1 | + from gitlab.base import RESTManager, RESTObject | ||
| 2 | + from gitlab.mixins import ListMixin | ||
| 3 | + | ||
| 4 | + __all__ = [ | ||
| 5 | + "ProjectIterationManager", | ||
| 6 | + "GroupIteration", | ||
| 7 | + "GroupIterationManager", | ||
| 8 | + ] | ||
| 9 | + | ||
| 10 | + | ||
| 11 | + class GroupIteration(RESTObject): | ||
| 12 | + _repr_attr = "title" | ||
| 13 | + | ||
| 14 | + | ||
| 15 | + class GroupIterationManager(ListMixin, RESTManager): | ||
| 16 | + _path = "/groups/{group_id}/iterations" | ||
| 17 | + _obj_cls = GroupIteration | ||
| 18 | + _from_parent_attrs = {"group_id": "id"} | ||
| 19 | + _list_filters = ("state", "search", "include_ancestors") | ||
| 20 | + | ||
| 21 | + | ||
| 22 | + class ProjectIterationManager(ListMixin, RESTManager): | ||
| 23 | + _path = "/projects/{project_id}/iterations" | ||
| 24 | + _obj_cls = GroupIteration | ||
| 25 | + _from_parent_attrs = {"project_id": "id"} | ||
| 26 | + _list_filters = ("state", "search", "include_ancestors") | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -57,6 +57,7 @@ | |||
| 57 | 57 | from .integrations import ProjectIntegrationManager, ProjectServiceManager # noqa: F401 | |
| 58 | 58 | from .invitations import ProjectInvitationManager # noqa: F401 | |
| 59 | 59 | from .issues import ProjectIssueManager # noqa: F401 | |
| 60 | + from .iterations import GroupIterationManager # noqa: F401 | ||
| 60 | 61 | from .jobs import ProjectJobManager # noqa: F401 | |
| 61 | 62 | from .labels import ProjectLabelManager # noqa: F401 | |
| 62 | 63 | from .members import ProjectMemberAllManager, ProjectMemberManager # noqa: F401 | |
@@ -185,6 +186,7 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO | |||
| 185 | 186 | invitations: ProjectInvitationManager | |
| 186 | 187 | issues: ProjectIssueManager | |
| 187 | 188 | issues_statistics: ProjectIssuesStatisticsManager | |
| 189 | + iterations: GroupIterationManager | ||
| 188 | 190 | jobs: ProjectJobManager | |
| 189 | 191 | keys: ProjectKeyManager | |
| 190 | 192 | labels: ProjectLabelManager | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,47 @@ | |||
| 1 | + """ | ||
| 2 | + GitLab API: https://docs.gitlab.com/ee/api/iterations.html | ||
| 3 | + """ | ||
| 4 | + | ||
| 5 | + import re | ||
| 6 | + | ||
| 7 | + import pytest | ||
| 8 | + import responses | ||
| 9 | + | ||
| 10 | + iterations_content = [ | ||
| 11 | + { | ||
| 12 | + "id": 53, | ||
| 13 | + "iid": 13, | ||
| 14 | + "group_id": 5, | ||
| 15 | + "title": "Iteration II", | ||
| 16 | + "description": "Ipsum Lorem ipsum", | ||
| 17 | + "state": 2, | ||
| 18 | + "created_at": "2020-01-27T05:07:12.573Z", | ||
| 19 | + "updated_at": "2020-01-27T05:07:12.573Z", | ||
| 20 | + "due_date": "2020-02-01", | ||
| 21 | + "start_date": "2020-02-14", | ||
| 22 | + "web_url": "http://gitlab.example.com/groups/my-group/-/iterations/13", | ||
| 23 | + } | ||
| 24 | + ] | ||
| 25 | + | ||
| 26 | + | ||
| 27 | + @pytest.fixture | ||
| 28 | + def resp_iterations_list(): | ||
| 29 | + with responses.RequestsMock() as rsps: | ||
| 30 | + rsps.add( | ||
| 31 | + method=responses.GET, | ||
| 32 | + url=re.compile(r"http://localhost/api/v4/(groups|projects)/1/iterations"), | ||
| 33 | + json=iterations_content, | ||
| 34 | + content_type="application/json", | ||
| 35 | + status=200, | ||
| 36 | + ) | ||
| 37 | + yield rsps | ||
| 38 | + | ||
| 39 | + | ||
| 40 | + def test_list_group_iterations(group, resp_iterations_list): | ||
| 41 | + iterations = group.iterations.list() | ||
| 42 | + assert iterations[0].group_id == 5 | ||
| 43 | + | ||
| 44 | + | ||
| 45 | + def test_list_project_iterations(project, resp_iterations_list): | ||
| 46 | + iterations = project.iterations.list() | ||
| 47 | + assert iterations[0].group_id == 5 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments