Skip to content

Instantly share code, notes, and snippets.

@toru-takahashi
Last active June 2, 2022 20:58
Show Gist options
  • Save toru-takahashi/7df580f2684197fc6f0ac4f62e46a6d3 to your computer and use it in GitHub Desktop.
Save toru-takahashi/7df580f2684197fc6f0ac4f62e46a6d3 to your computer and use it in GitHub Desktop.
Confluence page info to TD
from atlassian import Confluence
import json
import sys
from fluent import sender
from fluent import event
def get_all_page_ids_from_space(space):
"""
:param space:
:return:
"""
limit = 500
flag = True
step = 0
pages = []
while flag:
values = confluence.get_all_pages_from_space(space=space, start=limit * step, limit=limit)
step += 1
if len(values) == 0:
flag = False
print("Did not find any pages, please, check permissions")
else:
for value in values:
print("Retrieve page with title: " + value["title"])
pages.append(value)
print("Found in space {} pages {}".format(space, len(pages)))
return pages
if __name__ == "__main__":
# python confluence.py example.confluence.com username password
args = sys.argv
confluence = Confluence(
url='https://' + args[1],
username=args[2],
password=args[3])
sender.setup('td.confluence', host='127.0.0.1', port=24224)
pages = []
history = []
for space_key in ['PD', 'INT']:
pages = get_all_page_ids_from_space(space_key)
for page in pages:
value = confluence.get_content_history(page['id'])
event.Event('pages', page)
value['id'] = page['id']
event.Event('history', value)
for n in range(1, int(value['lastUpdated']['number'])):
revision = confluence.get_content_history_by_version_number(page['id'], n)
revision['id'] = page['id']
event.Event('revisions', revision)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment