File: wikis.rst

package info (click to toggle)
python-gitlab 1%3A8.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,884 kB
  • sloc: python: 25,823; makefile: 171; ruby: 27; javascript: 3
file content (94 lines) | stat: -rw-r--r-- 2,385 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
##########
Wiki pages
##########


References
==========

* v4 API:

  + :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 for Projects: https://docs.gitlab.com/api/wikis
* GitLab API for Groups: https://docs.gitlab.com/api/group_wikis

Examples
--------

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_all=True)

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_all=True)

Get a single wiki page for a project::

    page = project.wikis.get(page_slug)

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()})

Update a wiki page::

    page.content = 'My new content'
    page.save()

Delete a wiki page::

    page.delete()


File uploads
============

Reference
---------

* v4 API:

  + :attr:`gitlab.v4.objects.ProjectWiki.upload`
  + :attr:`gitlab.v4.objects.GrouptWiki.upload`


* Gitlab API for Projects: https://docs.gitlab.com/api/wikis#upload-an-attachment-to-the-wiki-repository
* Gitlab API for Groups: https://docs.gitlab.com/api/group_wikis#upload-an-attachment-to-the-wiki-repository

Examples
--------

Upload a file into a project wiki using a filesystem path::

    page = project.wikis.get(page_slug)
    page.upload("filename.txt", filepath="/some/path/filename.txt")

Upload a file into a project wiki with raw data::

    page.upload("filename.txt", filedata="Raw data")

Upload a file into a group wiki using a filesystem path::

    page = group.wikis.get(page_slug)
    page.upload("filename.txt", filepath="/some/path/filename.txt")

Upload a file into a group wiki using raw data::

    page.upload("filename.txt", filedata="Raw data")