Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(objects): add support for Group wikis#1484

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
nejch merged 6 commits intopython-gitlab:masterfromspamsch:master
Jun 2, 2021
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletionsdocs/gl_objects/wikis.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,21 +11,37 @@ References
+ :class:`gitlab.v4.objects.ProjectWiki`
+ :class:`gitlab.v4.objects.ProjectWikiManager`
+ :attr:`gitlab.v4.objects.Project.wikis`
+ :class:`gitlab.v4.objects.GroupWiki`
+ :class:`gitlab.v4.objects.GroupWikiManager`
+ :attr:`gitlab.v4.objects.Group.wikis`

* GitLab API: https://docs.gitlab.com/ce/api/wikis.html
* GitLab API for Projects: https://docs.gitlab.com/ce/api/wikis.html
* GitLab API for Groups: https://docs.gitlab.com/ee/api/group_wikis.html

Examples
--------

Get the list of wiki pages for a project::
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::

pages = project.wikis.list()

Get a single wiki page::
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::

pages = group.wikis.list()

Get a single wiki page for a project::

page = project.wikis.get(page_slug)

Create a wiki page::
Get a single wiki page for a group::

page = group.wikis.get(page_slug)

Get the contents of a wiki page::

print(page.content)

Create a wiki page on a project level::

page = project.wikis.create({'title': 'Wiki Page 1',
'content': open(a_file).read()})
Expand Down
2 changes: 2 additions & 0 deletionsgitlab/v4/objects/groups.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,6 +28,7 @@
from .runners import GroupRunnerManager # noqa: F401
from .statistics import GroupIssuesStatisticsManager # noqa: F401
from .variables import GroupVariableManager # noqa: F401
from .wikis import GroupWikiManager # noqa: F401

__all__ = [
"Group",
Expand DownExpand Up@@ -67,6 +68,7 @@ class Group(SaveMixin, ObjectDeleteMixin, RESTObject):
("variables", "GroupVariableManager"),
("clusters", "GroupClusterManager"),
("deploytokens", "GroupDeployTokenManager"),
("wikis", "GroupWikiManager"),
)

@cli.register_custom_action("Group", ("to_project_id",))
Expand Down
18 changes: 18 additions & 0 deletionsgitlab/v4/objects/wikis.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,6 +4,8 @@
__all__ = [
"ProjectWiki",
"ProjectWikiManager",
"GroupWiki",
"GroupWikiManager",
]


Expand All@@ -21,3 +23,19 @@ class ProjectWikiManager(CRUDMixin, RESTManager):
)
_update_attrs = RequiredOptional(optional=("title", "content", "format"))
_list_filters = ("with_content",)


class GroupWiki(SaveMixin, ObjectDeleteMixin, RESTObject):
_id_attr = "slug"
_short_print_attr = "slug"


class GroupWikiManager(CRUDMixin, RESTManager):
_path = "/groups/%(group_id)s/wikis"
_obj_cls = GroupWiki
_from_parent_attrs = {"group_id": "id"}
_create_attrs = RequiredOptional(
required=("title", "content"), optional=("format",)
)
_update_attrs = RequiredOptional(optional=("title", "content", "format"))
_list_filters = ("with_content",)
15 changes: 15 additions & 0 deletionstests/functional/api/test_groups.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -194,3 +194,18 @@ def test_group_subgroups_projects(gl, user):
assert group4.parent_id == group2.id
assert gr1_project.namespace["id"] == group1.id
assert gr2_project.namespace["parent_id"] == group1.id


@pytest.mark.skip
def test_group_wiki(group):
content = "Group Wiki page content"
wiki = group.wikis.create({"title": "groupwikipage", "content": content})
assert len(group.wikis.list()) == 1

wiki = group.wikis.get(wiki.slug)
assert wiki.content == content

wiki.content = "new content"
wiki.save()
wiki.delete()
assert len(group.wikis.list()) == 0

[8]ページ先頭

©2009-2025 Movatter.jp