@@ -11,21 +11,37 @@ References | |||
| 11 | 11 | + :class:`gitlab.v4.objects.ProjectWiki` | |
| 12 | 12 | + :class:`gitlab.v4.objects.ProjectWikiManager` | |
| 13 | 13 | + :attr:`gitlab.v4.objects.Project.wikis` | |
| 14 | + + :class:`gitlab.v4.objects.GroupWiki` | ||
| 15 | + + :class:`gitlab.v4.objects.GroupWikiManager` | ||
| 16 | + + :attr:`gitlab.v4.objects.Group.wikis` | ||
| 14 | 17 | ||
| 15 | - * GitLab API: https://docs.gitlab.com/ce/api/wikis.html | ||
| 18 | + * GitLab API for Projects: https://docs.gitlab.com/ce/api/wikis.html | ||
| 19 | + * GitLab API for Groups: https://docs.gitlab.com/ee/api/group_wikis.html | ||
| 16 | 20 | ||
| 17 | 21 | Examples | |
| 18 | 22 | -------- | |
| 19 | 23 | ||
| 20 | - Get the list of wiki pages for a project:: | ||
| 24 | + Get the list of wiki pages for a project. These do not contain the contents of the wiki page. You will need to call get(slug) to retrieve the content by accessing the content attribute:: | ||
| 21 | 25 | ||
| 22 | 26 | pages = project.wikis.list() | |
| 23 | 27 | ||
| 24 | - Get a single wiki page:: | ||
| 28 | + Get the list of wiki pages for a group. These do not contain the contents of the wiki page. You will need to call get(slug) to retrieve the content by accessing the content attribute:: | ||
| 29 | + | ||
| 30 | + pages = group.wikis.list() | ||
| 31 | + | ||
| 32 | + Get a single wiki page for a project:: | ||
| 25 | 33 | ||
| 26 | 34 | page = project.wikis.get(page_slug) | |
| 27 | 35 | ||
| 28 | - Create a wiki page:: | ||
| 36 | + Get a single wiki page for a group:: | ||
| 37 | + | ||
| 38 | + page = group.wikis.get(page_slug) | ||
| 39 | + | ||
| 40 | + Get the contents of a wiki page:: | ||
| 41 | + | ||
| 42 | + print(page.content) | ||
| 43 | + | ||
| 44 | + Create a wiki page on a project level:: | ||
| 29 | 45 | ||
| 30 | 46 | page = project.wikis.create({'title': 'Wiki Page 1', | |
| 31 | 47 | 'content': open(a_file).read()}) | |
@@ -28,6 +28,7 @@ | |||
| 28 | 28 | from .runners import GroupRunnerManager # noqa: F401 | |
| 29 | 29 | from .statistics import GroupIssuesStatisticsManager # noqa: F401 | |
| 30 | 30 | from .variables import GroupVariableManager # noqa: F401 | |
| 31 | + from .wikis import GroupWikiManager # noqa: F401 | ||
| 31 | 32 | ||
| 32 | 33 | __all__ = [ | |
| 33 | 34 | "Group", | |
@@ -67,6 +68,7 @@ class Group(SaveMixin, ObjectDeleteMixin, RESTObject): | |||
| 67 | 68 | ("variables", "GroupVariableManager"), | |
| 68 | 69 | ("clusters", "GroupClusterManager"), | |
| 69 | 70 | ("deploytokens", "GroupDeployTokenManager"), | |
| 71 | + ("wikis", "GroupWikiManager"), | ||
| 70 | 72 | ) | |
| 71 | 73 | ||
| 72 | 74 | @cli.register_custom_action("Group", ("to_project_id",)) | |
@@ -4,6 +4,8 @@ | |||
| 4 | 4 | __all__ = [ | |
| 5 | 5 | "ProjectWiki", | |
| 6 | 6 | "ProjectWikiManager", | |
| 7 | + "GroupWiki", | ||
| 8 | + "GroupWikiManager", | ||
| 7 | 9 | ] | |
| 8 | 10 | ||
| 9 | 11 | ||
@@ -21,3 +23,19 @@ class ProjectWikiManager(CRUDMixin, RESTManager): | |||
| 21 | 23 | ) | |
| 22 | 24 | _update_attrs = RequiredOptional(optional=("title", "content", "format")) | |
| 23 | 25 | _list_filters = ("with_content",) | |
| 26 | + | ||
| 27 | + | ||
| 28 | + class GroupWiki(SaveMixin, ObjectDeleteMixin, RESTObject): | ||
| 29 | + _id_attr = "slug" | ||
| 30 | + _short_print_attr = "slug" | ||
| 31 | + | ||
| 32 | + | ||
| 33 | + class GroupWikiManager(CRUDMixin, RESTManager): | ||
| 34 | + _path = "/groups/%(group_id)s/wikis" | ||
| 35 | + _obj_cls = GroupWiki | ||
| 36 | + _from_parent_attrs = {"group_id": "id"} | ||
| 37 | + _create_attrs = RequiredOptional( | ||
| 38 | + required=("title", "content"), optional=("format",) | ||
| 39 | + ) | ||
| 40 | + _update_attrs = RequiredOptional(optional=("title", "content", "format")) | ||
| 41 | + _list_filters = ("with_content",) | ||
@@ -194,3 +194,18 @@ def test_group_subgroups_projects(gl, user): | |||
| 194 | 194 | assert group4.parent_id == group2.id | |
| 195 | 195 | assert gr1_project.namespace["id"] == group1.id | |
| 196 | 196 | assert gr2_project.namespace["parent_id"] == group1.id | |
| 197 | + | ||
| 198 | + | ||
| 199 | + @pytest.mark.skip | ||
| 200 | + def test_group_wiki(group): | ||
| 201 | + content = "Group Wiki page content" | ||
| 202 | + wiki = group.wikis.create({"title": "groupwikipage", "content": content}) | ||
| 203 | + assert len(group.wikis.list()) == 1 | ||
| 204 | + | ||
| 205 | + wiki = group.wikis.get(wiki.slug) | ||
| 206 | + assert wiki.content == content | ||
| 207 | + | ||
| 208 | + wiki.content = "new content" | ||
| 209 | + wiki.save() | ||
| 210 | + wiki.delete() | ||
| 211 | + assert len(group.wikis.list()) == 0 | ||
0 commit comments