From 46f1240633c14d40e37c628a6866fe8f9f0a866b Mon Sep 17 00:00:00 2001 From: Yoann Goular Date: Fri, 10 May 2019 11:09:31 +0200 Subject: [PATCH] Add Confluence markup format parameter It will allow to create Confluence pages that will be interpreted with the wiki markup syntax. More info about Confluence formats here: https://confluence.atlassian.com/doc/confluence-markup-283640216.html Change-Id: I2534634a1b1eec1b9d970e5a055b8e73735fd8c9 --- atlassian/confluence.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/atlassian/confluence.py b/atlassian/confluence.py index 22f69936d..43d106216 100644 --- a/atlassian/confluence.py +++ b/atlassian/confluence.py @@ -279,7 +279,8 @@ def remove_page(self, page_id, status=None, recursive=False): params['status'] = status return self.delete(url, params=params) - def create_page(self, space, title, body, parent_id=None, type='page'): + def create_page(self, space, title, body, parent_id=None, type='page', + representation='storage'): """ Create page from scratch :param space: @@ -287,17 +288,20 @@ def create_page(self, space, title, body, parent_id=None, type='page'): :param body: :param parent_id: :param type: + :param representation: OPTIONAL: either Confluence 'storage' or 'wiki' markup format :return: """ log.info('Creating {type} "{space}" -> "{title}"'.format(space=space, title=title, type=type)) + if representation not in ['wiki', 'storage']: + raise ValueError("Wrong value for representation, it should be either wiki or storage") url = 'rest/api/content/' data = { 'type': type, 'title': title, 'space': {'key': space}, - 'body': {'storage': { + 'body': {representation: { 'value': body, - 'representation': 'storage'}}} + 'representation': representation}}} if parent_id: data['ancestors'] = [{'type': type, 'id': parent_id}] return self.post(url, data=data)