import os
from atlassian import Confluence
CONFLUENCE = Confluence(
url=f"https://{os.environ['CONFLUENCE_SITE']}.atlassian.net",
username=os.environ['CONFLUENCE_USER'],
password=os.environ['CONFLUENCE_TOKEN'],
cloud=True)
def get_confluence_page_source(title: str = None, page_id: int = None):
"""
Retrieve a string representing the body of a Confluence page as Confluence Storage Format.
see: https://confluence.atlassian.com/doc/confluence-storage-format-790796544.html
Useful to get macros and other formatting not found in the normal body contents.
Parameters:
title : (optional if page_id is given) the name of the page to retrieve (must have environment variable "CONFLUENCE_SPACE" set)
page_id : (optional if title is given) the page ID to retrieve, eg. 28280848470
Examples:
>>> CONFLUENCE = Confluence(
url=f"https://{os.environ['CONFLUENCE_SITE']}.atlassian.net",
username=os.environ['CONFLUENCE_USER'],
password=os.environ['CONFLUENCE_TOKEN'],
cloud=True)
>>> get_confluence_page_source(page_id=os.environ['CONFLUENCE_PARENT_PAGE_ID'])
'