Wiki Page

Supported by Redmine starting from version 2.2

Manager

All operations on the WikiPage resource are provided by it’s 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.ResourceManager.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.
  • title (string) – (required). Title of the wiki page.
  • text (string) – (required). Text 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 path to the file 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

>>> 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': '/absolute/path/to/file2'}]
... )
>>> wiki_page
<redminelib.resources.WikiPage "FooBar">

new

redminelib.managers.ResourceManager.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()
True

Read methods

get

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

Returns single WikiPage resource from Redmine by it’s 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 (string) – (optional). Can be used to fetch associated data in one call. Accepted values (separated by ,):
    • 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(524)
>>> wiki_page.attachments
<redminelib.resultsets.ResourceSet object with Attachment resources>

all

Not supported by Redmine

filter

redminelib.managers.ResourceManager.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.ResourceManager.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.
  • title (string) – (optional). Title of the wiki page.
  • text (string) – (optional). Text 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 path to the file 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

>>> redmine.wiki_page.update(
...     'Foo',
...     project_id='vacation',
...     title='FooBar',
...     text='foo',
...     parent_title='Yada',
...     comments='bar',
...     uploads=[{'path': '/absolute/path/to/file'}, {'path': '/absolute/path/to/file2'}]
... )
True

save

redminelib.resources.WikiPage.save()

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

Returns:True
>>> 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()
True

Delete methods

delete

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

Deletes single WikiPage resource from Redmine by it’s 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

New 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'
redminelib.resultsets.ResourceSet.export(fmt, savepath=None, filename=None)

Exports a resource set of WikiPage resources in one of the following formats: atom, pdf, html

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_pages = redmine.wiki_page.filter(project_id='vacation')
>>> wiki_pages.export('pdf', savepath='/home/jsmith', filename='wiki_pages.pdf')
'/home/jsmith/wiki_pages.pdf'