Skip to content
Merged
Changes from all 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
10 changes: 7 additions & 3 deletions atlassian/confluence.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,25 +279,29 @@ 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:
:param title:
: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)
Expand Down