Wiki Page

Supported by Redmine starting from version 2.2

Manager

All operations on the WikiPage resource are provided by its manager. To get access to it you have to call redmine.wiki_page where redmine is a configured redmine object. See the Configuration about how to configure redmine object.

Create methods

create

redminelib.managers.WikiPageManager.create(**fields)

Creates new WikiPage resource with given fields and saves it to the Redmine.

Parameters:
  • project_id (int or string) – (required). Id or identifier of wiki page’s project.

  • text (string) – (required). Text of the wiki page.

  • title (string) – (required). Title of the wiki page.

  • parent_title (string) – (optional). Title of parent wiki page.

  • comments (string) – (optional). Comments of the wiki page.

  • uploads (list) – (optional). Uploads as [{'': ''}, ...], accepted keys are:

    • path (required). Absolute file path or file-like object that should be uploaded.

    • filename (optional). Name of the file after upload.

    • description (optional). Description of the file.

    • content_type (optional). Content type of the file.

Returns:

Resource object

>>> from io import BytesIO
>>> wiki_page = redmine.wiki_page.create(
...     project_id='vacation',
...     title='FooBar',
...     text='foo',
...     parent_title='Yada',
...     comments='bar',
...     uploads=[{'path': '/absolute/path/to/file'}, {'path': BytesIO(b'I am content of file 2')}]
... )
>>> wiki_page
<redminelib.resources.WikiPage "FooBar">

new

redminelib.managers.WikiPageManager.new()

Creates new empty WikiPage resource but saves it to the Redmine only when save() is called, also calls pre_create() and post_create() methods of the Resource object. Valid attributes are the same as for create() method above.

Returns:

Resource object

>>> wiki_page = redmine.wiki_page.new()
>>> wiki_page.project_id = 'vacation'
>>> wiki_page.title = 'FooBar'
>>> wiki_page.text = 'foo'
>>> wiki_page.parent_title = 'Yada'
>>> wiki_page.comments = 'bar'
>>> wiki_page.uploads = [{'path': '/absolute/path/to/file'}, {'path': '/absolute/path/to/file2'}]
>>> wiki_page.save()
<redminelib.resources.WikiPage "FooBar">

Read methods

get

redminelib.managers.WikiPageManager.get(resource_id, **params)

Returns single WikiPage resource from Redmine by its title.

Parameters:
  • resource_id (string) – (required). Title of the wiki page.

  • project_id (int or string) – (required). Id or identifier of wiki page’s project.

  • version (int) – (optional). Version of the wiki page.

  • include (list) – (optional). Fetches associated data in one call. Accepted values:

    • attachments

Returns:

Resource object

>>> wiki_page = redmine.wiki_page.get('Photos', project_id='vacation', version=12, include=['attachments'])
>>> wiki_page
<redminelib.resources.WikiPage "Photos">

Hint

WikiPage resource object provides you with on demand includes. On demand includes are the other resource objects wrapped in a ResourceSet which are associated with a WikiPage resource object. Keep in mind that on demand includes are retrieved in a separate request, that means that if the speed is important it is recommended to use get() method with include keyword argument. On demand includes provided by the WikiPage resource object are the same as in the get() method above:

>>> wiki_page = redmine.wiki_page.get('Photos', project_id='vacation')
>>> wiki_page.attachments
<redminelib.resultsets.ResourceSet object with Attachment resources>

all

Not supported by Redmine

filter

redminelib.managers.WikiPageManager.filter(**filters)

Returns WikiPage resources that match the given lookup parameters.

Parameters:
  • project_id (int or string) – (required). Id or identifier of wiki page’s project.

  • limit (int) – (optional). How much resources to return.

  • offset (int) – (optional). Starting from what resource to return the other resources.

Returns:

ResourceSet object

>>> wiki_pages = redmine.wiki_page.filter(project_id='vacation')
>>> wiki_pages
<redminelib.resultsets.ResourceSet object with WikiPage resources>

Hint

You can also get wiki pages from a Project resource object directly using wiki_pages relation:

>>> project = redmine.project.get('vacation')
>>> project.wiki_pages
<redminelib.resultsets.ResourceSet object with WikiPage resources>

Update methods

update

redminelib.managers.WikiPageManager.update(resource_id, **fields)

Updates values of given fields of a WikiPage resource and saves them to the Redmine.

Parameters:
  • resource_id (string) – (required). Title of the wiki page.

  • project_id (int or string) – (required). Id or identifier of wiki page’s project.

  • text (string) – (required). Text of the wiki page.

  • title (string) – (optional). Title of the wiki page.

  • parent_title (string) – (optional). Title of parent wiki page.

  • comments (string) – (optional). Comments of the wiki page.

  • uploads (list) – (optional). Uploads as [{'': ''}, ...], accepted keys are:

    • path (required). Absolute file path or file-like object that should be uploaded.

    • filename (optional). Name of the file after upload.

    • description (optional). Description of the file.

    • content_type (optional). Content type of the file.

Returns:

True

>>> from io import BytesIO
>>> redmine.wiki_page.update(
...     'Foo',
...     project_id='vacation',
...     title='FooBar',
...     text='foo',
...     parent_title='Yada',
...     comments='bar',
...     uploads=[{'path': '/absolute/path/to/file'}, {'path': BytesIO(b'I am content of file 2')}]
... )
True

save

redminelib.resources.WikiPage.save(**attrs)

Saves the current state of a WikiPage resource to the Redmine. Attrs that can be changed are the same as for update() method above.

Returns:

Resource object

>>> wiki_page = redmine.wiki_page.get('Foo', project_id='vacation')
>>> wiki_page.title = 'Bar'
>>> wiki_page.text = 'bar'
>>> wiki_page.parent_title = 'Yada'
>>> wiki_page.comments = 'changed foo to bar'
>>> wiki_page.uploads = [{'path': '/absolute/path/to/file'}, {'path': '/absolute/path/to/file2'}]
>>> wiki_page.save()
<redminelib.resources.WikiPage "Bar">

Added in version 2.1.0: Alternative syntax was introduced.

>>> wiki_page = redmine.wiki_page.get('Foo', project_id='vacation').save(
...     title='Bar',
...     text='bar',
...     parent_title='Yada',
...     comments='changed foo to bar',
...     uploads=[{'path': '/absolute/path/to/file'}, {'path': '/absolute/path/to/file2'}]
... )
>>> wiki_page
<redminelib.resources.WikiPage "Bar">

Delete methods

delete

redminelib.managers.WikiPageManager.delete(resource_id, **params)

Deletes single WikiPage resource from Redmine by its title.

Parameters:
  • resource_id (string) – (required). Title of the wiki page.

  • project_id (int or string) – (required). Id or identifier of wiki page’s project.

Returns:

True

>>> redmine.wiki_page.delete('Foo', project_id=1)
True
redminelib.resources.WikiPage.delete()

Deletes current WikiPage resource object from Redmine.

Returns:

True

>>> wiki = redmine.wiki_page.get('Foo', project_id=1)
>>> wiki.delete()
True

Export

Added in version 2.0.0.

redminelib.resources.WikiPage.export(fmt, savepath=None, filename=None)

Exports WikiPage resource in one of the following formats: pdf, html, txt

Parameters:
  • fmt (string) – (required). Format to use for export.

  • savepath (string) – (optional). Path where to save the file.

  • filename (string) – (optional). Name that will be used for the file.

Returns:

String or Object

>>> wiki = redmine.wiki_page.get('Foo', project_id=1)
>>> wiki.export('pdf', savepath='/home/jsmith')
'/home/jsmith/123.pdf'